Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Implement file_copy #212

Open
ktbyers opened this issue Feb 15, 2017 · 1 comment
Open

Implement file_copy #212

ktbyers opened this issue Feb 15, 2017 · 1 comment
Assignees
Milestone

Comments

@ktbyers
Copy link
Contributor

ktbyers commented Feb 15, 2017

Implementation of file_copy operations into NAPALM.

Work on this using file_copy branch

I think we should do a POC using two dissimilar platforms like IOS and Junos (also maybe NXOS)

@ktbyers ktbyers assigned ktbyers and unassigned ktbyers Feb 15, 2017
@ktbyers
Copy link
Contributor Author

ktbyers commented Feb 15, 2017

Definition of methods (work in progress):

I view the higher level operations we want initially is a get_file and a put_file. The long term goal probably being an abstraction that lets you relatively easily do an OS upgrade.

We should also (maybe) think about making the base class transport method generic (i.e. not hard-code it to Secure Copy so in the long run we could support HTTPS file transfers, other file transfer methods).

class BaseFileCopy(object):

    def __init__(self, napalm_conn, source_file, dest_file, 
                       direction='put', file_system=None):
        raise NotImplementedError

    def __enter__(self):
        raise NotImplementedError

    def __exit__(self):
        raise NotImplementedError

    def _connect(self):
        raise NotImplementedError

    def _disconnect(self):
        raise NotImplementedError

    def get_file(self):
        raise NotImplementedError

    def put_file(self):
        raise NotImplementedError

    def _remote_md5(self):
        raise NotImplementedError

    def _local_md5(self):
        raise NotImplementedError

    def _compare_md5(self):
        raise NotImplementedError

    def _remote_space_available(self):
        raise NotImplementedError

    def _local_space_available(self):
        raise NotImplementedError

    def _verify_space_available(self):
        raise NotImplementedError

    def _check_file_exists(self):
        raise NotImplementedError

    def _remote_file_size(self):
        raise NotImplementedError

    def _local_file_size(self):
        raise NotImplementedError

Each NAPALM driver that implements this, must have a FileCopy class that it inherits from BaseFileCopy. The arguments of the class must be identical to the signature in BaseFileCopy.

All the methods are optional in the child driver except for:

__enter__           # Must support a context manager
__exit__              # Must support a context manager
get_file
put_file

put_file() will transfer a file from the control machine to the remote network device. It will do this in an indempotent manner (i.e. it will check if the file already exists and has the right MD5 hash). The put_file operation will also attempt to verify whether there is sufficient space available on the remote device.

put_file should generate FileTransferException if direction not set to 'put'

Failure to transfer the file will result in a FileTransferException

get_file() will transfer a file from the remote network device to the control machine once again in an idempotent manner. The get_file operation will also attempt to verify there is sufficient space available on the local file system for the transfer.

get_file should generate FileTransferException if direction not set to 'get'

@mirceaulinic mirceaulinic added this to the APPROVED milestone Feb 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants