-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathget.py
60 lines (53 loc) · 1.71 KB
/
get.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
from ncclient import manager
eos=manager.connect(host="10.83.28.203", port="830", timeout=30, username="arista", password="arista", hostkey_verify=False)
# Get configuration and state data
eos.get()
# Get configuration and state data using a filter
# Get configuration and state data for interface Ethernet 3
get_int_eth3 = eos.get(filter=("subtree", "<interfaces><interface><name>Ethernet3</name></interface></interfaces>"))
print (get_int_eth3.ok)
print (get_int_eth3)
int_eth3 = '''
<interfaces>
<interface>
<name>Ethernet3</name>
</interface>
</interfaces>
'''
get_int_eth3 = eos.get(filter=("subtree", int_eth3))
print (get_int_eth3)
# Get interface description configured on interface Ethernet 3
int_eth3_description = '''
<interfaces>
<interface>
<name>
Ethernet3
</name>
<config>
<description>
</description>
</config>
</interface>
</interfaces>
'''
get_int_eth3_description = eos.get(filter=("subtree", int_eth3_description))
print (get_int_eth3_description)
# Get interface Ethernet 3 operational status
int_eth3_op_status = '''
<interfaces>
<interface>
<name>
Ethernet3
</name>
<state>
<oper-status>
</oper-status>
</state>
</interface>
</interfaces>
'''
get_int_eth3_op_status = eos.get(filter=("subtree", int_eth3_op_status))
print (get_int_eth3_op_status)
# Other examples
eos.get(filter=("subtree", "<system><aaa><authentication><users><user><username></username></user></users></authentication></aaa></system>"))
eos.get(filter=("subtree", "<system><aaa><authentication><users><user><username>arista</username></user></users></authentication></aaa></system>"))