Open itdependsnetworks opened 7 years ago
Any help is welcome.
I think the SCP transfer mechanism and associated methods like MD5, space verification should probably be pushed into Netmiko. I restructured Netmiko 1.5.0 (Netmiko develop branch) to better accomplish this and did a very brief test on Juniper (at least for a put file).
I say this because this is inherently bound to SSH. Also the use of SCP extends beyond the NAPALM drivers.
So that is where I am probably going to work on this issue at.
I would probably then propose we make wrapper methods whereby NAPALM calls the underlying Netmiko methods for file transfer operations
...of course, people can do what they want, what they are interested in, but that is the direction I recently re-started working in.
@ktbyers I don't want to give you extra work, but also don't want to take credit for your work :)
Is this something that can be PR'd agains the re-unified branch? same on the IOS side.
@itdependsnetworks This is all essentially in Netmiko.
Netmiko has ios, asa, nxos support. I have some amount of support for Juniper and Arista (but need to do more for both of these).
So I think we should layer any NAPALM file transfer mechanisms on top of that driver.
Here are the methods in the Netmiko FileTransfer class:
def __init__(self, ssh_conn, source_file, dest_file, file_system=None, direction='put'):
def __enter__(self):
def __exit__(self, exc_type, exc_value, traceback):
def establish_scp_conn(self):
def close_scp_chan(self):
def remote_space_available(self, search_pattern=r"bytes total \((.*) bytes free\)"):
def local_space_available(self):
def verify_space_available(self, search_pattern=r"bytes total \((.*) bytes free\)"):
def check_file_exists(self, remote_cmd=""):
def remote_file_size(self, remote_cmd="", remote_file=None):
def file_md5(self, file_name):
def process_md5(md5_output, pattern=r"= (.*)"):
def compare_md5(self):
def remote_md5(self, base_cmd='verify /md5', remote_file=None):
def transfer_file(self):
def get_file(self):
def put_file(self):
def verify_file(self):
def enable_scp(self, cmd=None):
def disable_scp(self, cmd=None):
It has a device_type
dispatcher similar to ConnectHandler.
File Uploading
I worked on this last hackathon, but there was not a consensus on the methods. Since then @ktbyers has a demo here: https://github.com/ktbyers/napalm-ios/tree/file_copy
My plan for the hackathon is to finally work on this.