-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
netmiko_file_transfer failing on Cisco 4331 router #70
Comments
If I do a file_transfer with netmiko directly it works: from netmiko import ConnectHandler, file_transfer
device = {
"device_type": "cisco_ios",
"host": "192.168.254.40",
"username": "admin",
"password": "admin",
"fast_cli": True, # disable fast cli
"conn_timeout": 20,
"auth_timeout": 20,
"session_log": "scp-session.log",
}
src_file = "testfile.txt" # file on local machine
dest_file = "testfile.txt" # file to put on remote device (usually identical to src_file)
with ConnectHandler(**device) as ssh_conn:
print(f"Connected to {ssh_conn.host}:{ssh_conn.port}")
print(
f"Transferring {src_file} to flash:{dest_file} for {ssh_conn.host}, please wait..."
)
scp_transfer = file_transfer(
ssh_conn,
source_file=src_file,
dest_file=dest_file,
file_system="flash:",
overwrite_file=True,
verify_file=True,
)
print(scp_transfer) |
I tried to manually replicate some of the logic from netmiko_file_transfer so I could compare the task object to make sure the inputs were the same. I modified the net_connect object to make all the attributes match the known good file transfer that used netmiko directly. Here's the modifications I made to ensure the task object and file_transfer arguments matched: def my_file_transfer(task, source_file, dest_file, direction, file_system, overwrite_file, verify_file, socket_timeout, disable_md5, progress):
net_connect = task.host.get_connection(CONNECTION_NAME, task.nornir.config)
net_connect.ssh_config_file = None
net_connect.secret = ""
net_connect.fast_cli = True
net_connect.global_delay_factor = 0.1
net_connect.conn_timeout = 10
print("******************* DEBUG *********************")
print(net_connect.__dict__)
print("***********************************************")
return file_transfer(
net_connect,
source_file=source_file,
dest_file=dest_file,
file_system="bootflash:",
overwrite_file=True,
verify_file=True,
socket_timeout=30
)
result = nornir_client.run(
task = my_file_transfer,
source_file = self.file_name,
dest_file = self.file_name,
direction = "put",
file_system="bootflash:",
overwrite_file=True,
verify_file=False,
socket_timeout=30,
disable_md5=True,
progress=progress_bar,
) For comparison, here's what the debugs look like from the working job that uses netmiko directly:
|
Well, I'm not sure what happened, I re-factored my code and in so doing re-wrote the file transfer from scratch slightly modified, and it's working now: image_transfer = self.nornir_client.run(
task = netmiko_file_transfer,
source_file = str(self.target_image),
dest_file = str(self.target_image),
) The only difference really is the source and destination file variables are just the file name, not a complete path like I was using before, and I removed the direction argument. I'll leave it open in case you want to investigate the previous state but if not go ahead and close. Thanks. |
Not sure if I'm doing something wrong or if this is a bug:
I'm getting an error trying to do a netmiko_file_transfer to a Cisco 4331 running IOS-XE 3.16.05.s.
Tested on python 3.9.18 & 3.11.7.
Using cisco_ios device type.
Here are the python package versions:
netmiko==4.3.0
netutils==1.6.0
nornir==3.4.1
nornir-jinja2==0.2.0
nornir-napalm==0.4.0
nornir-nautobot==3.0.0
nornir-netmiko==1.0.1
nornir-utils==0.2.0
paramiko==3.3.1
scp==0.14.5
I'm using the Nornir Nautobot plugin in a Nautobot job. The job looks like this in part:
When I run the job (python logging enabled for "paramiko" & "nornir_netmiko") my docker compose logs show:
The text was updated successfully, but these errors were encountered: