From ff8efd4d142ac2f7ef4b40687b64b082b48bad3a Mon Sep 17 00:00:00 2001 From: "rick.mollard" <rick.mollard@nebraska.edu> Date: Wed, 29 Jun 2022 15:44:03 -0500 Subject: [PATCH] update --- findfails.py | 61 ++++++++++++++++++++++-------------------- unkSwitches-cx.txt | 66 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 29 deletions(-) diff --git a/findfails.py b/findfails.py index 508431c..c5da452 100644 --- a/findfails.py +++ b/findfails.py @@ -1,4 +1,4 @@ -from netmiko import ConnectHandler +from netmiko import (ConnectHandler,NetmikoTimeoutException) from getpass import getpass import requests import urllib3 @@ -45,35 +45,40 @@ creds = {"username": {Ausername}, "password": {Apassword}} for selectIP in file: ip_add = selectIP print(ip_add) - session = requests.session() - - net_connect = ConnectHandler( - device_type="aruba_procurve", - host=ip_add, - username=Ausername, - password=Apassword, - ) + try: + net_connect = ConnectHandler( + device_type="aruba_procurve", + host=ip_add, + username=Ausername, + password=Apassword, + ) - ############################################################################### - output = net_connect.send_command(f"show port-access clients") - to1 = output.split("\n") - print(f"Ports that have role: {policyrole}:") - for to in to1 : - to = to.lstrip() - #print(to) - if policyrole in to: - print(to) - to3 = to.split(" ")[0] - output2 = net_connect.send_command(f"port-access reauthenticate interface {to3}") - print(f"{to3} Reauthentication initiated.") + ############################################################################### + output = net_connect.send_command(f"show port-access clients") + to1 = output.split("\n") + print(f"Ports that have role: {policyrole}:") - #output1 = [f"interface {to3}","shut","no power"] - #net_connect.send_config_set(output1) - #time.sleep(1) - #output2 = [f"interface {to3}","no shut","power"] - #net_connect.send_config_set(output2) + for to in to1 : + to = to.lstrip() + #print(to) + if policyrole in to: + print(to) + port = to.split(" ")[0] + output2 = net_connect.send_command(f"port-access reauthenticate interface {port}") + print(f"{port} Reauthentication initiated.") - to = to.split(" ")[0] + #output1 = [f"interface {to3}","shut","no power"] + #net_connect.send_config_set(output1) + #time.sleep(1) + #output2 = [f"interface {to3}","no shut","power"] + #net_connect.send_config_set(output2) - net_connect.disconnect() \ No newline at end of file + to = to.split(" ")[0] + + net_connect.disconnect() + except (NetmikoTimeoutException) as error: + print("Switch is not responding-----> " + ip_add) + print("Switch is not responding-----> " + ip_add) + print("Switch is not responding-----> " + ip_add) + \ No newline at end of file diff --git a/unkSwitches-cx.txt b/unkSwitches-cx.txt index 4294976..a4f7d5c 100644 --- a/unkSwitches-cx.txt +++ b/unkSwitches-cx.txt @@ -1 +1,65 @@ -10.171.0.41 \ No newline at end of file +10.171.0.10 +10.171.0.12 +10.171.0.15 +10.171.0.16 +10.171.0.19 +10.171.0.20 +10.171.0.21 +10.171.0.23 +10.171.0.24 +10.171.0.26 +10.171.0.27 +10.171.0.28 +10.171.0.29 +10.171.0.30 +10.171.0.31 +10.171.0.32 +10.171.0.33 +10.171.0.34 +10.171.0.35 +10.171.0.37 +10.171.0.38 +10.171.0.39 +10.171.0.40 +10.171.0.41 +10.171.0.42 +10.171.0.43 +10.171.0.44 +10.171.0.45 +10.171.0.47 +10.171.0.48 +10.171.0.49 +10.171.0.50 +10.171.0.51 +10.171.0.52 +10.171.0.53 +10.171.0.54 +10.171.0.55 +10.171.0.56 +10.171.0.57 +10.171.0.58 +10.171.0.59 +10.171.0.60 +10.171.0.61 +10.171.0.62 +10.171.0.63 +10.171.0.64 +10.171.0.65 +10.171.0.66 +10.171.0.67 +10.171.0.68 +10.171.0.69 +10.171.0.70 +10.171.0.71 +10.171.0.72 +10.171.0.73 +10.171.0.74 +10.171.0.11 +10.171.0.13 +10.171.0.14 +10.171.0.17 +10.171.0.18 +10.171.0.25 +10.171.0.36 +10.171.0.46 +10.171.0.75 \ No newline at end of file -- GitLab