adds put_file and fetch_file implementations for cliconf plugin (#26728)
This commit is contained in:
parent
0b784c65b1
commit
41c1457823
1 changed files with 17 additions and 2 deletions
|
@ -27,6 +27,13 @@ from functools import wraps
|
|||
from ansible.errors import AnsibleError, AnsibleConnectionFailure
|
||||
from ansible.module_utils.six import with_metaclass
|
||||
|
||||
try:
|
||||
from scp import SCPClient
|
||||
HAS_SCP = True
|
||||
except ImportError:
|
||||
HAS_SCP = False
|
||||
|
||||
|
||||
try:
|
||||
from __main__ import display
|
||||
except ImportError:
|
||||
|
@ -181,8 +188,16 @@ class CliconfBase(with_metaclass(ABCMeta, object)):
|
|||
|
||||
def put_file(self, source, destination):
|
||||
"""Copies file over scp to remote device"""
|
||||
pass
|
||||
if not HAS_SCP:
|
||||
self._connection.internal_error("Required library scp is not installed. Please install it using `pip install scp`")
|
||||
ssh = self._connection._connect_uncached()
|
||||
with SCPClient(ssh.get_transport()) as scp:
|
||||
scp.put(source, destination)
|
||||
|
||||
def fetch_file(self, source, destination):
|
||||
"""Fetch file over scp from remote device"""
|
||||
pass
|
||||
if not HAS_SCP:
|
||||
self._connection.internal_error("Required library scp is not installed. Please install it using `pip install scp`")
|
||||
ssh = self._connection._connect_uncached()
|
||||
with SCPClient(ssh.get_transport()) as scp:
|
||||
scp.get(source, destination)
|
||||
|
|
Loading…
Reference in a new issue