diff --git a/pkgs/clean-pkg/changelog/undistributed/changelog_xr_clean_installimagesandpackages_improvement_20220119105121.rst b/pkgs/clean-pkg/changelog/undistributed/changelog_xr_clean_installimagesandpackages_improvement_20220119105121.rst new file mode 100644 index 000000000..080cbbefd --- /dev/null +++ b/pkgs/clean-pkg/changelog/undistributed/changelog_xr_clean_installimagesandpackages_improvement_20220119105121.rst @@ -0,0 +1,10 @@ +-------------------------------------------------------------------------------- + Fix +-------------------------------------------------------------------------------- +* IOSXR + * Modified: + * Clean Stage: + * InstallImagesAndPackages: + * Enhancement to handle CLI install add/activate in 'synchronous' mode and in standard mode + * Better catch the potential error message when the install is running in the background + diff --git a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxr/stages.py b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxr/stages.py index 1725e209b..c547d795d 100755 --- a/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxr/stages.py +++ b/pkgs/clean-pkg/src/genie/libs/clean/stages/iosxr/stages.py @@ -494,9 +494,13 @@ def update_install_repository(self, steps, device, image, error_pattern=self.error_patterns) out = device.expect( - [self.successful_operation_string], + [self.successful_operation_string, self.install_operation_aborted_pattern], trim_buffer=False, timeout=install_timeout) + error = re.search(self.install_operation_aborted_pattern, out.match_output) + if error: + device.execute("show install log " + error.groupdict()['id']) + step.failed("The command '{cmd}' aborted ".format(cmd=cmd)) except Exception as e: step.failed("The command '{cmd}' failed. Error: {e}" .format(cmd=cmd, e=str(e))) @@ -538,9 +542,14 @@ def install_activate(self, steps, device, install_timeout=INSTALL_TIMEOUT): device.spawn, timeout=install_timeout) # Wait for successful output - device.expect( - [self.successful_operation_string], + out = device.expect( + [self.successful_operation_string, self.install_operation_aborted_pattern], + trim_buffer=False, timeout=install_timeout) + error = re.search(self.install_operation_aborted_pattern, out.match_output) + if error: + device.execute("show install log " + error.groupdict()['id']) + step.failed("The command '{cmd}' aborted ".format(cmd=cmd)) except Exception as e: step.failed("Attempting to activate install id '{id}' " "failed. Error: {e}"