def _wait_for_reload(self, device): """ Wait for system to come up with max timeout as 10 Minutes """ status = device.reconnect() # Connection to device failed if not status : return status # Connection to device is stablished , now look for all nodes to xr run state timeout = 450 poll_time = 30 time_waited = 0 xr_run = "IOS XR RUN" success = False cmd = "admin show platform" print "Waiting all nodes to come up" time.sleep(100) while 1: # Wait till all nodes are in XR run state time_waited += poll_time if time_waited >= timeout: break time.sleep(poll_time) success, output = device.execute_command(cmd) if success and xr_run in output: inventory = pkgutils.parse_xr_show_platform(output) if pkgutils.validate_xr_node_state(inventory, device): return True # Some nodes did not come to run state return False
def _wait_for_reload(self, device): """ Wait for system to come up with max timeout as 25 Minutes """ status = device.reconnect() # Connection to device failed if not status : return status # Connection to device is stablished , now look for all nodes to xr run state timeout = 1500 poll_time = 30 time_waited = 0 xr_run = "IOS XR RUN" success = False cmd = "admin show platform" print "Waiting all nodes to come up" time.sleep(100) while 1: # Wait till all nodes are in XR run state time_waited += poll_time if time_waited >= timeout: break time.sleep(poll_time) success, output = device.execute_command(cmd) if success and xr_run in output: inventory = pkgutils.parse_xr_show_platform(output) if pkgutils.validate_xr_node_state(inventory, device): return True # Some nodes did not come to run state return False
def start(self, device, *args, **kwargs): """ Start the plugin """ no_valid_redundancy = 'Node \w+/\w+/\w+ has no valid partner' valid_redundancy = 'Node Redundancy Partner \(\w+/\w+/\w+\) is in .+ role' failed_oper = r'Install operation (\d+) failed' name = "{}.log".format(self.NAME.lower()) fname = os.path.join(device.output_store_dir, name.replace(":", "_")) try: fd_fname = open(fname, 'w') except: self.error("Failed to open %s file to write " % (fname)) cmd = "admin show platform" success, output = device.execute_command(cmd) if success: inventory = pkgutils.parse_xr_show_platform(output) if not pkgutils.validate_xr_node_state(inventory, device): fd_fname.close() self.error("All nodes are not in right state:\n %s" % (output)) # Save what was verified fd_fname.write(cmd) fd_fname.write(output) # Verify show redundancy cmd = "admin show redundancy" success, output = device.execute_command(cmd) if re.search(valid_redundancy, output) or re.search(no_valid_redundancy, output): fd_fname.write(cmd) fd_fname.write(output) else: fd_fname.close() self.error("Redundancy check failed :\n%s" % (output)) # Commit the installed software now #cmd = "admin install commit" #success, output = device.execute_command(cmd) #if not success or re.search(failed_oper, output): # fd_fname.close() # self.error("Instal commit failed:\n%s" % (output)) # Store the state of packages after install cmd = "admin show install active" success, output = device.execute_command(cmd) if success: fd_fname.write(cmd) fd_fname.write(output) cmd = "admin show install inactive" success, output = device.execute_command(cmd) if success: fd_fname.write(cmd) fd_fname.write(output) cmd = "admin show install commit" success, output = device.execute_command(cmd) if success: fd_fname.write(cmd) fd_fname.write(output) # Show configuration failed startup cmd = "show configuration failed startup" success, output = device.execute_command(cmd) if success and len(output.split("\n")) > 4: fd_fname.close() self.warning("Fialed configs check {} {}".format(cmd, output)) return False # TBD # 1. Clear config inconsistency # 2. install verify package / install verify package repair # 3. Cfs check # 4. mirror location 0/RSP0/CPU0 disk0:disk1: return True
def start(self, device, *args, **kwargs): """ Start the plugin """ no_valid_redundancy = 'Node \w+/\w+/\w+ has no valid partner' valid_redundancy = 'Node Redundancy Partner \(\w+/\w+/\w+\) is in .+ role' failed_oper = r'Install operation (\d+) failed' name = "{}.log".format(self.NAME.lower()) fname = os.path.join(device.output_store_dir, name.replace(":", "_")) try: fd_fname = open(fname, 'w') except: self.error("Failed to open %s file to write " % (fname)) cmd = "admin show platform" success, output = device.execute_command(cmd) if success: inventory = pkgutils.parse_xr_show_platform(output) if not pkgutils.validate_xr_node_state(inventory, device): fd_fname.close() self.error("All nodes are not in right state:\n %s" % (output)) # Save what was verified fd_fname.write(cmd) fd_fname.write(output) # Verify show redundancy cmd = "admin show redundancy" success, output = device.execute_command(cmd) if re.search(valid_redundancy, output) or re.search( no_valid_redundancy, output): fd_fname.write(cmd) fd_fname.write(output) else: fd_fname.close() self.error("Redundancy check failed :\n%s" % (output)) # Commit the installed software now #cmd = "admin install commit" #success, output = device.execute_command(cmd) #if not success or re.search(failed_oper, output): # fd_fname.close() # self.error("Instal commit failed:\n%s" % (output)) # Store the state of packages after install cmd = "admin show install active" success, output = device.execute_command(cmd) if success: fd_fname.write(cmd) fd_fname.write(output) cmd = "admin show install inactive" success, output = device.execute_command(cmd) if success: fd_fname.write(cmd) fd_fname.write(output) cmd = "admin show install commit" success, output = device.execute_command(cmd) if success: fd_fname.write(cmd) fd_fname.write(output) # Show configuration failed startup cmd = "show configuration failed startup" success, output = device.execute_command(cmd) if success and len(output.split("\n")) > 4: fd_fname.close() self.warning("Fialed configs check {} {}".format(cmd, output)) return False # TBD # 1. Clear config inconsistency # 2. install verify package / install verify package repair # 3. Cfs check # 4. mirror location 0/RSP0/CPU0 disk0:disk1: return True