-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_config.py
54 lines (48 loc) · 1.41 KB
/
edit_config.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
from ncclient import manager
eos=manager.connect(host="10.83.28.203", port="830", timeout=30, username="arista", password="arista", hostkey_verify=False)
conf = '''
<config>
<system>
<config>
<domain-name>abc.xyz</domain-name>
<hostname>switch1</hostname>
</config>
<dns>
<config>
<network-instance xmlns="http://arista.com/yang/openconfig/system/augments">default</network-instance>
</config>
<servers>
<server>
<address>
8.8.8.8
</address>
<config>
<address>8.8.8.8</address>
<port>53</port>
</config>
</server>
<server>
<address>10.83.28.52</address>
<config>
<address>10.83.28.52</address>
<port>53</port>
</config>
</server>
</servers>
</dns>
</system>
</config>
'''
configuration = eos.edit_config(target = "running", config = conf)
print(configuration)
dns_servers='''
<system>
<dns>
<servers>
</servers>
</dns>
</system>
'''
dns_servers_conf = eos.get_config(source="running", filter=("subtree", dns_servers))
print (dns_servers_conf)
eos.close_session()