-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample1.py
38 lines (28 loc) · 970 Bytes
/
example1.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
from cisco_sdwan_policy.Helper.PolicyLoader import PolicyLoader
if __name__ == '__main__':
# Example 1: Save policy to local disk & restore it.
# Input server Info here
server_info = {
"hostname": "192.168.100.32",
"port": 443,
"username": "admin",
"password": "admin",
}
# Load all policy in vManage
pl = PolicyLoader.init(server_info)
pl.load()
# Show all the loaded Policy.(Optional)
print([i.name for i in pl.main_policies])
print([i.name for i in pl.topo_policies])
print([i.name for i in pl.traffic_policies])
print([i.name for i in pl.list_policies])
# Generate backup json
backup = pl.save_to_json()
# Save to file
with open("policy_dump.json","w+") as file:
file.write(backup)
# Read from file
with open("policy_dump.json","r") as file:
info = file.read()
# Load to vMange and auto merge if needed.
pl.load_from_json(info)