def copy(self, context, source_object, destination_object): data = { 'host_src': source_object.host, 'path_src': source_object.path, 'host_dst': destination_object.host, 'path_dst': destination_object.path } try: copier = base.get_copier(context.src_cloud, context.dst_cloud, data) copier.transfer(data) except (base.FileCopyError, base.CopierCannotBeUsed, base.CopierNotFound) as e: msg = ("Copying file from {src_host}@{src_file} to " "{dst_host}@{dst_file}, error: {err}").format( src_host=source_object.host, src_file=source_object.path, dst_host=destination_object.host, dst_file=destination_object.path, err=e.message) raise CopyFailed(msg)
def run_transfer(self, src, dst): """Run repeating remote commmand. :return: True on success (or False otherwise) """ data = {'host_src': self.clouds[SRC][CFG].get(HOST), 'path_src': src, 'host_dst': self.clouds[DST][CFG].get(HOST), 'path_dst': os.path.join(dst, os.path.basename(src)), 'gateway': self.clouds[SRC][CFG].get(SSH_HOST)} copier = base.get_copier(self.clouds[SRC][CLOUD], self.clouds[DST][CLOUD], data) try: copier.transfer(data) return True except (remote_runner.RemoteExecutionError, local.LocalExecutionFailed)as e: LOG.debug(e, exc_info=True) LOG.warning("Failed copying to %s from %s", dst, src) return False
def run_transfer(self, src, dst): """Run repeating remote commmand. :return: True on success (or False otherwise) """ data = { 'host_src': self.clouds[SRC][CFG].get(HOST), 'path_src': src, 'host_dst': self.clouds[DST][CFG].get(HOST), 'path_dst': os.path.join(dst, os.path.basename(src)), 'gateway': self.clouds[SRC][CFG].get(SSH_HOST) } copier = base.get_copier(self.clouds[SRC][CLOUD], self.clouds[DST][CLOUD], data) try: copier.transfer(data) return True except (remote_runner.RemoteExecutionError, local.LocalExecutionFailed) as e: LOG.debug(e, exc_info=True) LOG.warning("Failed copying to %s from %s", dst, src) return False
def get_copier(self, name): self.cfg.set_override('copy_backend', name, 'migrate') return base.get_copier('fake_src_cloud', 'fake_dst_cloud', {'host_src': 'fake_host_src', 'host_dst': 'fake_host_dst'})