/
bf-config_v3.py
57 lines (31 loc) · 1.01 KB
/
bf-config_v3.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
#!/usr/bin/env python
import xmltodict
from device import Device
import json
import pprint
#from cli import *
def copy_bootflash(sw):
cp_bootflash = sw.conf('copy bootflash:start-config bootflash:/scripts/start-config_pytest15')
#print ret_dict
# print getData
show_bootflash_dict = xmltodict.parse(getData[1])
#print type(show_bootflash_dict)
data = show_bootflash_dict['ins_api']['outputs']['output']['body']
data_dict = json.dumps(data, indent = 4)
# print data_dict
#print type(data_dict)
#static_config = "start-config'\n'"
data_dict.strip('\n')
data_dict.replace('\n','')
if "start-config" in data_dict:
print "Awesome"
#print len(data)
#pp = pprint.PrettyPrinter(indent = 2, depth = 6)
#pp.pprint(data)
#print json.dumps(data, indent=4)
def main():
switch = Device(ip='172.31.217.134', username='admin', password='cisco123')
switch.open()
show_boot_config = copy_bootflash(switch)
if __name__ == "__main__":
main()