Ejemplo n.º 1
0
 def _send_file(self, filename, dest):
     self.fc = FileCopy(self.device, filename, dst=dest.split('/')[-1])
     try:
         if not self.fc.remote_file_exists():
             self.fc.send()
         elif not self.fc.file_already_exists():
             self.fc.send()
     except NXOSFileTransferError as fte:
         raise ReplaceConfigException(fte.message)
Ejemplo n.º 2
0
 def _send_file(self, filename, dest):
     self.fc = FileCopy(self.device, filename, dst=dest.split('/')[-1])
     try:
         if not self.fc.remote_file_exists():
             self.fc.send()
         elif not self.fc.file_already_exists():
             commands = [
                 'terminal dont-ask', 'delete {0}'.format(self.fc.dst)
             ]
             self.device.config_list(commands)
             self.fc.send()
     except NXOSFileTransferError as fte:
         raise ReplaceConfigException(fte.message)
Ejemplo n.º 3
0
    def file_copy(self, src, dest=None, file_system='bootflash:'):
        """Send a local file to the device.

        Args:
            src (str): Path to the local file to send.

        Keyword Args:
            dest (str): The destination file path to be saved on remote flash.
                If none is supplied, the implementing class should use the basename
                of the source path.
            file_system (str): The file system for the
                remote fle. Defaults to bootflash:'.
        """
        fc = FileCopy(self, src, dst=dest, file_system=file_system)
        fc.send()
Ejemplo n.º 4
0
    def file_copy_remote_exists(self, src, dest=None, file_system='bootflash:'):
        """Check if a remote file exists. A remote file exists if it has the same name
        as supplied dest, and the same md5 hash as the source.

        Args:
            src (str): Path to local file to check.

        Keyword Args:
            dest (str): The destination file path to be saved on remote the remote device.
                If none is supplied, the implementing class should use the basename
                of the source path.
            file_system (str): The file system for the
                remote file. Defaults to 'bootflash:'.

        Returns:
            True if the remote file exists, False if it doesn't.
        """
        fc = FileCopy(self, src, dst=dest, file_system=file_system)
        if fc.file_already_exists():
            return True
        return False