Skip to content
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

File Uploading #2

Open
itdependsnetworks opened this issue Oct 14, 2017 · 4 comments
Open

File Uploading #2

itdependsnetworks opened this issue Oct 14, 2017 · 4 comments

Comments

@itdependsnetworks
Copy link

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.

@itdependsnetworks
Copy link
Author

Any help is welcome.

@ktbyers
Copy link

ktbyers commented Oct 14, 2017

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.

@itdependsnetworks
Copy link
Author

@ktbyers I don't want to give you extra work, but also don't want to take credit for your work :)

https://github.com/napalm-automation/napalm-base/blob/abb9faab9c531f8b6ec88203c1ec41af217355b7/napalm_base/file_copy.py

Is this something that can be PR'd agains the re-unified branch? same on the IOS side.

@ktbyers
Copy link

ktbyers commented Nov 14, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants