def run(self): """ Performs install activate operation """ check_ncs6k_release(self.ctx) operation_id = None if hasattr(self.ctx, 'operation_id'): if self.ctx.operation_id != -1: self.ctx.info("Using the operation ID: {}".format(self.ctx.operation_id)) operation_id = self.ctx.operation_id if operation_id is None or operation_id == -1: tobe_activated = self.get_tobe_activated_pkg_list() if not tobe_activated: self.ctx.info("Nothing to be activated.") return True if operation_id is not None and operation_id != -1: cmd = 'install activate id {}'.format(operation_id) else: cmd = 'install activate {}'.format(tobe_activated) self.ctx.info("Activate package(s) pending") self.ctx.post_status("Activate Package(s) Pending") install_activate_deactivate(self.ctx, cmd) self.ctx.info("Activate package(s) done") # Refresh package and inventory information get_package(self.ctx) get_inventory(self.ctx) update_device_info_udi(self.ctx)
def run(self): check_ncs6k_release(self.ctx) server_repository_url = self.ctx.server_repository_url if server_repository_url is None: self.ctx.error("No repository provided") return packages = self.ctx.software_packages if packages is None: self.ctx.error("No package list provided") return has_tar = False if self.ctx.family == 'NCS6K': s_packages = " ".join([ package for package in packages if ('iso' in package or 'pkg' in package or 'smu' in package or 'tar' in package) ]) else: s_packages = " ".join([ package for package in packages if ('rpm' in package or 'iso' in package or 'tar' in package) ]) if 'tar' in s_packages: has_tar = True if not s_packages: self.ctx.error( "None of the selected package(s) has an acceptable file extension." ) self.ctx.info("Add Package(s) Pending") self.ctx.post_status("Add Package(s) Pending") self.install_add(server_repository_url, s_packages, has_tar=has_tar) self.ctx.info("Package(s) Added Successfully") # Refresh package and inventory information get_package(self.ctx) get_inventory(self.ctx)
def run(self): """ Performs install deactivate operation RP/0/RP0/CPU0:Deploy#install deactivate ncs6k-5.2.5.CSCuz65240-1.0.0 May 27 16:39:31 Install operation 33 started by root: install deactivate pkg ncs6k-5.2.5.CSCuz65240-1.0.0 May 27 16:39:31 Package list: May 27 16:39:31 ncs6k-5.2.5.CSCuz65240-1.0.0 May 27 16:39:36 Install operation will continue in the background """ check_ncs6k_release(self.ctx) operation_id = None if hasattr(self.ctx, 'operation_id'): if self.ctx.operation_id != -1: self.ctx.info("Using the operation ID: {}".format( self.ctx.operation_id)) operation_id = self.ctx.operation_id if operation_id is None or operation_id == -1: tobe_deactivated = self.get_tobe_deactivated_pkg_list() if not tobe_deactivated: self.ctx.info("Nothing to be deactivated.") return True if operation_id is not None and operation_id != -1: cmd = 'install deactivate id {}'.format(operation_id) else: cmd = 'install deactivate {}'.format(tobe_deactivated) self.ctx.info("Deactivate package(s) pending") self.ctx.post_status("Deactivate Package(s) Pending") install_activate_deactivate(self.ctx, cmd) self.ctx.info("Deactivate package(s) done") # Refresh package and inventory information get_package(self.ctx) get_inventory(self.ctx)
def run(self): check_ncs6k_release(self.ctx) server_repository_url = self.ctx.server_repository_url if server_repository_url is None: self.ctx.error("No repository provided") return packages = self.ctx.software_packages if packages is None: self.ctx.error("No package list provided") return has_tar = False if self.ctx.family == 'NCS6K': s_packages = " ".join([ package for package in packages if ('iso' in package or 'pkg' in package or 'smu' in package or 'tar' in package) ]) else: s_packages = " ".join([ package for package in packages if ('rpm' in package or 'iso' in package or 'tar' in package) ]) if 'tar' in s_packages: has_tar = True if not s_packages: self.ctx.error( "None of the selected package(s) has an acceptable file extension." ) # OIR facility is available only for calvados package installations self.ctx.send("admin", timeout=30) self.disable_standby() cmd = "install add source {} {} ".format(server_repository_url, s_packages) result = self.execute_cmd(cmd) if result: pkg_id = self.op_id if has_tar is True: self.ctx.operation_id = self.op_id self.ctx.info("The operation {} stored".format(self.op_id)) self.ctx.info("Package(s) Added Successfully") else: self.ctx.info("Failed to add packages") self.ctx.error(result) return self.ctx.info("Add package(s) passed") self.ctx.post_status("Add package(s) passed") cmd = "install activate id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) Activated Successfully") else: self.ctx.info("Failed to activate packages") return self.ctx.info("Activate package(s) passed") self.ctx.post_status("Activate package(s) passed") if not self.verify_pkgs(): return False if not self.commit_verify(): return False self.enable_standby() # give the standby sufficient time to sync i.e do the OIR sleep(600) cmd = "install deactivate id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) deactivated Successfully") else: self.ctx.info("Failed to deactivate packages") return self.ctx.info("Deactivate package(s) passed") self.ctx.post_status("Deactivate package(s) passed") if not self.commit_verify(): return False cmd = "install remove id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) remove Successfully") else: self.ctx.info("Failed to remove packages") return self.ctx.info("Remove package(s) passed") self.ctx.post_status("Remove package(s) passed") if not self.commit_verify(): return False self.ctx.send("exit", timeout=30) return True
def run(self): check_ncs6k_release(self.ctx) server_repository_url = self.ctx.server_repository_url if server_repository_url is None: self.ctx.error("No repository provided") return packages = self.ctx.software_packages if packages is None: self.ctx.error("No package list provided") return has_tar = False if self.ctx.family == 'NCS6K': s_packages = " ".join([package for package in packages if ('iso' in package or 'pkg' in package or 'smu' in package or 'tar' in package)]) else: s_packages = " ".join([package for package in packages if ('rpm' in package or 'iso' in package or 'tar' in package)]) if 'tar' in s_packages: has_tar = True if not s_packages: self.ctx.error("None of the selected package(s) has an acceptable file extension.") admin_mode = self.ctx.admin_mode if admin_mode: self.ctx.send("admin", timeout=30) parent_pkg = self.ctx.parent_pkg cmd = "install add source {} {} ".format(server_repository_url, parent_pkg) result = self.execute_cmd(cmd) if not result: self.ctx.info("failed to add parent pkg") return parent_id = self.op_id cmd = "install add source {} {} ".format(server_repository_url, s_packages) result = self.execute_cmd(cmd) if result: pkg_id = self.op_id if has_tar is True: self.ctx.operation_id = self.op_id self.ctx.info("The operation {} stored".format(self.op_id)) self.ctx.info("Package(s) Added Successfully") else: self.ctx.info("Failed to add packages") self.ctx.error(result) return self.ctx.info("Add package(s) passed") self.ctx.post_status("Add package(s) passed") # adding package before parent will fail cmd = "install prepare id {} ".format(pkg_id) try: result = self.execute_cmd(cmd) except PluginError: err_str = "Validated child cannot be prepared before parent" self.ctx.info(err_str) self.ctx.post_status(err_str) self.ctx._connection.reconnect() pass else: err_str = "Failed: Validate child cannot be prepared before parent" self.ctx.info(err_str) self.ctx.post_status(err_str) self.execute_cmd("install prepare clean") cmd = "install prepare id {} {}".format(parent_id, pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.post_status("Prepared packages successfully") else: self.ctx.info("Failed to prepared packages") self.ctx.post_status("Failed to prepared packages") return result = self.execute_cmd("install activate") if result: self.ctx.info("Package(s) activated Successfully") self.ctx.post_status("Package(s) activated Successfully") else: self.ctx.info("Failed to activate packages") return cmd = "install remove id {} ".format(pkg_id) # removing package which is active will fail try: result = self.execute_cmd(cmd) except: err_str = "Validated active child package cannot be removed" self.ctx.info(err_str) self.ctx.post_status(err_str) self.ctx._connection.reconnect() pass else: err_str = "Failed: Validate active child package cannot be removed" self.ctx.info(err_str) self.ctx.post_status(err_str) cmd = "install remove id {} ".format(parent_id) try: result = self.execute_cmd(cmd) except: err_str = "Validated active parent package cannot be removed" self.ctx.info(err_str) self.ctx.post_status(err_str) self.ctx._connection.reconnect() pass else: err_str = "Failed: Validate active parent package cannot be removed" self.ctx.info(err_str) self.ctx.post_status(err_str) self.execute_cmd("install commit") result = self.execute_cmd("install commit") self.commit_verify() cmd = "install deactivate id {} {} ".format(parent_id, pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) deactivated Successfully") self.ctx.post_status("Package(s) deactivated Successfully") else: self.ctx.info("Failed to deactivate packages") self.ctx.post_status("Failed to deactivate packages") return self.ctx.info("Deactivate package(s) passed") self.ctx.post_status("Deactivate package(s) passed") result = self.execute_cmd("install commit") cmd = "install remove id {} ".format(parent_id) self.ctx.post_status(cmd) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) remove Successfully") else: self.ctx.info("Failed to remove packages") return self.ctx.info("Remove package(s) passed") self.ctx.post_status("Remove package(s) passed") self.execute_cmd("install commit") if admin_mode: self.ctx.send("exit", timeout=30) self.ctx.send("exit", timeout=30) return True
def run(self): check_ncs6k_release(self.ctx) server_repository_url = self.ctx.server_repository_url if server_repository_url is None: self.ctx.error("No repository provided") return packages = self.ctx.software_packages if packages is None: self.ctx.error("No package list provided") return has_tar = False if self.ctx.family == 'NCS6K': s_packages = " ".join([ package for package in packages if ('iso' in package or 'pkg' in package or 'smu' in package or 'tar' in package) ]) else: s_packages = " ".join([ package for package in packages if ('rpm' in package or 'iso' in package or 'tar' in package) ]) if 'tar' in s_packages: has_tar = True if not s_packages: self.ctx.error( "None of the selected package(s) has an acceptable file extension." ) cmd = "install add source {} {} ".format(server_repository_url, s_packages) result = self.execute_cmd(cmd) if result: pkg_id = self.op_id if has_tar is True: self.ctx.operation_id = self.op_id self.ctx.info("The operation {} stored".format(self.op_id)) self.ctx.info("Package(s) Added Successfully") else: self.ctx.info("Failed to add packages") self.ctx.error(result) return self.ctx.info("Add package(s) passed") self.ctx.post_status("Add package(s) passed") pkg_name = self.get_pkg_name(pkg_id) cmd = "show install package {} ".format(pkg_name) result = self.ctx.send(cmd, timeout=120) self.ctx.info(result) cmd = "install activate id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) Activated Successfully") else: self.ctx.info("Failed to activate packages") return self.ctx.info("Activate package(s) passed") self.ctx.post_status("Activate package(s) passed") cmd = "reload location all" result = self.execute_cmd(cmd) if result: self.ctx.info("Reload happened Successfully") else: self.ctx.info("Failed to reload ") return cmd = "install commit" result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) committed Successfully") else: self.ctx.info("Failed to commit packages") return self.ctx.info("SU complete") return True
def run(self): check_ncs6k_release(self.ctx) server_repository_url = self.ctx.server_repository_url if server_repository_url is None: self.ctx.error("No repository provided") return packages = self.ctx.software_packages if packages is None: self.ctx.error("No package list provided") return has_tar = False # is_tp_smu = False # for pkg in packages: # if "CSCke" in pkg: # is_tp_smu = True # break if self.ctx.family == 'NCS6K': s_packages = " ".join([package for package in packages if ('iso' in package or 'pkg' in package or 'smu' in package or 'tar' in package)]) else: s_packages = " ".join([package for package in packages if ('rpm' in package or 'iso' in package or 'tar' in package)]) if 'tar' in s_packages: has_tar = True if not s_packages: self.ctx.error("None of the selected package(s) has an acceptable file extension.") admin_mode = self.ctx.admin_mode if admin_mode: self.ctx.send("admin", timeout=30) cmd = "install add source {} {} ".format(server_repository_url, s_packages) result = self.execute_cmd(cmd) if result: pkg_id = self.op_id if has_tar is True: self.ctx.operation_id = self.op_id self.ctx.info("The operation {} stored".format(self.op_id)) self.ctx.info("Package(s) Added Successfully") else: self.ctx.info("Failed to add packages") self.ctx.error(result) return self.ctx.info("Add package(s) passed") self.ctx.post_status("Add package(s) passed") self.generic_show() cmd = "install prepare id {} ".format(pkg_id) result = self.execute_cmd(cmd) result = self.execute_cmd("install prepare clean") cmd = "install prepare id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) Prepared Successfully") else: self.ctx.info("Failed to prepared packages") return result = self.execute_cmd("install activate") result = self.execute_cmd("install commit") self.commit_verify() cmd = "install deactivate id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) deactivated Successfully") else: self.ctx.info("Failed to deactivate packages") return if not self.verify_pkgs(): return result = self.execute_cmd("install commit") self.commit_verify() cmd = "install activate id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) activated Successfully") else: self.ctx.info("Failed to activated packages") return self.ctx.info("Activate package(s) passed") self.ctx.post_status("Activate package(s) passed") if not self.verify_pkgs(): return self.generic_show() result = self.execute_cmd("install commit") self.commit_verify() cmd = "install deactivate id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) deactivated Successfully") else: self.ctx.info("Failed to deactivate packages") return self.ctx.info("Deactivate package(s) passed") self.ctx.post_status("Deactivate package(s) passed") result = self.execute_cmd("install commit") cmd = "install remove id {} ".format(pkg_id) result = self.execute_cmd(cmd) if result: self.ctx.info("Package(s) remove Successfully") else: self.ctx.info("Failed to remove packages") return self.ctx.info("Remove package(s) passed") self.ctx.post_status("Remove package(s) passed") self.generic_show() self.execute_cmd("install commit") if admin_mode: self.ctx.send("exit", timeout=30) self.ctx.send("exit", timeout=30) return True
def run(self): check_ncs6k_release(self.ctx) server_repository_url = self.ctx.server_repository_url if server_repository_url is None: self.ctx.error("No repository provided") return packages = self.ctx.software_packages if packages is None: self.ctx.error("No package list provided") return has_tar = False is_iso = False if self.ctx.family == 'NCS6K': s_packages = " ".join([ package for package in packages if ('iso' in package or 'pkg' in package or 'smu' in package or 'tar' in package) ]) else: s_packages = " ".join([ package for package in packages if ('rpm' in package or 'iso' in package or 'tar' in package) ]) if 'tar' in s_packages: has_tar = True if 'iso' in s_packages: is_iso = True if not s_packages: self.ctx.error( "None of the selected package(s) has an acceptable file extension." ) cmd = "install add source {} {} ".format(server_repository_url, s_packages) result = self.execute_cmd(cmd) if result: pkg_id = self.op_id if has_tar is True: self.ctx.operation_id = self.op_id self.ctx.info("The operation {} stored".format(self.op_id)) self.ctx.info("Package(s) Added Successfully") else: self.ctx.info("Failed to add packages") self.ctx.error(result) return self.ctx.info("Add package(s) passed") self.ctx.post_status("Add package(s) passed") pkg_name = self.get_pkg_name(pkg_id) self.ctx.info("pkg_name = ") self.ctx.info(pkg_name) admin_mode = self.ctx.admin_mode if admin_mode: self.ctx.send("admin", timeout=30) if is_iso: cmd = "install extract {} ".format(pkg_name) result = self.execute_cmd(cmd) if result: self.ctx.info("Package extracted Successfully") else: self.ctx.info("Failed to extract package") return extracted_pkg_name = self.get_extracted_pkg(self.op_id, admin_mode) result = self.check_prepare(extracted_pkg_name) if result: self.ctx.info("Validated issu prepare operation") else: self.ctx.info("Failed validation of issu prepare operation") return result = self.perform_activate(extracted_pkg_name) if result: result = self.execute_cmd( "install activate issu abort cleanup") if result: self.ctx.info("Validated install activate issu") else: self.ctx.info( "Failed install activate issu abort cleanup") return else: self.ctx.info("Failed install activate issu") return else: result = self.check_prepare(pkg_name) if result: self.ctx.info("Validated issu prepare operation") else: self.ctx.info("Failed validation of issu prepare operation") return result = self.perform_activate(pkg_name) if result: try: result = self.execute_cmd("install activate issu run") except PluginError: self.ctx._connection.reconnect() pass if result: self.ctx.info("Validated install activate issu run") cmd = "install deactivate {} ".format(pkg_name) result = self.execute_cmd(cmd) if result: self.ctx.info("Validated deactivate issu") else: self.ctx.info("Failed deactivate issu") else: self.ctx.info("Failed install activate issu run") return else: self.ctx.info("Failed install activate issu load") if admin_mode: self.ctx.send("exit", timeout=30) return True