-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset.py
More file actions
44 lines (30 loc) · 1.26 KB
/
set.py
File metadata and controls
44 lines (30 loc) · 1.26 KB
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
from pygnmi.client import gNMIclient
import json
if __name__ == '__main__':
## update
cisco_update = [
("openconfig-interfaces:interfaces/interface[name=Loopback3]",
{
"config":
{
"name":"Loopback3",
#"enabled": False,
"type": "iana-if-type:softwareLoopback", ## mandatory field as per YANG module
#"description":"testing pygnmi to create an interface"
}
}
)
]
with gNMIclient(target=("10.251.254.106",57400),username="cisco",password="cisco123",insecure=True) as gc:
update_result = gc.set(update=cisco_update,encoding='json_ietf')
print(json.dumps(update_result, indent=4))
## get
path = ['openconfig-interfaces:interfaces/interface[name=Loopback3]']
with gNMIclient(target=("10.251.254.106",57400),username="cisco",password="cisco123",insecure=True) as gc:
get_result = gc.get(path=path,encoding='json_ietf',datatype='all',)
print(json.dumps(get_result, indent=4))
## delete
# cisco_delete = ['openconfig-interfaces:interfaces/interface[name=Loopback3]']
# with gNMIclient(target=("10.251.254.106",57400),username="cisco",password="cisco123",insecure=True) as gc:
# delete_result = gc.set(delete=cisco_delete,encoding='json_ietf')
# print(json.dumps(delete_result, indent=4))