CiscoTestAutomation / genielibs

genie.libs contains libraries for configuring, retrieving and testing topologies
Apache License 2.0
107 stars 53 forks source link

Fail Copy_To_Device cleaner via FTP on iOS XR #152

Open widadzakaria opened 7 months ago

widadzakaria commented 7 months ago

Hi,

When I try to copy a file from a Server to an iOS XR router (ASR9K) using the copy_to_device cleaner and the FTP protocole, the command executed in the CLI has this format : copy ftp://[Username]:[Password]@[Server-IP]//[File_Directory] [Destination_Directory_on_Router] .

The problem is that the router ask again the : Address or name of remote host, Source Username, Source password, Destination FIlename... so the new format 'generated' by the router add again the username and the password... So the command become : ftp://[Username]:*@[Server-IP]/%2F[Username]:[Password]@[Server-IP]//[File_Directory] [Destination_Directory_on_Router]. So the copy fails with this error : %GENIE-ERROR: ('Command execution failed', SubCommandFailure('sub_command failure, patterns matched in the output:'.....

Actually, the command that has to be executed on an iOS XR router has to be : copy ftp://[Server-IP]//[File_Directory] [Destination_Directory_on_Router], so when the router ask for the username and password, the command that it generates is the good one .

Here is an example of the clean.yaml:

cleaners:
    PyatsDeviceClean:
        module: genie.libs.clean
        devices: [R1]

devices:
    R1:
        connect:

        copy_to_device:
            origin:
                hostname: Server
                files:
                    - [File_Directory] 
            destination:
                [Destination_Directory_on_Router]
            protocol: ftp #it works using tftp
        order:
        - connect
        - copy_to_device

Thanks for the help :)

widadzakaria commented 7 months ago

Copy of : https://github.com/CiscoTestAutomation/genieparser/issues/819

SohanTirpude commented 7 months ago

Hello @widadzakaria,

Kindly provide the complete output of copy_to_device with debug set to True in testbed. If you don't know how to set debug to True, then in testbed, under device, under connections, there will be a defaults, inside of that under line class: unicon.Unicon you can place line debug: True

connections:
  defaults:
    class: unicon.Unicon
    debug: True   
widadzakaria commented 7 months ago

``Hi @SohanTirpude and @ParimiNeeraja

Thanks for taking car of my issue !

Here is the output of the copy_to_device, step 6, with debug on:

2024-02-07T13:30:11: %AETEST-INFO: +..............................................................................+
2024-02-07T13:30:11: %AETEST-INFO: :    Starting STEP 6: Copying image file /IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.    :
2024-02-07T13:30:11: %AETEST-INFO: :    All-SMUs.20230501.tar to device Router1 harddisk:/tmp-ALL-v7.4.2     :
2024-02-07T13:30:11: %AETEST-INFO: +..............................................................................+

2024-02-07 13:30:11,810: %UNICON-DEBUG: >>> Unicon Sending (target=Router1):: ''

2024-02-07 13:30:11,815: %UNICON-INFO: +++ Router1 with via 'cli': executing command 'copy ftp://username:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar' +++

2024-02-07 13:30:11,815: %UNICON-DEBUG: >>> Unicon Sending (target=Router1):: 'copy ftp://username:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r'
copy ftp://username:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar
Wed Feb  7 13:30:11.900 EST
Address or name of remote host [RemoteHost]?

2024-02-07 13:30:12,673: %UNICON-DEBUG: <<< Unicon Got (target=Router1):: 'copy ftp://username:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\rWed Feb  7 13:30:11.900 EST\r\nAddress or name of remote host [RemoteHost]?'

2024-02-07 13:30:12,673: %UNICON-DEBUG: *** Pattern List (target=Router1):: 

2024-02-07 13:30:12,674: %UNICON-DEBUG:         '^.*\\[confirm\\]\\s*[\\(\\[]y/n[\\]\\)].*$'

2024-02-07 13:30:12,674: %UNICON-DEBUG:         '^.*(?<!Abort Copy\\? )\\[confirm\\].*$'

2024-02-07 13:30:12,674: %UNICON-DEBUG:         '^.*\\[yes[/,][Nn][Oo]\\]\\s?:?\\s*$'

2024-02-07 13:30:12,674: %UNICON-DEBUG:         '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying|audit: kauditd hold queue overflow).*$'

2024-02-07 13:30:12,675: %UNICON-DEBUG:         'Do you wish to proceed?.*$'

2024-02-07 13:30:12,675: %UNICON-DEBUG:         "\\[confirm( with only 'y' or 'n')?\\]\\s*\\[y/n\\].*$"

2024-02-07 13:30:12,675: %UNICON-DEBUG:         'Address or name of remote host.*$'

2024-02-07 13:30:12,675: %UNICON-DEBUG:         'Destination filename.*$'

2024-02-07 13:30:12,676: %UNICON-DEBUG:         'Abort Copy\\? \\[confirm\\]\\s*$'

2024-02-07 13:30:12,676: %UNICON-DEBUG:         '(?<!Abort Copy\\? )\\[confirm\\]\\s*$'

2024-02-07 13:30:12,676: %UNICON-DEBUG:         'Are you sure you want to continue connecting.*$'

2024-02-07 13:30:12,676: %UNICON-DEBUG:         'Destination username.*$'

2024-02-07 13:30:12,677: %UNICON-DEBUG:         'Destination password.*$'

2024-02-07 13:30:12,677: %UNICON-DEBUG:         '.*[D|d]estination file *name.*$'

2024-02-07 13:30:12,677: %UNICON-DEBUG:         'Enter username:\\s*$'

2024-02-07 13:30:12,677: %UNICON-DEBUG:         '.*[P|p]assword:\\s*$'

2024-02-07 13:30:12,678: %UNICON-DEBUG:         '[P|p]assword for .*$'

2024-02-07 13:30:12,678: %UNICON-DEBUG:         'Do you want to delete.*$'

2024-02-07 13:30:12,678: %UNICON-DEBUG:         'Host name or IP address.*$'

2024-02-07 13:30:12,678: %UNICON-DEBUG:         'Delete filename.*$'

2024-02-07 13:30:12,679: %UNICON-DEBUG:         'Source username.*$'

2024-02-07 13:30:12,679: %UNICON-DEBUG:         'Source filename.*$'

2024-02-07 13:30:12,679: %UNICON-DEBUG:         ' *[O|o]verwrite.*continu.*$'

2024-02-07 13:30:12,679: %UNICON-DEBUG:         '.*Do you want to (overwrite|overwritte|overwrit).*$'

2024-02-07 13:30:12,679: %UNICON-DEBUG:         'Enter vrf.*$'

2024-02-07 13:30:12,680: %UNICON-DEBUG:         '.*This is a directory. +Do you want to continue.*$'

2024-02-07 13:30:12,680: %UNICON-DEBUG:         '^.*--\\s?[Mm]ore\\s?--.*$'

2024-02-07 13:30:12,680: %UNICON-DEBUG:         '^(.*?)RP/\\w+(/\\S+)?/\\S+\\d+:(Router1|ios|xr)\\s?#\\s?$'

2024-02-07 13:30:12,680: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)\\s?#\\s?$'

2024-02-07 13:30:12,681: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)#\\s?$'

2024-02-07 13:30:12,681: %UNICON-DEBUG:         '^(.*?)(?:\\[(xr-vm_)?nodeD?\\d_(?:(?:RS?P|CB)[01]|[\\d+])_CPU\\d:(.*?)\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,681: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\s?#\\s?$|RP/\\S+\\(admin\\)\\s?#\\s?)$'

2024-02-07 13:30:12,681: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\(config.*\\)\\s?#\\s?|RP/\\S+\\(admin-config(\\S+)?\\)\\s?#\\s?)$'

2024-02-07 13:30:12,682: %UNICON-DEBUG:         '^(.*?)(?:\\[sysadmin-vm:0_.*:([\\s\\S]+)?\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,682: %UNICON-DEBUG: 

2024-02-07 13:30:12,682: %UNICON-DEBUG: *** Pattern Matched (target=Router1):: 'Address or name of remote host.*$'

2024-02-07 13:30:12,683: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=1, mode_name='search only last line'>

2024-02-07 13:30:12,683: %UNICON-DEBUG: 

2024-02-07 13:30:12,683: %UNICON-DEBUG: Statement matched: '[pattern='Address or name of remote host.*$', action=sendline, args={'key': ''}, loop_continue=True, continue_timer=False, trim_buffer=True]'

2024-02-07 13:30:12,683: %UNICON-DEBUG: >>> Unicon Sending (target=Router1):: '\r'

Source username: [anonymous]?

2024-02-07 13:30:12,728: %UNICON-DEBUG: <<< Unicon Got (target=Router1):: '\r\n\rSource username: [anonymous]?'

2024-02-07 13:30:12,729: %UNICON-DEBUG: *** Pattern List (target=Router1):: 

2024-02-07 13:30:12,729: %UNICON-DEBUG:         '^.*\\[confirm\\]\\s*[\\(\\[]y/n[\\]\\)].*$'

2024-02-07 13:30:12,729: %UNICON-DEBUG:         '^.*(?<!Abort Copy\\? )\\[confirm\\].*$'

2024-02-07 13:30:12,729: %UNICON-DEBUG:         '^.*\\[yes[/,][Nn][Oo]\\]\\s?:?\\s*$'

2024-02-07 13:30:12,730: %UNICON-DEBUG:         '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying|audit: kauditd hold queue overflow).*$'

2024-02-07 13:30:12,730: %UNICON-DEBUG:         'Do you wish to proceed?.*$'

2024-02-07 13:30:12,730: %UNICON-DEBUG:         "\\[confirm( with only 'y' or 'n')?\\]\\s*\\[y/n\\].*$"

2024-02-07 13:30:12,730: %UNICON-DEBUG:         'Address or name of remote host.*$'

2024-02-07 13:30:12,731: %UNICON-DEBUG:         'Destination filename.*$'

2024-02-07 13:30:12,731: %UNICON-DEBUG:         'Abort Copy\\? \\[confirm\\]\\s*$'

2024-02-07 13:30:12,731: %UNICON-DEBUG:         '(?<!Abort Copy\\? )\\[confirm\\]\\s*$'

2024-02-07 13:30:12,732: %UNICON-DEBUG:         'Are you sure you want to continue connecting.*$'

2024-02-07 13:30:12,732: %UNICON-DEBUG:         'Destination username.*$'

2024-02-07 13:30:12,732: %UNICON-DEBUG:         'Destination password.*$'

2024-02-07 13:30:12,732: %UNICON-DEBUG:         '.*[D|d]estination file *name.*$'

2024-02-07 13:30:12,733: %UNICON-DEBUG:         'Enter username:\\s*$'

2024-02-07 13:30:12,733: %UNICON-DEBUG:         '.*[P|p]assword:\\s*$'

2024-02-07 13:30:12,733: %UNICON-DEBUG:         '[P|p]assword for .*$'

2024-02-07 13:30:12,733: %UNICON-DEBUG:         'Do you want to delete.*$'

2024-02-07 13:30:12,733: %UNICON-DEBUG:         'Host name or IP address.*$'

2024-02-07 13:30:12,734: %UNICON-DEBUG:         'Delete filename.*$'

2024-02-07 13:30:12,734: %UNICON-DEBUG:         'Source username.*$'

2024-02-07 13:30:12,734: %UNICON-DEBUG:         'Source filename.*$'

2024-02-07 13:30:12,735: %UNICON-DEBUG:         ' *[O|o]verwrite.*continu.*$'

2024-02-07 13:30:12,735: %UNICON-DEBUG:         '.*Do you want to (overwrite|overwritte|overwrit).*$'

2024-02-07 13:30:12,735: %UNICON-DEBUG:         'Enter vrf.*$'

2024-02-07 13:30:12,736: %UNICON-DEBUG:         '.*This is a directory. +Do you want to continue.*$'

2024-02-07 13:30:12,736: %UNICON-DEBUG:         '^.*--\\s?[Mm]ore\\s?--.*$'

2024-02-07 13:30:12,736: %UNICON-DEBUG:         '^(.*?)RP/\\w+(/\\S+)?/\\S+\\d+:(Router1|ios|xr)\\s?#\\s?$'

2024-02-07 13:30:12,736: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)\\s?#\\s?$'

2024-02-07 13:30:12,736: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)#\\s?$'

2024-02-07 13:30:12,737: %UNICON-DEBUG:         '^(.*?)(?:\\[(xr-vm_)?nodeD?\\d_(?:(?:RS?P|CB)[01]|[\\d+])_CPU\\d:(.*?)\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,737: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\s?#\\s?$|RP/\\S+\\(admin\\)\\s?#\\s?)$'

2024-02-07 13:30:12,737: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\(config.*\\)\\s?#\\s?|RP/\\S+\\(admin-config(\\S+)?\\)\\s?#\\s?)$'

2024-02-07 13:30:12,737: %UNICON-DEBUG:         '^(.*?)(?:\\[sysadmin-vm:0_.*:([\\s\\S]+)?\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,737: %UNICON-DEBUG: 

2024-02-07 13:30:12,737: %UNICON-DEBUG: *** Pattern Matched (target=Router1):: 'Source username.*$'

2024-02-07 13:30:12,737: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=1, mode_name='search only last line'>

2024-02-07 13:30:12,737: %UNICON-DEBUG: 

2024-02-07 13:30:12,738: %UNICON-DEBUG: Statement matched: '[pattern='Source username.*$', action=sendline, args={'key': 'username'}, loop_continue=True, continue_timer=False, trim_buffer=True]'

2024-02-07 13:30:12,738: %UNICON-DEBUG: >>> Unicon Sending (target=Router1):: 'username\r'
username
Source password: 

2024-02-07 13:30:12,740: %UNICON-DEBUG: <<< Unicon Got (target=Router1):: 'username\r\n\rSource password: '

2024-02-07 13:30:12,740: %UNICON-DEBUG: *** Pattern List (target=Router1):: 

2024-02-07 13:30:12,740: %UNICON-DEBUG:         '^.*\\[confirm\\]\\s*[\\(\\[]y/n[\\]\\)].*$'

2024-02-07 13:30:12,741: %UNICON-DEBUG:         '^.*(?<!Abort Copy\\? )\\[confirm\\].*$'

2024-02-07 13:30:12,741: %UNICON-DEBUG:         '^.*\\[yes[/,][Nn][Oo]\\]\\s?:?\\s*$'

2024-02-07 13:30:12,741: %UNICON-DEBUG:         '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying|audit: kauditd hold queue overflow).*$'

2024-02-07 13:30:12,741: %UNICON-DEBUG:         'Do you wish to proceed?.*$'

2024-02-07 13:30:12,741: %UNICON-DEBUG:         "\\[confirm( with only 'y' or 'n')?\\]\\s*\\[y/n\\].*$"

2024-02-07 13:30:12,741: %UNICON-DEBUG:         'Address or name of remote host.*$'

2024-02-07 13:30:12,741: %UNICON-DEBUG:         'Destination filename.*$'

2024-02-07 13:30:12,741: %UNICON-DEBUG:         'Abort Copy\\? \\[confirm\\]\\s*$'

2024-02-07 13:30:12,742: %UNICON-DEBUG:         '(?<!Abort Copy\\? )\\[confirm\\]\\s*$'

2024-02-07 13:30:12,742: %UNICON-DEBUG:         'Are you sure you want to continue connecting.*$'

2024-02-07 13:30:12,742: %UNICON-DEBUG:         'Destination username.*$'

2024-02-07 13:30:12,742: %UNICON-DEBUG:         'Destination password.*$'

2024-02-07 13:30:12,742: %UNICON-DEBUG:         '.*[D|d]estination file *name.*$'

2024-02-07 13:30:12,742: %UNICON-DEBUG:         'Enter username:\\s*$'

2024-02-07 13:30:12,742: %UNICON-DEBUG:         '.*[P|p]assword:\\s*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         '[P|p]assword for .*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         'Do you want to delete.*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         'Host name or IP address.*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         'Delete filename.*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         'Source username.*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         'Source filename.*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         ' *[O|o]verwrite.*continu.*$'

2024-02-07 13:30:12,743: %UNICON-DEBUG:         '.*Do you want to (overwrite|overwritte|overwrit).*$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         'Enter vrf.*$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         '.*This is a directory. +Do you want to continue.*$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         '^.*--\\s?[Mm]ore\\s?--.*$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         '^(.*?)RP/\\w+(/\\S+)?/\\S+\\d+:(Router1|ios|xr)\\s?#\\s?$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)\\s?#\\s?$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)#\\s?$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         '^(.*?)(?:\\[(xr-vm_)?nodeD?\\d_(?:(?:RS?P|CB)[01]|[\\d+])_CPU\\d:(.*?)\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,744: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\s?#\\s?$|RP/\\S+\\(admin\\)\\s?#\\s?)$'

2024-02-07 13:30:12,745: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\(config.*\\)\\s?#\\s?|RP/\\S+\\(admin-config(\\S+)?\\)\\s?#\\s?)$'

2024-02-07 13:30:12,745: %UNICON-DEBUG:         '^(.*?)(?:\\[sysadmin-vm:0_.*:([\\s\\S]+)?\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,745: %UNICON-DEBUG: 

2024-02-07 13:30:12,745: %UNICON-DEBUG: *** Pattern Matched (target=Router1):: '.*[P|p]assword:\\s*$'

2024-02-07 13:30:12,745: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=1, mode_name='search only last line'>

2024-02-07 13:30:12,745: %UNICON-DEBUG: 

2024-02-07 13:30:12,745: %UNICON-DEBUG: Statement matched: '[pattern='.*[P|p]assword:\s*$', action=sendline, args={'key': 'Password'}, loop_continue=True, continue_timer=False, trim_buffer=True]'

2024-02-07 13:30:12,745: %UNICON-DEBUG: >>> Unicon Sending (target=Router1):: 'Password\r'

Destination filename [/harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar]?

2024-02-07 13:30:12,748: %UNICON-DEBUG: <<< Unicon Got (target=Router1):: '\r\nDestination filename [/harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar]?'

2024-02-07 13:30:12,748: %UNICON-DEBUG: *** Pattern List (target=Router1):: 

2024-02-07 13:30:12,749: %UNICON-DEBUG:         '^.*\\[confirm\\]\\s*[\\(\\[]y/n[\\]\\)].*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         '^.*(?<!Abort Copy\\? )\\[confirm\\].*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         '^.*\\[yes[/,][Nn][Oo]\\]\\s?:?\\s*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying|audit: kauditd hold queue overflow).*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         'Do you wish to proceed?.*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         "\\[confirm( with only 'y' or 'n')?\\]\\s*\\[y/n\\].*$"

2024-02-07 13:30:12,749: %UNICON-DEBUG:         'Address or name of remote host.*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         'Destination filename.*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         'Abort Copy\\? \\[confirm\\]\\s*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         '(?<!Abort Copy\\? )\\[confirm\\]\\s*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         'Are you sure you want to continue connecting.*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         'Destination username.*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         'Destination password.*$'

2024-02-07 13:30:12,749: %UNICON-DEBUG:         '.*[D|d]estination file *name.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         'Enter username:\\s*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         '.*[P|p]assword:\\s*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         '[P|p]assword for .*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         'Do you want to delete.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         'Host name or IP address.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         'Delete filename.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         'Source username.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         'Source filename.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         ' *[O|o]verwrite.*continu.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         '.*Do you want to (overwrite|overwritte|overwrit).*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         'Enter vrf.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         '.*This is a directory. +Do you want to continue.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         '^.*--\\s?[Mm]ore\\s?--.*$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         '^(.*?)RP/\\w+(/\\S+)?/\\S+\\d+:(Router1|ios|xr)\\s?#\\s?$'

2024-02-07 13:30:12,750: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)\\s?#\\s?$'

2024-02-07 13:30:12,751: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)#\\s?$'

2024-02-07 13:30:12,751: %UNICON-DEBUG:         '^(.*?)(?:\\[(xr-vm_)?nodeD?\\d_(?:(?:RS?P|CB)[01]|[\\d+])_CPU\\d:(.*?)\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,751: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\s?#\\s?$|RP/\\S+\\(admin\\)\\s?#\\s?)$'

2024-02-07 13:30:12,751: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\(config.*\\)\\s?#\\s?|RP/\\S+\\(admin-config(\\S+)?\\)\\s?#\\s?)$'

2024-02-07 13:30:12,751: %UNICON-DEBUG:         '^(.*?)(?:\\[sysadmin-vm:0_.*:([\\s\\S]+)?\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,751: %UNICON-DEBUG: 

2024-02-07 13:30:12,751: %UNICON-DEBUG: *** Pattern Matched (target=Router1):: 'Destination filename.*$'

2024-02-07 13:30:12,751: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=1, mode_name='search only last line'>

2024-02-07 13:30:12,751: %UNICON-DEBUG: 

2024-02-07 13:30:12,751: %UNICON-DEBUG: Statement matched: '[pattern='Destination filename.*$', action=sendline, args={'key': '/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar'}, loop_continue=True, continue_timer=False, trim_buffer=True]'

2024-02-07 13:30:12,751: %UNICON-DEBUG: >>> Unicon Sending (target=Router1):: '/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r'
/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar
Accessing ftp://username:*@RemoteHost/%2Fusername:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar

Error: Copy failed with error 'Invalid IP address'
RP/0/RP0/CPU0:Router1#

2024-02-07 13:30:12,796: %UNICON-DEBUG: <<< Unicon Got (target=Router1):: "/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\rAccessing ftp://username:*@RemoteHost/%2Fusername:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\r\nError: Copy failed with error 'Invalid IP address'\r\nRP/0/RP0/CPU0:Router1#"

2024-02-07 13:30:12,796: %UNICON-DEBUG: *** Pattern List (target=Router1):: 

2024-02-07 13:30:12,796: %UNICON-DEBUG:         '^.*\\[confirm\\]\\s*[\\(\\[]y/n[\\]\\)].*$'

2024-02-07 13:30:12,797: %UNICON-DEBUG:         '^.*(?<!Abort Copy\\? )\\[confirm\\].*$'

2024-02-07 13:30:12,797: %UNICON-DEBUG:         '^.*\\[yes[/,][Nn][Oo]\\]\\s?:?\\s*$'

2024-02-07 13:30:12,797: %UNICON-DEBUG:         '^.*?(%\\w+(-\\S+)?-\\d+-\\w+|Guestshell destroyed successfully|%Error opening tftp:\\/\\/255\\.255\\.255\\.255|Autoinstall trying|audit: kauditd hold queue overflow).*$'

2024-02-07 13:30:12,797: %UNICON-DEBUG:         'Do you wish to proceed?.*$'

2024-02-07 13:30:12,798: %UNICON-DEBUG:         "\\[confirm( with only 'y' or 'n')?\\]\\s*\\[y/n\\].*$"

2024-02-07 13:30:12,798: %UNICON-DEBUG:         'Address or name of remote host.*$'

2024-02-07 13:30:12,798: %UNICON-DEBUG:         'Destination filename.*$'

2024-02-07 13:30:12,798: %UNICON-DEBUG:         'Abort Copy\\? \\[confirm\\]\\s*$'

2024-02-07 13:30:12,799: %UNICON-DEBUG:         '(?<!Abort Copy\\? )\\[confirm\\]\\s*$'

2024-02-07 13:30:12,799: %UNICON-DEBUG:         'Are you sure you want to continue connecting.*$'

2024-02-07 13:30:12,800: %UNICON-DEBUG:         'Destination username.*$'

2024-02-07 13:30:12,800: %UNICON-DEBUG:         'Destination password.*$'

2024-02-07 13:30:12,800: %UNICON-DEBUG:         '.*[D|d]estination file *name.*$'

2024-02-07 13:30:12,801: %UNICON-DEBUG:         'Enter username:\\s*$'

2024-02-07 13:30:12,801: %UNICON-DEBUG:         '.*[P|p]assword:\\s*$'

2024-02-07 13:30:12,802: %UNICON-DEBUG:         '[P|p]assword for .*$'

2024-02-07 13:30:12,802: %UNICON-DEBUG:         'Do you want to delete.*$'

2024-02-07 13:30:12,802: %UNICON-DEBUG:         'Host name or IP address.*$'

2024-02-07 13:30:12,803: %UNICON-DEBUG:         'Delete filename.*$'

2024-02-07 13:30:12,803: %UNICON-DEBUG:         'Source username.*$'

2024-02-07 13:30:12,803: %UNICON-DEBUG:         'Source filename.*$'

2024-02-07 13:30:12,803: %UNICON-DEBUG:         ' *[O|o]verwrite.*continu.*$'

2024-02-07 13:30:12,804: %UNICON-DEBUG:         '.*Do you want to (overwrite|overwritte|overwrit).*$'

2024-02-07 13:30:12,804: %UNICON-DEBUG:         'Enter vrf.*$'

2024-02-07 13:30:12,804: %UNICON-DEBUG:         '.*This is a directory. +Do you want to continue.*$'

2024-02-07 13:30:12,804: %UNICON-DEBUG:         '^.*--\\s?[Mm]ore\\s?--.*$'

2024-02-07 13:30:12,804: %UNICON-DEBUG:         '^(.*?)RP/\\w+(/\\S+)?/\\S+\\d+:(Router1|ios|xr)\\s?#\\s?$'

2024-02-07 13:30:12,805: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)\\s?#\\s?$'

2024-02-07 13:30:12,805: %UNICON-DEBUG:         '^(.*?)RP/\\S+\\(config.*\\)#\\s?$'

2024-02-07 13:30:12,805: %UNICON-DEBUG:         '^(.*?)(?:\\[(xr-vm_)?nodeD?\\d_(?:(?:RS?P|CB)[01]|[\\d+])_CPU\\d:(.*?)\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,805: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\s?#\\s?$|RP/\\S+\\(admin\\)\\s?#\\s?)$'

2024-02-07 13:30:12,806: %UNICON-DEBUG:         '^(.*?)(?:sysadmin-vm:0_(.*)\\(config.*\\)\\s?#\\s?|RP/\\S+\\(admin-config(\\S+)?\\)\\s?#\\s?)$'

2024-02-07 13:30:12,806: %UNICON-DEBUG:         '^(.*?)(?:\\[sysadmin-vm:0_.*:([\\s\\S]+)?\\]\\s?\\$\\s?|[\\r\\n]+\\s?#\\s?)$'

2024-02-07 13:30:12,806: %UNICON-DEBUG: 

2024-02-07 13:30:12,807: %UNICON-DEBUG: *** Pattern Matched (target=Router1):: '^(.*?)RP/\\w+(/\\S+)?/\\S+\\d+:(Router1|ios|xr)\\s?#\\s?$'

2024-02-07 13:30:12,807: %UNICON-DEBUG: <unicon.eal.MatchMode mode_id=1, mode_name='search only last line'>

2024-02-07 13:30:12,807: %UNICON-DEBUG: *** Match Groups:: ('', '/RP0', 'Router1')

2024-02-07 13:30:12,807: %UNICON-DEBUG: Statement matched: '[pattern='^(.*?)RP/\w+(/\S+)?/\S+\d+:(Router1|ios|xr)\s?#\s?$', action=None, args=None, loop_continue=False, continue_timer=False, trim_buffer=True]'

2024-02-07 13:30:12,928: %UNICON-DEBUG: Statement matched: '[pattern='^(.*?)RP/\w+(/\S+)?/\S+\d+:(Router1|ios|xr)\s?#\s?$', action=None, args=None, loop_continue=False, continue_timer=False, trim_buffer=True]'
2024-02-07T13:30:12: %GENIE-INFO: Failed to copy file to device: ('Command execution failed', SubCommandFailure('sub_command failure, patterns matched in the output:', ['Error(?! opening tftp://255\\.255\\.255\\.255)', 'Copy failed'], 'service result', "copy ftp://username:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\rWed Feb  7 13:30:11.900 EST\r\nAddress or name of remote host [RemoteHost]?\r\n\rSource username: [anonymous]?username\r\n\rSource password: \r\nDestination filename [/harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar]?/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\rAccessing ftp://username:*@RemoteHost/%2Fusername:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\r\nError: Copy failed with error 'Invalid IP address'\r\nRP/0/RP0/CPU0:Router1#"))
2024-02-07T13:30:12: %GENIE-ERROR: ('Command execution failed', SubCommandFailure('sub_command failure, patterns matched in the output:', ['Error(?! opening tftp://255\\.255\\.255\\.255)', 'Copy failed'], 'service result', "copy ftp://username:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\rWed Feb  7 13:30:11.900 EST\r\nAddress or name of remote host [RemoteHost]?\r\n\rSource username: [anonymous]?username\r\n\rSource password: \r\nDestination filename [/harddisk:/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar]?/tmp-ALL-v7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\rAccessing ftp://username:*@RemoteHost/%2Fusername:Password@RemoteHost//IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar\r\n\r\nError: Copy failed with error 'Invalid IP address'\r\nRP/0/RP0/CPU0:Router1#"))
2024-02-07T13:30:12: %AETEST-ERROR: Failed reason: Failed to copy image '/IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar' to 'harddisk:/tmp-ALL-v7.4.2' on device 'Router1'

2024-02-07T13:30:12: %AETEST-INFO: The result of STEP 6: Copying image file /IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar to device Router1 harddisk:/tmp-ALL-v7.4.2 is => FAILED

Have a great day !

ParimiNeeraja commented 7 months ago

Hi widadzakaria,

Thanks for sharing the debug log, will check and update you.

ParimiNeeraja commented 6 months ago

Hi @widadzakaria ,

I checked in repo, in there it just passing username and password, there it was not changing the command. Please try to replicate this exactly steps in manual and share with us.

Thanks.

ParimiNeeraja commented 6 months ago

Hi @widadzakaria ,

Kindly let me know is there any update on this issue.

ParimiNeeraja commented 6 months ago

Hi @widadzakaria ,

Is any update on this issue. Kindly let us know.

widadzakaria commented 6 months ago

Hi @ParimiNeeraja,

I tried to use the copy_to_device() API to make thing a bit easier but still I have the same error when I'm using FTP. No issue using TFTP. Check the file for more info (Unicon Debug ON). copy_to_device-API.txt

Here is my testbed-file :

testbed:
  name : lab

  credentials:
    default:
      password: PASSWORD
      username: USERNAME
    enable:
      password: PASSWORD

  servers:
    CiscoConf:
      address: SERVER-IP
      credentials:
        default:
          username: SERVER-USERNAME
          password: SERVER-PASSWORD

devices:
  ROUTER
    connections:
      defaults:
        class: unicon.Unicon
        debug: True
      cli:
        ip: ROUTER-IP
        protocol: ssh
    os: iosxr
    type: iosxr

And here a example of my python script:

from genie.testbed import load
from genie.libs.sdk.apis.iosxr.utils import copy_to_device
from genie.libs.sdk.apis.iosxr.asr9k.get import get_software_version

#Connect to the Router

tb = load('/home/user/Project/yaml/lab.yaml')
dev = tb.devices['ROUTER']
dev.connect(log_stdout=True)

#show version

version = get_software_version(dev)

print(version)

#Copy from the server to the router

copy_to_device(dev, '/IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar', 'harddisk:tmp-ALL-v7.4.2-PyATS/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar', 'SERVER', 'ftp')
widadzakaria commented 6 months ago

Hi @ParimiNeeraja

An information that might help, to copy a file from a server to a router iOSXR version 6.x and lower (32 bits), we can use this command : copy ftp:// username : password @ hostname or ipaddress/directory-path/pie-name target-device [location {node-id | all}] But if the router is version 7.x and higher (64 bits), we cannot directly input the username and the password into the command, so the command becomes: copy ftp:// hostname or ipaddress/directory-path/pie-name target-device [location {node-id | all}] after that the router will ask for the username and password.

ParimiNeeraja commented 6 months ago

Hi @widadzakaria ,

Please do the above steps in manually to replicate this exactly steps, kindly do not run in any script.

widadzakaria commented 6 months ago

Hi @ParimiNeeraja,

Hope that help !

RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#show version 
Thu Feb 29 10:30:09.889 EST
Cisco IOS XR Software, Version 7.4.2
Copyright (c) 2013-2022 by Cisco Systems, Inc.

Build Information:
 Built By     : ingunawa
 Built On     : Wed Feb 16 04:59:15 PST 2022
 Built Host   : iox-ucs-068
 Workspace    : /auto/srcarchive15/prod/7.4.2/asr9k-x64/ws
 Version      : 7.4.2
 Location     : /opt/cisco/XR/packages/
 Label        : 7.4.2

cisco ASR9K () processor
System uptime is 22 weeks 1 day 20 hours 47 minutes

RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#dir harddisk:
Thu Feb 29 10:30:19.213 EST

Directory of harddisk:
 522242 drwxr-xr-x. 2     4096 Oct 24  2022 .mgr_cache
 913921 drwxr-xr-x. 4     4096 Feb 26 15:21 cisco_support
 783361 drwxr-xr-x. 2     4096 Oct 24  2022 .tmp_staging
 783362 drwxr-xr-x. 3     4096 Feb 26 14:11 mirror
 391683 drwxr-xr-x. 3     4096 Sep 26 14:44 .sppdc_new
1044481 drwxr-xr-x. 2     4096 Oct 24  2022 .tmp
1175041 drwxr-xr-x. 2     4096 Jan 27 13:40 .sppdc
 130561 drw-r--r--. 2     4096 Feb 26 14:30 tmp-ALL-v7.4.2-PyATS

23099260 kbytes total (21780972 kbytes free)
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#!! LET'S PUT THE USERNAME AND THE PASSWORD OF THE SERVER INTO THE COPY COMMAND
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#copy ftp://SERVER-USERNAME:SERVER-PASSWORD@SERVER-IP/IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2-PyATS/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.$
Thu Feb 29 10:32:07.938 EST
Address or name of remote host [SERVER-IP]?
Source username: [anonymous]?SERVER-USERNAME
Source password: 
Destination filename [/harddisk:/tmp-ALL-v7.4.2-PyATS/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar]?
Accessing ftp://SERVER-USERNAME:*@SERVER-IP/%2FSERVER-USERNAME:SERVER-PASSWORD@SERVER-IP/IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar

Error: Copy failed with error 'Invalid IP address'
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#!! THE COPY COMMAND WITHOUT THE USERNAME/PASSWORD SERVER
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#
RP/0/RP0/CPU0:ROUTER#copy ftp://SERVER-IP/IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar harddisk:/tmp-ALL-v7.4.2-PyATS/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar                    
Thu Feb 29 10:32:44.460 EST
Source username: [anonymous]?SERVER-USERNAME
Source password: 
Destination filename [/harddisk:/tmp-ALL-v7.4.2-PyATS/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar]?
Accessing ftp://SERVER-USERNAME:*@SERVER-IP/IOS-eXR/7.4.2/ASR9K.IOS-eXR7.4.2.All-SMUs.20230501.tar
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC....
ParimiNeeraja commented 6 months ago

Hi @widadzakaria ,

Thanks for the detailed information. As mentioned by you that in router version 6 this issue is not seen and the command it generated correctly by Unicon. But for router version 7 this command needs to be changed.

I will need to check with the team on how to handle such scenario because this is due to version mismatch this issue is seeing. Kindly give me some time. If needed any more help, I will let you know.

Thank you.

Neeraja1bala commented 3 months ago

Hello @widadzakaria ,

As you mentioned earlier this command , copy ftp:// hostname or ipaddress/directory-path/pie-name target-device [location {node-id | all}] is using for 7.x version, can you let me know is there any specific sub-version to use this command or for all with 7 version.

Neeraja1bala commented 3 months ago

Hello @widadzakaria ,

Kindly let me know the update router versions. Thanks.

widadzakaria commented 3 months ago

Hi @Neeraja1bala, Yes this command is used for all iOS XR version 7.x Thanks

Neeraja1bala commented 1 month ago

Hello @widadzakaria , Thanks for the update. We have added this issue in our backlog.