mirror of
https://github.com/ceph/ceph
synced 2025-01-29 14:34:40 +00:00
FIx mktemp dir and redundant Paramiko connecting.
Use previously initialized connection for sftp_get calls. Use local directory for tarball temp file location.
This commit is contained in:
parent
36b07b8aee
commit
8bed6ab625
@ -625,7 +625,7 @@ def pull_directory(remote, remotedir, localdir):
|
||||
remote.shortname, remotedir, localdir)
|
||||
if not os.path.exists(localdir):
|
||||
os.mkdir(localdir)
|
||||
_, local_tarfile = tempfile.mkstemp()
|
||||
_, local_tarfile = tempfile.mkstemp(dir=localdir)
|
||||
remote.get_tar(remotedir, local_tarfile, sudo=True)
|
||||
with open(local_tarfile, 'r+') as fb1:
|
||||
tar = tarfile.open(mode='r|', fileobj=fb1)
|
||||
|
@ -73,10 +73,6 @@ class Remote(object):
|
||||
def hostname(self):
|
||||
return self.name.split('@')[1]
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return self.name.split('@')[0]
|
||||
|
||||
@property
|
||||
def is_online(self):
|
||||
if self.ssh is None:
|
||||
@ -159,11 +155,7 @@ class Remote(object):
|
||||
return result
|
||||
|
||||
def _sftp_copy_file(self, file_path, to_path):
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
client.load_system_host_keys()
|
||||
client.connect(self.hostname, username=self.username)
|
||||
sftp = client.open_sftp()
|
||||
sftp = self.ssh.open_sftp()
|
||||
sftp.get(file_path, to_path)
|
||||
|
||||
def remove(self, path):
|
||||
|
Loading…
Reference in New Issue
Block a user