-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.py
589 lines (509 loc) · 25.3 KB
/
command.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
"""this one is where the command is parsed and further routines are called"""
import common
import myprint
import cisco
import dellquanta
import re
import definitions
#from islands import *
"""check number of devices passed as argument. if number is different from what it shoud be, return error"""
def check_device_list(device_list, number):
if len(device_list) != number:
myprint.error("Wrong number of devices, should be " + str(number))
else:
return True
"""get vendor name, with long output (show version)"""
def get_device_vendors(device_list, option):
if option == "short":
vendors = common.get_device_vendors(device_list)
myprint.vendors(vendors, "short")
else:
vendors = common.get_device_vendors(device_list)
myprint.vendors(vendors, "all")
"""***********************************************************************************************************"""
""" VLAN ROUTINES """
"""***********************************************************************************************************"""
"""all the vlan options parsed here"""
def get_vlans_info(device_list, task, parameter1, parameter2):
#all this option accept only one device
#check_device_list(device_list, 1)
#device = device_list[0]
for i in range (0,len(device_list)):
device = device_list[i]
vendor_name = common.get_device_vendor(device)
if vendor_name == "Cisco":
vendor = cisco
elif vendor_name == "Dell":
vendor = dellquanta
elif vendor_name == "Quanta":
vendor = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
if task == "all":
vlan_list = get_vlans_on_device(device, vendor)
myprint.vlan_list_joined(vlan_list, str("\nConfigured vlans on: " + device + "\n"))
elif task == "allinfo":
(interfaces_dict, vlan_list, native_tagged) = get_all_vlans_on_all_ports(device, vendor_name)
myprint.all_ports_all_vlan(device, interfaces_dict, vlan_list, native_tagged)
elif task == "allinfo-dict": #za apis klic, ki vrne dict
(interfaces_dict, native_tagged) = get_all_vlans_on_all_ports(device, vendor_name)
return interfaces_dict, native_tagged
elif task == "check":
(interfaces_dict, vlan_list) = check_vlans(device, vendor_name)
myprint.check_vlans(device, interfaces_dict, vlan_list)
elif task == "vlan_island":
(vlan_list, vlan_island_list) = check_island_vlans(device, vendor_name, parameter1+"_vlan")
myprint.check_island_vlans(device, vlan_list, vlan_island_list, parameter1)
elif task == "ports_with_this_vlan":
vlan_id = parameter1
interfaces_dict = get_ports_with_this_vlan(device, vendor, vlan_id)
myprint.ports_with_vlan(device, vlan_id, interfaces_dict)
elif task == "vlans_on_this_port":
port = parameter1
vlan_list_on_port = get_vlans_on_this_port(device, vendor, port)
myprint.vlan_list_joined(vlan_list_on_port, str("\nFollowing vlans are configured on " + device + " port " + str(port) + "\n"))
elif task == "is_vlan_on_this_port":
port = parameter1
vlan_id = parameter2
status = is_vlan_on_this_port(device, vendor, port, vlan_id)
myprint.myprint("\nOn " + str(device) + " port " + str(port) + " vlan " + str(vlan_id) + (" CONFIGURED\n" if status else " NOT CONFIGURED\n"))
else:
myprint.error("Wrong parameter options")
exit(0)
"""what are vlans on specific device"""
def get_vlans_on_device(device, vendor):
vlan_list = vendor.configured_vlans_on_device(device)
return vlan_list
"""search all the ports on device and find out where this vlan in configured in either access or trunk port"""
#def get_ports_with_this_vlan(device_list,vlanid):
def get_ports_with_this_vlan(device, vendor, vlan_id):
#here we allow only one device as search object
#vlan should be in range
if (vlan_id<1 or vlan_id>4094):
myprint.error("Wrong vlan id, should be between 1-4094, exiting")
exit(0)
#torej npr. sljptl1 vlan 14, zelim izpis na katerih portih je vse ta vlan (access in trunk)
vlan_list = vendor.configured_vlans_on_device(device)
if vlan_id not in vlan_list:
myprint.warning("\nWARNING: Vlan "+ str(vlan_id) + " not configured on " + device + "\n")
interfaces_dict = common.get_interfaces_id(device)
interfaces_dict = common.get_interfaces_status(device,interfaces_dict)
interfaces_dict = vendor.get_interfaces_lacp(device, interfaces_dict)
interfaces_dict = vendor.get_interfaces_trunk(device, interfaces_dict, vendor)
interfaces_dict = common.get_interfaces_desc(device, interfaces_dict)
interfaces_dict = vendor.vlan_on_all_ports(device,interfaces_dict, vlan_id)
return interfaces_dict
def is_vlan_on_this_port(device, vendor, port, vlan):
vlan_list = vendor.configured_vlans_on_device(device)
if vlan not in vlan_list:
myprint.warning("\nWARNING: Vlan "+ str(vlan) + " not configured on " + device + "\n")
interfaces_dict = common.get_interfaces_id(device)
common.check_if_interface_exists(interfaces_dict,port)
interfaces_dict = common.get_interfaces_status(device,interfaces_dict)
interfaces_dict = vendor.get_interfaces_lacp(device, interfaces_dict)
interfaces_dict = vendor.get_interfaces_trunk(device, interfaces_dict, vendor)
port_id = common.find_port_id(interfaces_dict,port)
if interfaces_dict[port_id][1] == "Down":
myprint.warning("\nPort is down, vlan information maybe not reliable.")
status = vendor.is_vlan_on_port(device, port_id, vlan)
return status
def get_vlans_on_this_port(device, vendor, port):
#here we need to now port type, in case of port channel return nothing...
interfaces_dict = common.get_interfaces_id(device)
common.check_if_interface_exists(interfaces_dict,port)
interfaces_dict = common.get_interfaces_status(device,interfaces_dict)
interfaces_dict = vendor.get_interfaces_lacp(device, interfaces_dict)
interfaces_dict = vendor.get_interfaces_trunk(device, interfaces_dict, vendor)
port_id = common.find_port_id(interfaces_dict,port)
if interfaces_dict[port_id][1] == "Down":
myprint.warning("\nPort is down, vlan information maybe not reliable.")
vlan_list = vendor.configured_vlans_on_device(device)
vlan_list_on_port = vendor.vlans_on_port(device, port_id, vlan_list)
return vlan_list_on_port
def get_all_vlans_on_all_ports(device, vendor):
if vendor == "Cisco":
specific = cisco
else:
specific = dellquanta
vlan_list = specific.configured_vlans_on_device(device)
interfaces_dict = common.get_interfaces_id(device)
interfaces_dict = common.get_interfaces_desc(device,interfaces_dict)
interfaces_dict = common.get_interfaces_status(device,interfaces_dict)
interfaces_dict = specific.get_interfaces_lacp(device, interfaces_dict)
interfaces_dict = specific.get_interfaces_trunk(device, interfaces_dict, vendor)
interfaces_dict = specific.get_interfaces_native_vlan(device, interfaces_dict, vendor)
for key, value in interfaces_dict.items():
if str(key) == "int_id":
interfaces_dict['int_id'].append('Member')
else:
vlan_list_on_port = []
vlan_list_on_port = specific.vlans_on_port(device, key, vlan_list)
interfaces_dict[key].append(vlan_list_on_port)
interfaces_dict = common.get_interfaces_desc(device, interfaces_dict)
native_tagged = specific.get_native_tagged(device)
return interfaces_dict, vlan_list, native_tagged
def check_vlans(device, vendor):
if vendor != "Cisco":
myprint.error("\nThis only works for cisco\n")
vendor = cisco
vlan_list = vendor.configured_vlans_on_device(device)
interfaces_dict = common.get_interfaces_id(device)
interfaces_dict = common.get_interfaces_status(device,interfaces_dict)
interfaces_dict = vendor.get_interfaces_trunk(device, interfaces_dict, vendor)
for key, value in interfaces_dict.items():
if str(key) == "int_id":
interfaces_dict['int_id'].append('Member')
else:
vlan_list_on_port = []
vlan_list_on_port = vendor.vlans_on_port(device, key, vlan_list)
interfaces_dict[key].append(vlan_list_on_port)
#print interfaces_dict
return interfaces_dict, vlan_list
def check_island_vlans(device, vendor, island_name):
from islands import *
if vendor == "Cisco":
specific = cisco
else:
specific = dellquanta
#if island_name in globals():
if island_name in locals():
island_vlans = eval(island_name)
island_vlans = island_vlans.split(',')
#print island_vlans
else:
myprint.error("Vlans for this island not specified correctly")
vlan_list = specific.configured_vlans_on_device(device)
#print vlan_list
return vlan_list, island_vlans
"""***********************************************************************************************************"""
""" PORT ROUTINES """
"""***********************************************************************************************************"""
def get_ports_on_devices(device_list):
check_device_list(device_list, 1)
name = device_list[0]
vendor_name = common.get_device_vendor(name)
interfaces_dict = common.get_interfaces_id(name)
interfaces_dict = common.get_interfaces_desc(name,interfaces_dict)
#myprint.dict_sorted_with_message(interfaces_dict, str("Ports on " + name))
myprint.dict_sorted_interface(interfaces_dict, name)
def get_ports_info_on_device(device_list):
check_device_list(device_list, 1)
name = device_list[0]
vendor_name = common.get_device_vendor(name)
if vendor_name == "Cisco":
specific = cisco
else:
specific = dellquanta
interfaces_dict = common.get_interfaces_id(name)
interfaces_dict = common.get_interfaces_admin_status(name,interfaces_dict)
interfaces_dict = common.get_interfaces_status(name,interfaces_dict)
interfaces_dict = common.get_interfaces_speed(name, interfaces_dict)
interfaces_dict = specific.get_interfaces_lacp(name, interfaces_dict)
interfaces_dict = specific.get_interfaces_trunk(name, interfaces_dict, vendor_name) #first is link up/down info, second is lacp info
interfaces_dict = common.get_interfaces_desc(name,interfaces_dict)
myprint.dict_sorted_interface(interfaces_dict, name)
def get_single_port_info(device_list, port):
check_device_list(device_list, 1)
name = device_list[0]
vendor_name = common.get_device_vendor(name)
if vendor_name == "Cisco":
specific = cisco
else:
specific = dellquanta
interfaces_dict = common.get_interfaces_id(name)
common.check_if_interface_exists(interfaces_dict,port)
interfaces_dict = common.get_interfaces_admin_status(name,interfaces_dict)
interfaces_dict = common.get_interfaces_status(name,interfaces_dict)
interfaces_dict = common.get_interfaces_speed(name, interfaces_dict)
interfaces_dict = cisco.get_interfaces_lacp(name, interfaces_dict)
interfaces_dict = cisco.get_interfaces_trunk(name, interfaces_dict, vendor_name) #first is link up/down info, second is lacp info
interfaces_dict = common.get_interfaces_desc(name,interfaces_dict)
myprint.dict_interface(interfaces_dict, name, port)
"""***********************************************************************************************************"""
""" CHECK ROUTINES """
"""***********************************************************************************************************"""
def get_link_info(device_list, task, vlan_id):
#all this option accept two devices
check_device_list(device_list, 2)
device1 = device_list[0]
device2 = device_list[1]
vendor_name1 = common.get_device_vendor(device1)
vendor_name2 = common.get_device_vendor(device2)
if vendor_name1 == "Cisco":
vendor1 = cisco
elif vendor_name1 == "Dell":
vendor1 = dellquanta
elif vendor_name1 == "Quanta":
vendor1 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
if vendor_name2 == "Cisco":
vendor2 = cisco
elif vendor_name2 == "Dell":
vendor2 = dellquanta
elif vendor_name2 == "Quanta":
vendor2 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
if task == None:
(port1, port2) = get_common_link(device1, device2)
if port1 != None and port2 != None:
myprint.myprint("\nBased on descripton this is common link: %s %s %s %s \n" % (device1, port1, device2, port2))
else:
myprint.error("\nNo common link between %s and %s \n" % (device1, device2))
elif task == "vlan" and vlan_id == "all":
(port1, port2) = get_common_link(device1, device2)
if port1 != None and port2 != None:
myprint.myprint("\nBased on descripton this is common link: %s %s %s %s \n" % (device1, port1, device2, port2))
else:
myprint.error("\nNo common link between %s and %s \n" % (device1, device2))
(list1, list2) = check_common_link_vlans(device1, vendor1, port1, device2, vendor2, port2)
print device1, port1, "vlans: ", (', '.join(str(x) for x in list1))
print device2, port2, "vlans: ", (', '.join(str(x) for x in list2))
#on dell and quanta we can not remove vlan 1, so let's ignore it in compare
if list1 == list2:
print "\nConfigured vlans are the same"
elif list1[0] == 1:
if list1[1:] == list2:
print "\nConfigured vlans are the same, ignoring vlan 1 on " + device1 + "\n"
elif list2[0] == 1:
if list1 == list2[1:]:
print "\nConfigured vlans are the same, ignoring vlan 1 on " + device2 + "\n"
else:
print "\nConfigured vlans are NOT the same\n"
elif task == "island":
island_id = vlan_id
(island_dev, island_v) = get_island_info(island_id, "values")
island_dev_list = island_dev.split(",")
island_vlan_list = island_v.split(",")
#print island_dev
if device1 not in island_dev_list:
myprint.error("\nDevice %s not part of island %s \n" % (device1, island_id))
if device2 not in island_dev_list:
myprint.error("\nDevice %s not part of island %s \n" % (device2, island_id))
(port1, port2) = get_common_link(device1, device2)
if port1 != None and port2 != None:
myprint.myprint("Based on descripton this is common link: %s %s %s %s \n" % (device1, port1, device2, port2))
else:
myprint.error("\nNo common link between %s and %s \n" % (device1, device2))
(list1, list2) = check_common_link_vlans(device1, vendor1, port1, device2, vendor2, port2)
print "Vlans in island", island_id, island_v
print device1, port1, "vlans: ", (', '.join(str(x) for x in list1))
print device2, port2, "vlans: ", (', '.join(str(x) for x in list2))
#print island_vlan_list
#print list1
print
for i in island_vlan_list:
if int(i) not in list1:
print "Vlan", i, "missing on", device1, port1
for i in island_vlan_list:
if int(i) not in list2:
print "Vlan", i, "missing on", device2, port2
for i in list1:
if str(i) not in island_vlan_list:
print "... but vlan", i, "configured on", device1, port1, "and not part of island", island_id
for i in list2:
if int(i) not in list2:
print "... but vlan", i, "configured on", device2, port2, "and not part of island", island_id
print
elif task == "vlan":
(port1, port2) = get_common_link(device1, device2)
if port1 != None and port2 != None:
myprint.myprint("\nBased on descripton this is common link: %s %s %s %s \n" % (device1, port1, device2, port2))
else:
myprint.error("\nNo common link between %s and %s \n" % (device1, device2))
(list1, list2) = check_common_link_vlans(device1, vendor1, port1, device2, vendor2, port2)
myprint.myprint("On " + str(device1) + " port " + str(port1) + " vlan " + str(vlan_id) + (" CONFIGURED" if vlan_id in list1 else " NOT CONFIGURED"))
myprint.myprint("On " + str(device2) + " port " + str(port2) + " vlan " + str(vlan_id) + (" CONFIGURED\n" if vlan_id in list2 else " NOT CONFIGURED\n"))
else:
myprint.error("Wrong parameter options")
def get_common_link(device1, device2):
port1 = None
port2 = None
interfaces_dict1 = common.get_interfaces_id(device1)
interfaces_dict1 = common.get_interfaces_status(device1,interfaces_dict1)
interfaces_dict1 = common.get_interfaces_desc(device1, interfaces_dict1)
interfaces_dict2 = common.get_interfaces_id(device2)
interfaces_dict2 = common.get_interfaces_status(device2,interfaces_dict2)
interfaces_dict2 = common.get_interfaces_desc(device2, interfaces_dict2)
for key, value in interfaces_dict1.items():
string = '\\b%s\\b' % device2
if len(re.findall(string, value[2])) > 0:
port1 = value[0]
for key, value in interfaces_dict2.items():
string = '\\b%s\\b' % device1
if len(re.findall(string, value[2])) > 0:
port2 = value[0]
return port1, port2
def check_common_link_vlans(device1, vendor1, port1, device2, vendor2, port2):
list1 = get_vlans_on_this_port(device1, vendor1, port1)
list2 = get_vlans_on_this_port(device2, vendor2, port2)
return list1, list2
def get_multiple_link_info(device_list, vlan_id):
items_number = len(device_list)
if (items_number % 2) != 0:
myprint.error("Number of devices must be odd")
for i in range(0, items_number, 2):
device1 = device_list[i]
device2 = device_list[i+1]
vendor_name1 = common.get_device_vendor(device1)
vendor_name2 = common.get_device_vendor(device2)
if vendor_name1 == "Cisco":
vendor1 = cisco
elif vendor_name1 == "Dell":
vendor1 = dellquanta
elif vendor_name1 == "Quanta":
vendor1 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
if vendor_name2 == "Cisco":
vendor2 = cisco
elif vendor_name2 == "Dell":
vendor2 = dellquanta
elif vendor_name2 == "Quanta":
vendor2 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
(port1, port2) = get_common_link(device1, device2)
if port1 != None and port2 != None:
myprint.myprint("\nBased on descripton this is common link: %s %s %s %s \n" % (device1, port1, device2, port2))
else:
myprint.error("\nNo common link between %s and %s \n" % (device1, device2))
(list1, list2) = check_common_link_vlans(device1, vendor1, port1, device2, vendor2, port2)
myprint.myprint("On " + str(device1) + " port " + str(port1) + " vlan " + str(vlan_id) + (" CONFIGURED" if vlan_id in list1 else " NOT CONFIGURED"))
myprint.myprint("On " + str(device2) + " port " + str(port2) + " vlan " + str(vlan_id) + (" CONFIGURED\n" if vlan_id in list2 else " NOT CONFIGURED\n"))
def get_ring_check(device_list, vlan_id):
items_number = len(device_list)
if (items_number < 3):
myprint.error("Minimum devices is 3...")
for i in range(0, items_number-1):
device1 = device_list[i]
device2 = device_list[i+1]
vendor_name1 = common.get_device_vendor(device1)
vendor_name2 = common.get_device_vendor(device2)
if vendor_name1 == "Cisco":
vendor1 = cisco
elif vendor_name1 == "Dell":
vendor1 = dellquanta
elif vendor_name1 == "Quanta":
vendor1 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
if vendor_name2 == "Cisco":
vendor2 = cisco
elif vendor_name2 == "Dell":
vendor2 = dellquanta
elif vendor_name2 == "Quanta":
vendor2 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
(port1, port2) = get_common_link(device1, device2)
if port1 != None and port2 != None:
myprint.myprint("\nBased on descripton this is common link: %s %s %s %s \n" % (device1, port1, device2, port2))
else:
myprint.error("\nError! No common link between %s and %s \nAre doing it wireless? :)\n" % (device1, device2))
exit(0)
def get_ring_vlan_check(device_list, vlan_id):
ring_status = 1
items_number = len(device_list)
if (items_number < 3):
myprint.error("Minimum devices is 3...")
for i in range(0, items_number-1):
segment_status = 1
device1 = device_list[i]
device2 = device_list[i+1]
vendor_name1 = common.get_device_vendor(device1)
vendor_name2 = common.get_device_vendor(device2)
if vendor_name1 == "Cisco":
vendor1 = cisco
elif vendor_name1 == "Dell":
vendor1 = dellquanta
elif vendor_name1 == "Quanta":
vendor1 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
if vendor_name2 == "Cisco":
vendor2 = cisco
elif vendor_name2 == "Dell":
vendor2 = dellquanta
elif vendor_name2 == "Quanta":
vendor2 = dellquanta
else:
myprint.error("Only Cisco, Dell and Quanta deviced supported")
myprint.myprint("\n------------------------------------------------")
myprint.myprint("Checking segment between %s and %s" % (device1, device2))
vlan_list = vendor1.configured_vlans_on_device(device1)
if vlan_id in vlan_list:
myprint.myprint("Vlan "+ str(vlan_id) + " configured on " + device1)
else:
myprint.warning("!!! WARNING: Vlan "+ str(vlan_id) + " NOT configured on " + device1 + "!!!")
segment_status = 0
ring_status = 0
vlan_list = vendor2.configured_vlans_on_device(device2)
if vlan_id in vlan_list:
myprint.myprint("Vlan "+ str(vlan_id) + " configured on " + device2)
else:
myprint.warning("!!! WARNING: Vlan "+ str(vlan_id) + " NOT configured on " + device2 + "!!!")
segment_status = 0
ring_status = 0
(port1, port2) = get_common_link(device1, device2)
if port1 != None and port2 != None:
myprint.myprint("Based on descripton this is common link: %s %s %s %s" % (device1, port1, device2, port2))
else:
myprint.error("\nError! No common link between %s and %s \n" % (device1, device2))
(list1, list2) = check_common_link_vlans(device1, vendor1, port1, device2, vendor2, port2)
if vlan_id in list1:
myprint.myprint("On " + str(device1) + " port " + str(port1) + " vlan " + str(vlan_id) + " CONFIGURED")
else:
myprint.myprint("On " + str(device1) + " port " + str(port1) + " vlan " + str(vlan_id) + " NOT CONFIGURED")
segment_status = 0
ring_status = 0
if vlan_id in list2:
myprint.myprint("On " + str(device2) + " port " + str(port2) + " vlan " + str(vlan_id) + " CONFIGURED")
else:
myprint.myprint("On " + str(device2) + " port " + str(port2) + " vlan " + str(vlan_id) + " NOT CONFIGURED")
segment_status = 0
ring_status = 0
if segment_status == 1:
myprint.myprint("Segment OK")
else:
myprint.myprint("Segment NOK")
if ring_status == 1:
myprint.myprint("\nTotal path OK\n")
else:
myprint.myprint("\nTotal path NOK\n")
exit(0)
def get_island_info(island_name, parameter1):
from islands import *
print
#if island_name in globals():
if island_name in locals():
island_devices = eval(island_name)
if parameter1 != "values":
myprint.myprint("Devices in island " + island_name + ": " + island_devices)
else:
myprint.error("Wrong island name")
island_vlan_name = island_name + "_vlan"
#if island_vlan_name in globals():
if island_vlan_name in locals():
island_vlans = eval(island_vlan_name)
if parameter1 != "values":
myprint.myprint("Vlans in island " + island_name + ": " + island_vlans)
else:
myprint.error("Missing island vlans")
if parameter1 == "values":
#return island_devices.split(","), island_vlans.split(",")
return island_devices, island_vlans
else:
print
exit(0)
def get_island_search(device_list):
print
from islands import *
for key,value in locals().items():
if str(key) == "device_list":
pass
elif device_list[0] in value:
print device_list[0], "is member of island", key
print
exit(0)