-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevice.py
More file actions
67 lines (53 loc) · 2.47 KB
/
device.py
File metadata and controls
67 lines (53 loc) · 2.47 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from driver.driver import get_driver
class Device(object):
def __init__(self, switch):
self.switch = switch
self.driver = get_driver(switch)
def run(self):
self.driver.connect()
self.check_tedb_network_lsa()
# self.check_mpls_tunnel_num()
# self.check_down_interfaces()
# self.shutdown_interfaces()
self.driver.disconnect()
def check_tedb_network_lsa(self):
if '93' in self.switch.name or '57' in self.switch.name or '6820' in self.switch.name:
pass
else:
result = self.driver.get_tedb_network_lsa()
if result:
if len(result) == 1:
print '\n{} ----- {}: \n{}'.format(self.switch.name, self.switch.m_ip, result[0])
elif len(result) == 3:
print '\n{} ----- {}: \n{}\n{}\n{}'.format(self.switch.name, self.switch.m_ip, result[0],
result[1], result[2])
else:
print '\n{} ----- {}: \n{}\n{}'.format(self.switch.name, self.switch.m_ip, result[0], result[1])
else:
print '\n{} ----- {}: \n{}'.format(self.switch.name, self.switch.m_ip, 'None')
def check_mpls_tunnel_num(self):
result = self.driver.get_mpls_te_tunnel_num()
if result:
print '\n{} ----- {}: \n{}'.format(self.switch.name, self.switch.m_ip, result)
def check_down_interfaces(self):
each_res, both_res, _ = self.driver.get_interface_status()
# print '\n{} ----- {}: \n each_down_interfaces: {}'.format(self.switch.name, self.switch.m_ip, each_res)
print '\n{} ----- {}: \n both_down_interfaces: {}'.format(self.switch.name, self.switch.m_ip, both_res)
def shutdown_interfaces(self):
shutdown_intfs = []
_, both_res, _ = self.driver.get_interface_status()
self.driver.return_root()
for intf in both_res:
self.driver.shutdown_interface(intf)
shutdown_intfs.append(intf)
self.driver.commit()
self.driver.quit()
self.driver.save()
# _, _, result = self.driver.get_interface_status(no_processing=True)
print '\n{} ----- {}: \n shutdown interfaces: {}'.format(self.switch.name, self.switch.m_ip, shutdown_intfs)
def check_ssh(self):
pass
def check_interface_ip(self):
ip = '3.3.3.3'
result = self.driver.check_interfae_ip(ip)
print result