def run(self): """ It performs commit operation """ failed_oper = r'Install operation (\d+) failed' completed_with_failure = 'Install operation (\d+) completed with failure' success_oper = r'Install operation (\d+) completed successfully' cmd = "admin install commit" output = self.ctx.send(cmd) result = re.search('Install operation (\d+) \'', output) if result: op_id = result.group(1) watch_operation(self.ctx, op_id) else: log_install_errors(self.output) self.ctx.error("Operation ID not found.") return cmd = "admin show install log {} detail".format(op_id) output = self.ctx.send(cmd) if re.search(failed_oper, output): log_install_errors(self.ctx, output) self.ctx.error("Install operation failed.") return if re.search(completed_with_failure, output): log_install_errors(self.ctx, output) self.ctx.info("Completed with failure but failure was after Point of No Return.") elif re.search(success_oper, output): self.ctx.info("Operation {} finished successfully.".format(op_id)) get_package(self.ctx)
def handle_non_reload_cmd(self, fsm_ctx): self.op_id = self.get_op_id(fsm_ctx.ctrl.before) if self.op_id == -1: self.fsm_result = False return False watch_operation(self.ctx, self.op_id) self.fsm_result = True return True
def run(self): """ It performs commit operation RP/0/RP0/CPU0:Deploy#install commit May 27 16:34:04 Install operation 32 started by root: install commit May 27 16:34:05 Install operation will continue in the background RP/0/RP0/CPU0:Deploy#May 27 16:34:11 Install operation 32 finished successfully """ cmd = "install commit" output = self.ctx.send(cmd) result = re.search('Install operation (\d+)', output) if result: op_id = result.group(1) watch_operation(self.ctx, op_id) else: log_install_errors(self.ctx, output) self.ctx.error("Operation ID not found.") return failed_oper = r'Install operation {} aborted'.format(op_id) success_oper = r'Install operation (\d+) finished successfully' # Not sure if this is still the message on NCS6K completed_with_failure = 'Install operation (\d+) completed with failure' cmd = "show install log {} detail".format(op_id) output = self.ctx.send(cmd) if re.search(failed_oper, output): log_install_errors(self.ctx, output) self.ctx.error("Install operation failed.") return if re.search(completed_with_failure, output): log_install_errors(self.ctx, output) self.ctx.info( "Completed with failure but failure was after Point of No Return." ) elif re.search(success_oper, output): self.ctx.info("Operation {} finished successfully.".format(op_id)) # Refresh package and inventory information get_package(self.ctx) get_inventory(self.ctx)
def run(self): """ It performs commit operation RP/0/RP0/CPU0:Deploy#install commit May 27 16:34:04 Install operation 32 started by root: install commit May 27 16:34:05 Install operation will continue in the background RP/0/RP0/CPU0:Deploy#May 27 16:34:11 Install operation 32 finished successfully """ cmd = "install commit" output = self.ctx.send(cmd) result = re.search(r'Install operation (\d+)', output) if result: op_id = result.group(1) watch_operation(self.ctx, op_id) else: log_install_errors(self.ctx, output) self.ctx.error("Operation ID not found.") return failed_oper = r'Install operation {} aborted'.format(op_id) success_oper = r'Install operation (\d+) finished successfully' # Not sure if this is still the message on NCS6K completed_with_failure = r'Install operation (\d+) completed with failure' cmd = "show install log {} detail".format(op_id) output = self.ctx.send(cmd) if re.search(failed_oper, output): log_install_errors(self.ctx, output) self.ctx.error("Install operation failed.") return if re.search(completed_with_failure, output): log_install_errors(self.ctx, output) self.ctx.info("Completed with failure but failure was after Point of No Return.") elif re.search(success_oper, output): self.ctx.info("Operation {} finished successfully.".format(op_id)) # Refresh package and inventory information get_package(self.ctx) get_inventory(self.ctx)
def handle_reload_cmd(self, fsm_ctx): self.ctx.send("yes", timeout=30) self.op_id = self.get_op_id(fsm_ctx.ctrl.before) if self.op_id == -1: self.fsm_result = False return False sleep(60) try: watch_operation(self.ctx, self.op_id) except self.ctx.CommandTimeoutError: # The device already started the reload pass success = wait_for_reload(self.ctx) if not success: self.ctx.error("Reload or boot failure") self.fsm_result = False return self.ctx.info("Operation {} finished successfully".format(self.op_id)) self.fsm_result = True return True
def run(self): """ It performs commit operation """ failed_oper = r'Install operation (\d+) failed' completed_with_failure = 'Install operation (\d+) completed with failure' success_oper = r'Install operation (\d+) completed successfully' cmd = "admin install commit" output = self.ctx.send(cmd) result = re.search('Install operation (\d+) \'', output) if result: op_id = result.group(1) watch_operation(self.ctx, op_id) else: log_install_errors(self.ctx, output) self.ctx.error("Operation ID not found.") return cmd = "admin show install log {} detail".format(op_id) output = self.ctx.send(cmd) if re.search(failed_oper, output): log_install_errors(self.ctx, output) self.ctx.error("Install operation failed.") return if re.search(completed_with_failure, output): log_install_errors(self.ctx, output) self.ctx.info( "Completed with failure but failure was after Point of No Return." ) elif re.search(success_oper, output): self.ctx.info("Operation {} finished successfully.".format(op_id)) # Refresh package and inventory information get_package(self.ctx) get_inventory(self.ctx)
def handle_confirm(self, fsm_ctx): self.ctx.send("yes", timeout=30) self.op_id = self.get_op_id(fsm_ctx.ctrl.before) watch_operation(self.ctx, self.op_id) self.fsm_result = True return True