root / examples / nc05.py @ master
History | View | Annotate | Download (916 Bytes)
1 |
#! /usr/bin/env python2.6
|
---|---|
2 |
#
|
3 |
# Delete an existing user from the running configuration using
|
4 |
# edit-config and the test-option provided by the :validate
|
5 |
# capability.
|
6 |
#
|
7 |
# $ ./nc05.py broccoli bob
|
8 |
|
9 |
import sys, os, warnings |
10 |
warnings.simplefilter("ignore", DeprecationWarning) |
11 |
from ncclient import manager |
12 |
|
13 |
def demo(host, user, name): |
14 |
snippet = """<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
|
15 |
<aaa xmlns="http://tail-f.com/ns/aaa/1.1">
|
16 |
<authentication> <users> <user xc:operation="delete">
|
17 |
<name>%s</name>
|
18 |
</user></users></authentication></aaa></config>""" % name
|
19 |
|
20 |
with manager.connect(host=host, port=22, username=user) as m: |
21 |
assert(":validate" in m.server_capabilities) |
22 |
m.edit_config(target='running', config=snippet,
|
23 |
test_option='test-then-set')
|
24 |
|
25 |
if __name__ == '__main__': |
26 |
demo(sys.argv[1], os.getenv("USER"), sys.argv[2]) |