@@ -877,11 +877,12 @@ def file_copy_remote_exists(self, src, dest=None, file_system=None):
877877 log .debug ("Host %s: File %s does not already exist on remote." , self .host , src )
878878 return False
879879
880- def install_os (self , image_name , install_mode = False , read_timeout = 2000 , ** vendor_specifics ):
880+ def install_os (self , image_name , reboot = True , install_mode = False , read_timeout = 2000 , ** vendor_specifics ):
881881 """Installs the prescribed Network OS, which must be present before issuing this command.
882882
883883 Args:
884884 image_name (str): Name of the IOS image to boot into
885+ reboot (bool): Whether to reboot the device after setting the boot options. Defaults to true.
885886 install_mode (bool, optional): Uses newer install method on devices. Defaults to False.
886887 read_timeout (int, optional): Netmiko timeout when waiting for device prompt. Default 2000.
887888 vendor_specifics (dict, optional): Vendor specific arguments to pass to the install command.
@@ -894,6 +895,11 @@ def install_os(self, image_name, install_mode=False, read_timeout=2000, **vendor
894895 """
895896 timeout = vendor_specifics .get ("timeout" , 3600 )
896897 if not self ._image_booted (image_name ):
898+ if install_mode and not reboot :
899+ raise ValueError (
900+ "IOS devices automatically reboot after installation when using install mode but the reboot argument was set to false."
901+ )
902+
897903 if install_mode :
898904 # Change boot statement to be boot system <flash>:packages.conf
899905 self .set_boot_options (INSTALL_MODE_FILE_NAME , ** vendor_specifics )
@@ -926,6 +932,9 @@ def install_os(self, image_name, install_mode=False, read_timeout=2000, **vendor
926932 self .reboot ()
927933 else :
928934 self .set_boot_options (image_name , ** vendor_specifics )
935+ if not reboot :
936+ log .info ("Host %s: OS image %s boot options set. Reboot the device to apply" , self .host , image_name )
937+ return True
929938 self .reboot ()
930939
931940 # Wait for the reboot to finish
0 commit comments