netmiko
netmiko copied to clipboard
scp_handler.py process_md5() failed with linux ubuntu 22.04 lts
log:
{'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'}
Traceback (most recent call last):
File "/builds/infra/sw_dump/dump.py", line 35, in
i've checked the scp_handler.py file and modified process_md5() def :
def process_md5(md5_output: str, pattern: str = r"=\s+(\S+)") -> str:
"""
Process the string to retrieve the MD5 hash
Output from Cisco IOS (ASA is similar)
.MD5 of flash:file_name Done!
verify /md5 (flash:file_name) = 410db2a7015eaa42b1fe71f1bf3d59a2
"""
print(md5_output.split('\n'))
md5_output=md5_output.split('\n')[-1]
match = re.search(pattern, md5_output)
if match:
return match.group(1)
else:
raise ValueError(f"Invalid output from MD5 command: {md5_output}")
it seems some md5_output has a '\n' in begining(ubuntu22.04)
{'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400056.unf autobackup_7.2.94_20230514_2000_1684094400056.unf ['2674b3d0e1353125e6a0298024dddc37 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400056.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400016.unf autobackup_7.2.94_20230514_2000_1684094400016.unf ['1b738b8a69ab968caecbdad112f92058 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400016.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf autobackup_7.2.94_20230514_2000_1684094400030.unf ['122132d4a4b1b1f1f4ae727e7aea4ff0 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'}
/root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf autobackup_7.2.94_20230514_2000_1684094400030.unf ['', '4977085b132f104643c75695b8ba1af2 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400030.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400026.unf autobackup_7.2.94_20230514_2000_1684094400026.unf ['58fd1ca3ba475da91584efeaac636d3e /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400026.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400020.unf autobackup_7.2.94_20230514_2000_1684094400020.unf ['269953a481129a39ec5488ea2f7cfa32 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400020.unf'] {'device_type': 'linux', 'host': 'some_ip', 'username': 'root', 'use_keys': True, 'key_file': 'KEY', 'ssh_config_file': './ssh_config'} /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400012.unf autobackup_7.2.94_20230514_2000_1684094400012.unf ['b54d1d571d60b700a8c8218fd886ee29 /root/services/unifi/config/data/backup/autobackup/autobackup_7.2.94_20230514_2000_1684094400012.unf']