From e112d105d22bed31cac4dffd54a9d413d5f9dd83 Mon Sep 17 00:00:00 2001 From: "rick.mollard" <rick.mollard@nebraska.edu> Date: Fri, 1 Jul 2022 10:42:59 -0500 Subject: [PATCH] updates --- arubaModels.py | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 arubaModels.py diff --git a/arubaModels.py b/arubaModels.py new file mode 100644 index 0000000..0970a2f --- /dev/null +++ b/arubaModels.py @@ -0,0 +1,74 @@ +from netmiko import (ConnectHandler,NetmikoTimeoutException) +from getpass import getpass +import requests +import urllib3 +import re +import time +import getpass + +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + +# +# This script will look to see which ports are in a "failed" state and try to reathenticate the port. +# +# + +########################################################################### +print(" 1 = UNL-City \n 2 = UNL-East \n 3 = UNO \n 4 = UNK \n Select Campus:") +campus = input() +print(f"Campus Selected: {campus}") +print("----------------------------------") +if campus == "1": + file = [line.strip() for line in open("unlCitySwitches-cx.txt", 'r')] +if campus == "2": + file = [line.strip() for line in open("unlEastSwitches-cx.txt", 'r')] +if campus == "3": + file = [line.strip() for line in open("unoSwitches-cx.txt", 'r')] +if campus == "4": + file = [line.strip() for line in open("unkSwitches-cx.txt", 'r')] + #print(file[]) + #file.close() + + + Switches48port = ["JL661A","JL659A"] +########################################################################## +print("Enter Username:") +Ausername = input() +print("Enter Password:") +Apassword = getpass.getpass() +creds = {"username": {Ausername}, "password": {Apassword}} + + +for selectIP in file: + ip_add = selectIP + print(ip_add) + try: + net_connect = ConnectHandler( + device_type="aruba_procurve", + host=ip_add, + username=Ausername, + password=Apassword, + ) + + + ############################################################################### + output = net_connect.send_command(f"show vsf") + to1 = output.split("\n") + + for to in to1 : + to = to.lstrip() + + if "JL661A" in to: # Checks for 48 port switch + print(to) + #checks for + elif "JL659A" in to: # Checks for CL6 48 port Switch + print(to) + + 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 -- GitLab