Closed ZacharyPuls closed 9 months ago
Hello @ZacharyPuls,
This is strange, but rather than removing the error handling, I will be looking at why the copyfile
returns None
for IOSXR
devices. So, kindly give me some time to analyse and debug the issue.
Thank you.
Hello @ZacharyPuls,
I think I have found the issue the repo.
For iosxe
, if you check the method copyfile
defined in iosxe/fileutils.py#L118, this method returns the output of copyfile
of parent class FileUtilsDeviceBase
which is defined in plugins/fileutils.py#L92 which again return the output of send_cli_to_device
which is defined in filetransferutils/fileutils.py#L39 which returns the output execute
API. And hence, for iosxe
this issue is not seen because it is return something than None
. Now, as per the function documentation it is wrong because it is not returning the None
.
Now, for iosxr
, the method copyfile
defined in iosxr/fileutils.py#L20 doesn't return the output of copyfile
of parent class FileUtilsDeviceBase
and hence by default it is returning None
. So, if we make the change in this file to return the output of copyfile
of parent class FileUtilsDeviceBase
then I think this issue will be resolved.
Can you please add return
here iosxr/fileutils.py#L122 and let me know if this fixes the issue or not?
Thank you.
Hello @ZacharyPuls,
Did you get a chance to test it again with above mentioned changes? Kindly let me know.
Thank you.
Hello @ZacharyPuls,
Did you try with above mentioned solution? Kindly let me know.
Thank you.
Hello @ZacharyPuls,
I have raised the PR for this issue. I will update you once this PR gets merged. Thank you.
I apologize for the delay in response, it's taken me a bit to get back to this. I can confirm this works on our lab device.
Hello @ZacharyPuls,
No problem and thanks for confirmation. I have already merged the PR as well, so in the upcoming pyATS version this fix will be available. Hence, I am closing this ticket, if you still see this issue with newer pyATS version, then kindly let me know.
Thank you.
In genielibs/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py line 1208, device.api.copy_to_device checks for a non-None return value:
This returns the result of FileUtils.copyfile (genielibs/pkgs/sdk-pkg/src/genie/libs/sdk/apis/utils.py, lines 913-931):
Which, on IOS-XR (genielibs/pkgs/filetransferutils-pkg/src/genie/libs/filetransferutils/plugins/iosxr/fileutils.py, line 20) always returns None:
This is causing copy_to_device to always fail when run via pyats clean (output from a sample device):
I'd recommend correcting this by removing lines 1221-1222 of genielibs/pkgs/clean-pkg/src/genie/libs/clean/stages/stages.py:
As the task will fail when the copy fails, as device.api.copy_to_device will propagate an Exception if the copy operation fails.