def set_boot_options(self, image_name, kickstart=None, **vendor_specifics): file_system = vendor_specifics.get("file_system") if file_system is None: file_system = "bootflash:" file_system_files = self.show("dir {0}".format(file_system), raw_text=True) if re.search(image_name, file_system_files) is None: raise NTCFileNotFoundError(hostname=self.hostname, file=image_name, dir=file_system) if kickstart is not None: if re.search(kickstart, file_system_files) is None: raise NTCFileNotFoundError(hostname=self.hostname, file=kickstart, dir=file_system) kickstart = file_system + kickstart image_name = file_system + image_name self.native.timeout = 300 upgrade_result = self.native.set_boot_options(image_name, kickstart=kickstart) self.native.timeout = 30 return upgrade_result
def set_boot_options(self, image_name, **vendor_specifics): current_boot = self.show("show running-config | inc ^boot system ") file_system = vendor_specifics.get("file_system") if file_system is None: file_system = self._get_file_system() file_system_files = self.show("dir {0}".format(file_system)) if re.search(image_name, file_system_files) is None: raise NTCFileNotFoundError( # TODO: Update to use hostname hostname=self.host, file=image_name, dir=file_system, ) current_images = current_boot.splitlines() commands_to_exec = ["no {0}".format(image) for image in current_images] commands_to_exec.append("boot system {0}/{1}".format(file_system, image_name)) self.config_list(commands_to_exec) self.save() if self.boot_options["sys"] != image_name: raise CommandError( command="boot system {0}/{1}".format(file_system, image_name), message="Setting boot command did not yield expected results", )
def set_boot_options(self, image_name, **vendor_specifics): volume = vendor_specifics.get("volume") self._check_free_space(min_space=6) if not self._image_exists(image_name): raise NTCFileNotFoundError(hostname=self._get_hostname(), file=image_name, dir="/shared/images") self._image_install(image_name=image_name, volume=volume) self._wait_for_image_installed(image_name=image_name, volume=volume)
def set_boot_options(self, image_name, **vendor_specifics): file_system = vendor_specifics.get("file_system") if file_system is None: file_system = self._get_file_system() file_system_files = self.show("dir {0}".format(file_system)) if re.search(image_name, file_system_files) is None: raise NTCFileNotFoundError(hostname=self.hostname, file=image_name, dir=file_system) try: command = "boot system {0}/{1}".format(file_system, image_name) self.config(["no boot system", command]) except CommandListError: # TODO: Update to CommandError when deprecating config_list file_system = file_system.replace(":", "") command = "boot system {0} {1}".format(file_system, image_name) self.config(["no boot system", command]) self.save() new_boot_options = self.boot_options["sys"] if new_boot_options != image_name: raise CommandError( command=command, message= "Setting boot command did not yield expected results, found {0}" .format(new_boot_options), )
def set_boot_options(self, image_name, **vendor_specifics): file_system = vendor_specifics.get("file_system") if file_system is None: file_system = self._get_file_system() file_system_files = self.show("dir {0}".format(file_system)) if re.search(image_name, file_system_files) is None: raise NTCFileNotFoundError(hostname=self.facts.get("hostname"), file=image_name, dir=file_system) try: self.config_list([ 'no boot system', 'boot system {0}/{1}'.format(file_system, image_name) ]) except CommandError: file_system = file_system.replace(':', '') self.config_list([ 'no boot system', 'boot system {0} {1}'.format(file_system, image_name) ]) if self.get_boot_options()["sys"] != image_name: raise CommandError( command="boot command", message="Setting boot command did not yield expected results", )
def set_boot_options(self, image_name, **vendor_specifics): file_system = vendor_specifics.get("file_system") if file_system is None: file_system = self._get_file_system() file_system_files = self.show("dir {0}".format(file_system), raw_text=True) if re.search(image_name, file_system_files) is None: raise NTCFileNotFoundError(hostname=self.facts.get("hostname"), file=image_name, dir=file_system) self.show("install source {0}{1}".format(file_system, image_name)) if self.get_boot_options()["sys"] != image_name: raise CommandError( command="install source {0}".format(image_name), message="Setting install source did not yield expected results", )
def install_os(self, image_name, **vendor_specifics): volume = vendor_specifics.get('volume') if not self.image_installed(image_name, volume): self._check_free_space(min_space=6) if not self._image_exists(image_name): raise NTCFileNotFoundError(hostname=self._get_hostname(), file=image_name, dir='/shared/images') self._image_install(image_name=image_name, volume=volume) self._wait_for_image_installed(image_name=image_name, volume=volume) return True return False
def set_boot_options(self, image_name, **vendor_specifics): """ Set the version to boot on the device. Args: image_name (str): The version to boot into on next reload. Raises: NTCFileNotFoundError: When the version is not listed in ``boot_options``. Example: >>> device = AIREOSDevice(**connection_args) >>> device.boot_options { 'backup': '8.8.125.0', 'primary': '8.9.100.0', 'sys': '8.9.100.0' } >>> device.set_boot_options("8.8.125.0") >>> device.boot_options { 'backup': '8.8.125.0', 'primary': '8.9.100.0', 'sys': '8.8.125.0' } """ if self.boot_options["primary"] == image_name: boot_command = "boot primary" elif self.boot_options["backup"] == image_name: boot_command = "boot backup" else: raise NTCFileNotFoundError(image_name, "'show boot'", self.host) self.config(boot_command) self.save() if not self.boot_options["sys"] == image_name: raise CommandError( command=boot_command, message="Setting boot command did not yield expected results", )