def discoverOSType(node, potentialpassword="******"): # The CTRL-C, Enter, and logout command in string format cmds = ['\x03', '\n', 'exit'] count = 0 tnode = copy.deepcopy(node) del node node = tnode while count < 10: # Attempt to get the login prompt output. # If Ubuntu is found, return MiniOS object. If ESXi is found, return ESXi object after logging in. output = '' for cmd in cmds: node.SOLActivate() node.SOLSession.sendline(cmd) time.sleep(2) node.SOLDeactivate() output += node.SOLSession.read(20000) if "Ubuntu" in output or "ubuntu" in output: print(node.host + " Found a MiniOS Instance") instance = minios.minios(node) instance.login() return instance elif "ESXi" in output: print(node.host + " Found a ESXi Instance") # The known passwords so far in UCP lineup passwords = [ potentialpassword, lawcompliance.passwordencode(node.host, getPassword('esxi')), 'Passw0rd!', 'Hitachi2019!' ] instance = esxi.ESXi(node, 'root', '') for password in passwords: print(node.host + " Attempting to log into ESXi with \"root\" and \"" + password + "\"") instance.password = password try: instance.login() print(node.host + " Logged into ESXi with \"root\" and \"" + password + "\" successfully") return instance except: print(node.host + " Failed to log into ESXi with \"root\" and \"" + password + "\"") continue del instance else: print(node.host + " No OS detected. Waiting 30 seconds to try again") count += 1 time.sleep(30) continue return None
def main(): preserveconfig = True # Ask the user how many nodes that rack has #nodesnum = helper.askNodeQuantity() nodesnum = 10 if preserveconfig is True: while True: # Ask for the username and password of BMC username = input('What is the username of the BMC? ') if username != 'admin': print( "This toolkit only supports \"admin\" account for restoration. If another account is used, please manually create the account. Exiting." ) return False password = input('What is the password of the BMC? ') print('You have entered ' + str(username) + ' and ' + str(password) + ' ') response = input( 'Is this correct? (Enter y for yes or n for no): ') if 'y' in response: print('Perfect! Let\'s move on.') break else: print('Re-asking questions.') # Get the existing nodes #if preserveconfig is True: # # Discover with existing details # nodes = autodiscover.discover(nodesnum, [username], [password]) #else: # # Discover with default details # nodes = autodiscover.discover(nodesnum) nodes = [quantaskylake.DS120('10.76.38.91', 'admin', 'cmb9.admin')] #nodes = [quantaskylake.DS120('fe80::dac4:97ff:fe17:6e7c%ens160', 'admin', 'cmb9.admin')] #nodes = [quantaskylake.DS120('fe80::dac4:97ff:fe17:6e7c', 'admin', 'cmb9.admin')] #nodes = ['fe80::dac4:97ff:fe17:6e7c%ens160'] #r = firmware('fe80::dac4:97ff:fe17:6e7c%ens160', 'admin', 'cmb9.admin') #r.printfirmwareselection("DS120") # Start the firmware object f = firmware() # Start MiniOS Logic badtime.seperate() print("\nStarting PCI Device Firmware Flashing\n") print('Setting MiniOS BIOS Default') processes = [] for node in nodes: processes.append( multiprocessing.Process(target=node.setMiniOSDefaults2())) # Start threads for process in processes: process.start() time.sleep(1) # Wait for threads for process in processes: process.join() #vmcli_nodes = copy.deepcopy(nodes) #vmcli_nodes = helper.massStartVMCLI(vmcli_nodes, minios.getminiosiso()) print('Powering on the nodes to start MiniOS') processes = [] for node in nodes: processes.append(multiprocessing.Process(target=node.poweron)) # Start threads for process in processes: process.start() # Slowly power-on nodes to not overload circuit time.sleep(2) # Wait for threads for process in processes: process.join() print("\nCreating MiniOS Instances") minioses = [] for node in nodes: minioses.append(minios.minios(node)) print("\nAttempting to login into all MiniOS Instances") for minios_instance in minioses: minios_instance.login() time.sleep(30) print(" Jenny, I am here now") print("\nDiscovering All PCI Devices in all MiniOS Instances") temp_minioses = [] with concurrent.futures.ThreadPoolExecutor(max_workers=32) as executor: futures = [ executor.submit(miniospcidiscoverwrapper, minios_instance) for minios_instance in minioses ] for future in concurrent.futures.as_completed(futures): temp_minioses.append(future.result()) minioses = temp_minioses for minios_instance in minioses: minios_instance.printPCIDevices() # Ask the user which vSphere version so we can flash the DS120/220 with appropriate firmware. while True: print( '\nWhich appliance are you going to install? (Note: Entering UCP is the default option)\n' ) f.printesxiselection() date = input('Enter the date and/or version (if any): ') if len(f.returnesxiselection(date)) < 1: print('I couldn\'t find this selection. Please try again.') else: print('\nThis selection has the following firmwares:') f.printesxiselection(date) firmwareselection = f.returnesxiselection(date) break print("\nFlashing All PCI Devices in all MiniOS Instances") temp_minioses = [] with concurrent.futures.ThreadPoolExecutor(max_workers=32) as executor: futures = [ executor.submit(pciflashing, minios_instance, f, firmwareselection) for minios_instance in minioses ] for future in concurrent.futures.as_completed(futures): try: temp_minioses.append(future.result()) except: continue minioses = temp_minioses input("Hit enter to continue") # Power off the nodes for node in nodes: node.poweroff()
import quantaskylake import minios from prettytable import PrettyTable import os node = quantaskylake.D52B('10.76.38.52', 'admin', 'cmb9.admin') test = minios.minios(node) #tset = minios(node) # if this is used, there is an error that module is not callable test.login() test.discoverPCIDevices() founddevices = test.printPCIDevices() ''' #print("=================Starting to Upgrade==========================") #pcitest = minios.intelNIC(test, '3d:00') #pcitest.flash("/cdrom/firmware/Intel(R)_Ethrnet_Connection_X722_for_10GbE_SFP+/ON 10GbE X722-X527-DA4 SFP plus_FW-Online-Auto_Linux_0004.zip") #pcitest.flash("/cdrom/firmware/Intel(R)_Ethernet_Connection_X722_for_10GbE_SFP+/2018_WW46_LBG_X722_NUP_UEFI_v0006.zip") #melltext = minios.mellanoxNIC(test, '3d:00') # melltext.flash('/cdrom/firmware/Quanta_S5B_CX4Lx_25G_2P/3GS5BMA0000_MLX_25G_dual_port_14_20_1010_Online.zip') #melltext.flash('/cdrom/firmware/Intel(R)_Ethernet_Connection_X722_for_10GbE_SFP+/2018_WW46_LBG_X722_NUP_UEFI_v0006.zip') founddevices = test.printPCIDevices2() print(node.host + " Discovered the following PCI Devices:") t = PrettyTable(["PCI_Address", "Name", "Firmware", "Serial", "VID", "DVID", "SVID", "SSID"]) t.sortby = "PCI_Address" for device2, pciclass2 in founddevices.items(): print(node.host + ' In Loop --- Discovered PCI Device: ' + device2 + ' ' + pciclass2.name + ' v.' + pciclass2.firmware) # This path is relative to the MiniOS for ch in ['(', ')']: if ch in pciclass2.name: