networktocode / pyntc

Python library focused on tasks related to device level and OS management.
https://pyntc.readthedocs.io/en/latest/
Other
170 stars 52 forks source link

Running install mode for install_os from ios_device.py returns unexpected key argument error for delay_factor on line 712 #242

Closed shenglong closed 2 years ago

shenglong commented 2 years ago

Hello, in version 0.20.1, when running install_os in install mode, from ios_device.py returns an error of unexpected keyword argument for show():

The full traceback is:
  File "/tmp/ansible_gna.gna_collections.install_os_payload_jpa7zvmx/ansible_gna.gna_collections.install_os_payload.zip/ansible_collections/gna/gna_collections/plugins/modules/install_os.py", line 303, in main
  File "/home/yogurtschwartz/projects/v_envs/py39/lib/python3.9/site-packages/pyntc/devices/ios_device.py", line 712, in install_os
    self.show(command, delay_factor=install_mode_delay_factor)
show() got an unexpected keyword argument 'delay_factor'

If we don't pass the delay_factor variable to the show(), then the command from ios_device.py on line 712, with this content instead:

command = (f"install add file {self._get_file_system()}{image_name} activate commit prompt-level none")
self.show(command)

The os upgrade installation runs correctly on the device, and the install process happens without issues.

shenglong commented 2 years ago

After reviewing it these past days, the show() function, doesn't expect a netmiko arg when the install_os runs in install mode, but in install mode when invoking the show(), it passes a netmiko arg, that's why it returns a key argument error when invoking show() in install mode for install_os.

Update: When enabling the netmiko arg to be passed into show(), the install mode runs without issues too.

def install_os(self, image_name, install_mode=False, install_mode_delay_factor=20, **vendor_specifics):
...
    self.show(command, delay_factor=install_mode_delay_factor)
def show(self, command, expect_string=None, **netmiko_args):
        """Run command on device.

        Args:
            command (str): Command to be ran.
            expect_string (str, optional): Expected string from command output. Defaults to None.

        Returns:
            str: Output of command.
        """
        self.enable()
        return self._send_command(command, expect_string=expect_string, **netmiko_args)
shenglong commented 2 years ago

Good day, I wanted to know if this change was feasible, or could it be reviewed.

jeffkala commented 2 years ago

closed in #243