Skip to content

Commit

Permalink
Fix issues with 'recurse' option to copy-to and copy from (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
erl-hpe authored Jun 11, 2024
1 parent 1d3f1d7 commit e84d8b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
12 changes: 11 additions & 1 deletion vtds_provider_gcp/api_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ def copy_from(
passed to subprocess.Popen() or simply passed on to
subprocess.Popen() as keyword arguments.
If the 'recurse' option is True and the local file is a
directory, the directory and all of its descendants will be
copied.
If the 'logfiles' argument is provided, it contains a two
element tuple telling run_command where to put standard output
and standard error logging for the copy respectively.
Expand Down Expand Up @@ -340,7 +344,9 @@ class BladeSSHConnectionSet(BladeConnectionSet, metaclass=ABCMeta):
"""
@abstractmethod
def copy_to(self, source, destination, logname=None, blade_type=None):
def copy_to(
self, source, destination, recurse=False, logname=None, blade_type=None
):
"""Copy the file at a path on the local machine ('source') to
a path ('dest') on all of the selected blades (based on
'blade_type'). If 'blade_type is not specified or None, copy
Expand All @@ -349,6 +355,10 @@ def copy_to(self, source, destination, logname=None, blade_type=None):
errors they produce to raise a ContextualError exception
describing the failures.
If the 'recurse' option is True and the local file is a
directory, the directory and all of its descendants will be
copied.
If the 'logname' argument is provided, use the string found
there to compose paths to two files, one that will contain the
standard output from the command and one that will contain the
Expand Down
15 changes: 11 additions & 4 deletions vtds_provider_gcp/private/api_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ def copy_to(
"""
logfiles = logfiles if logfiles is not None else (None, None)
recurse_option = ['--recurse'] if recurse else []
recurse_option = ['-r'] if recurse else []
cmd = [
'scp', '-i', self.private_key_path, *recurse_option, *self.options,
source,
Expand Down Expand Up @@ -730,7 +730,7 @@ def copy_from(
"""
logfiles = logfiles if logfiles is not None else (None, None)
recurse_option = ['--recurse'] if recurse else []
recurse_option = ['-r'] if recurse else []
cmd = [
'scp', '-i', self.private_key_path, *recurse_option, *self.options,
'root@%s:%s' % (self.loc_ip, destination),
Expand Down Expand Up @@ -821,7 +821,10 @@ def __init__(self, common, connections):
"""
PrivateBladeConnectionSet.__init__(self, common, connections)

def copy_to(self, source, destination, logname=None, blade_type=None):
def copy_to(
self, source, destination,
recurse=False, logname=None, blade_type=None
):
"""Copy the file at a path on the local machine ('source') to
a path ('dest') on all of the selected blades (based on
'blade_type'). If 'blade_type is not specified or None, copy
Expand All @@ -830,6 +833,10 @@ def copy_to(self, source, destination, logname=None, blade_type=None):
errors they produce to raise a ContextualError exception
describing the failures.
If the 'recurse' option is True and the local file is a
directory, the directory and all of its descendants will be
copied.
If the 'logname' argument is provided, use the string found
there to compose the 'logfiles' argument to be passed to each
copy operation.
Expand All @@ -849,7 +856,7 @@ def copy_to(self, source, destination, logname=None, blade_type=None):
wait_args_list = [
(
blade_connection.copy_to(
source, destination, False,
source, destination, recurse, False,
log_paths(
self.common.build_dir(),
"%s-%s" % (logname, blade_connection.blade_hostname())
Expand Down
2 changes: 1 addition & 1 deletion vtds_provider_gcp/private/private_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def open_safe(path, flags):
with open(
priv_key, mode='w', opener=open_safe, encoding='UTF-8'
) as priv_key_file:
priv_key_file.write(keys['private'])
priv_key_file.write("%s\n" % keys['private'])
return keys

def __add_ssh_key(self, blade_type, blade_config):
Expand Down

0 comments on commit e84d8b6

Please sign in to comment.