-
Notifications
You must be signed in to change notification settings - Fork 3
/
edit_config_delete.py
68 lines (63 loc) · 1.87 KB
/
edit_config_delete.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from ncclient import manager
eos=manager.connect(host="10.83.28.221", port="830", timeout=30, username="arista", password="arista", hostkey_verify=False)
# Edit the running configuration with delete operation
# Get first the running configuration to be sure to then delete existing configuration data
conf = '''
<system xmlns="http://arista.com/yang/openconfig/system/">
<config>
<domain-name>
</domain-name>
</config>
<dns>
<servers>
<server>
</server>
</servers>
</dns>
<aaa>
<authentication>
<users>
<user>
<username>
</username>
</user>
</users>
</authentication>
</aaa>
</system>
'''
eos.get_config(source="running", filter=("subtree", conf))
conf = '''
<config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<system xmlns="http://arista.com/yang/openconfig/system/">
<config>
<domain-name operation="delete">abc.xyz</domain-name>
</config>
<dns>
<servers>
<server>
<address operation="delete">1.1.1.1</address>
</server>
</servers>
</dns>
</system>
</config>
'''
reply = eos.edit_config(target = "running", config = conf, default_operation="none")
conf = '''
<config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<system xmlns="http://arista.com/yang/openconfig/system/">
<aaa>
<authentication>
<users>
<user>
<username operation="delete">gnmi</username>
</user>
</users>
</authentication>
</aaa>
</system>
</config>
'''
reply = eos.edit_config(target = "running", config = conf, default_operation="none")
eos.close_session()