Semana 12- 07/02/2021

This commit is contained in:
Antonio Torres Míguez
2021-02-07 23:31:05 +01:00
parent 0ba559cb48
commit c293978390

View File

@ -4,6 +4,7 @@ from random import randint, uniform
from datetime import datetime from datetime import datetime
devices = create_devices(num_subnets=2, num_devices=25) devices = create_devices(num_subnets=2, num_devices=25)
print("\n MUESTRA TODOS LOS DISPOSITIVOS CREADOS: ")
print("\n NAME VENDOR : OS IP ADDRESS VERSION") print("\n NAME VENDOR : OS IP ADDRESS VERSION")
print(" ----- ------- ----- -------------- -----------") print(" ----- ------- ----- -------------- -----------")
for device in devices: for device in devices:
@ -11,6 +12,9 @@ for device in devices:
f'{device["name"]:>7} {device["vendor"]:>10} : {device["os"]:<6} {device["ip"]:<15} {device["version"]}' f'{device["name"]:>7} {device["vendor"]:>10} : {device["os"]:<6} {device["ip"]:<15} {device["version"]}'
) )
print("\n MUESTRA LOS DISPOSITIVOS EXCEPTO CISCO: ")
print("\n NAME VENDOR : OS IP ADDRESS VERSION") print("\n NAME VENDOR : OS IP ADDRESS VERSION")
print(" ----- ------- ----- -------------- -----------") print(" ----- ------- ----- -------------- -----------")
for device in devices: for device in devices:
@ -19,6 +23,8 @@ for device in devices:
f'{device["name"]:>7} {device["vendor"]:>10} : {device["os"]:<6} {device["ip"]:<15} {device["version"]}' f'{device["name"]:>7} {device["vendor"]:>10} : {device["os"]:<6} {device["ip"]:<15} {device["version"]}'
) )
print("\n----- Starting comparison of device names --------------------") print("\n----- Starting comparison of device names --------------------")
for index, device_a in enumerate(devices): for index, device_a in enumerate(devices):
for device_b in devices[index+1:]: for device_b in devices[index+1:]:
@ -26,7 +32,10 @@ for index, device_a in enumerate(devices):
print(f"Found match! {device_a['name']} for both {device_a['ip']} and {device_b['ip']}") print(f"Found match! {device_a['name']} for both {device_a['ip']} and {device_b['ip']}")
print("----- Comparison of device names completed") print("----- Comparison of device names completed")
print("\n----- Create table of arbitrary 'standard' versions for each vendor:os - Resumen de versiones --------------------")
print("\n----- Create table of arbitrary 'standard' versions for each vendor:os - Resumen de versiones diferentes --------------------")
standard_versions = dict() standard_versions = dict()
for device in devices: for device in devices:
vendor_os = device["vendor"] + ":" + device["os"] vendor_os = device["vendor"] + ":" + device["os"]
@ -34,7 +43,10 @@ for device in devices:
standard_versions[vendor_os] = device["version"] standard_versions[vendor_os] = device["version"]
pprint(standard_versions) pprint(standard_versions)
print("\n----- Create list of non-compliant device OS versions for each vendor:os --------------------")
print("\n----- Create list of non-compliant device OS versions for each vendor:os - Versiones diferentes a las standar --------------------")
non_compliant_devices = dict() non_compliant_devices = dict()
for vendor_os, _ in standard_versions.items(): for vendor_os, _ in standard_versions.items():
non_compliant_devices[vendor_os] = [] non_compliant_devices[vendor_os] = []
@ -46,6 +58,10 @@ for device in devices:
pprint(non_compliant_devices) pprint(non_compliant_devices)
print("\n\n----- Assignment, copy, and deep copy --------------------") print("\n\n----- Assignment, copy, and deep copy --------------------")
devices2 = devices devices2 = devices
devices[0]["name"] = "this is a dumb device name" devices[0]["name"] = "this is a dumb device name"
@ -77,6 +93,9 @@ else:
print(" ---> Result: I can do whatever I want with my copy, without touching the original!!") print(" ---> Result: I can do whatever I want with my copy, without touching the original!!")
new_set_of_devices = create_devices(num_subnets=2, num_devices=25) new_set_of_devices = create_devices(num_subnets=2, num_devices=25)
if new_set_of_devices == devices: if new_set_of_devices == devices:
print(" Huh?") print(" Huh?")