Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cisco_ios = True
else:
cisco_ios = False
if not cisco_ios and inline_transfer:
raise ValueError("Inline Transfer only supported for Cisco IOS/Cisco IOS-XE")
scp_args = {
"ssh_conn": ssh_conn,
"source_file": source_file,
"dest_file": dest_file,
"direction": direction,
}
if file_system is not None:
scp_args["file_system"] = file_system
TransferClass = InLineTransfer if inline_transfer else FileTransfer
with TransferClass(**scp_args) as scp_transfer:
if scp_transfer.check_file_exists():
if overwrite_file:
if not disable_md5:
if scp_transfer.compare_md5():
return nottransferred_but_verified
else:
# File exists, you can overwrite it, MD5 is wrong (transfer file)
verifyspace_and_transferfile(scp_transfer)
if scp_transfer.compare_md5():
return transferred_and_verified
else:
raise ValueError(
"MD5 failure between source and destination files"
)
def _inline_tcl_xfer(
self, source_file=None, source_config=None, dest_file=None, file_system=None
):
"""
Use Netmiko InlineFileTransfer (TCL) to transfer file or config to remote device.
Return (status, msg)
status = boolean
msg = details on what happened
"""
if source_file:
return self._xfer_file(
source_file=source_file,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
if source_config:
return self._xfer_file(
source_config=source_config,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
raise ValueError("File source not specified for transfer.")
status = boolean
msg = details on what happened
"""
if source_file:
return self._xfer_file(
source_file=source_file,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
if source_config:
return self._xfer_file(
source_config=source_config,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
raise ValueError("File source not specified for transfer.")
def _inline_tcl_xfer(self, source_file=None, source_config=None, dest_file=None,
file_system=None):
"""
Use Netmiko InlineFileTransfer (TCL) to transfer file or config to remote device.
Return (status, msg)
status = boolean
msg = details on what happened
"""
if source_file:
return self._xfer_file(source_file=source_file, dest_file=dest_file,
file_system=file_system, TransferClass=InLineTransfer)
if source_config:
return self._xfer_file(source_config=source_config, dest_file=dest_file,
file_system=file_system, TransferClass=InLineTransfer)
raise ValueError("File source not specified for transfer.")
def _inline_tcl_xfer(self, source_file=None, source_config=None, dest_file=None,
file_system=None):
"""
Use Netmiko InlineFileTransfer (TCL) to transfer file or config to remote device.
Return (status, msg)
status = boolean
msg = details on what happened
"""
if source_file:
return self._xfer_file(source_file=source_file, dest_file=dest_file,
file_system=file_system, TransferClass=InLineTransfer)
if source_config:
return self._xfer_file(source_config=source_config, dest_file=dest_file,
file_system=file_system, TransferClass=InLineTransfer)
raise ValueError("File source not specified for transfer.")
def _inline_tcl_xfer(
self, source_file=None, source_config=None, dest_file=None, file_system=None
):
"""
Use Netmiko InlineFileTransfer (TCL) to transfer file or config to remote device.
Return (status, msg)
status = boolean
msg = details on what happened
"""
if source_file:
return self._xfer_file(
source_file=source_file,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
if source_config:
return self._xfer_file(
source_config=source_config,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
raise ValueError("File source not specified for transfer.")
status = boolean
msg = details on what happened
"""
if source_file:
return self._xfer_file(
source_file=source_file,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
if source_config:
return self._xfer_file(
source_config=source_config,
dest_file=dest_file,
file_system=file_system,
TransferClass=InLineTransfer,
)
raise ValueError("File source not specified for transfer.")
def _inline_tcl_xfer(self, source_file=None, source_config=None, dest_file=None,
file_system=None):
"""
Use Netmiko InlineFileTransfer (TCL) to transfer file or config to remote device.
Return (status, msg)
status = boolean
msg = details on what happened
"""
if source_file:
return self._xfer_file(source_file=source_file, dest_file=dest_file,
file_system=file_system, TransferClass=InLineTransfer)
if source_config:
return self._xfer_file(source_config=source_config, dest_file=dest_file,
file_system=file_system, TransferClass=InLineTransfer)
raise ValueError("File source not specified for transfer.")