Question 21
This commit is contained in:
@@ -114,16 +114,34 @@ def question_20():
|
||||
|
||||
|
||||
def question_21():
|
||||
pass
|
||||
inventory = get_inventory()
|
||||
|
||||
for device in inventory:
|
||||
print(f"\n=== Connexion au routeur {device['hostname']} ({device['ip']}) ===")
|
||||
|
||||
try:
|
||||
# Connexion au routeur
|
||||
net_connect = ConnectHandler(
|
||||
device_type=device["device_type"],
|
||||
host=device["ip"],
|
||||
username=device["username"],
|
||||
password=device["password"]
|
||||
)
|
||||
|
||||
# Commande à exécuter
|
||||
command = "show run interface GigabitEthernet0/0.99"
|
||||
output = net_connect.send_command(command)
|
||||
|
||||
print(f"\nConfiguration de GigabitEthernet0/0.99 sur {device['hostname']} :\n")
|
||||
print(output)
|
||||
|
||||
net_connect.disconnect()
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur sur {device['hostname']} : {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
r01 = {
|
||||
'device_type': 'cisco_ios',
|
||||
'host': '172.16.100.126',
|
||||
'username': 'cisco',
|
||||
'password': 'cisco'
|
||||
}
|
||||
net_connect = ConnectHandler(**r01)
|
||||
|
||||
|
||||
#question_9(net_connect)
|
||||
#question_10(net_connect)
|
||||
@@ -136,7 +154,7 @@ if __name__ == "__main__":
|
||||
#question_17(net_connect)
|
||||
#question_18(net_connect)
|
||||
hosts = get_inventory()
|
||||
"print(hosts)
|
||||
question_20()
|
||||
print(hosts)
|
||||
#question_20()
|
||||
#question_21()
|
||||
net_connect.disconnect()
|
||||
Reference in New Issue
Block a user