def transfer_file_to_file(src_cloud, dst_cloud, host_src, host_dst, path_src, path_dst, cfg_migrate): # TODO: Delete after transport_db_via_ssh action rewriting LOG.debug("| | copy file") ssh_ip_src = src_cloud.getIpSsh() ssh_ip_dst = dst_cloud.getIpSsh() with settings(host_string=ssh_ip_src, connection_attempts=env.connection_attempts): with utils.forward_agent(cfg_migrate.key_filename): with utils.up_ssh_tunnel(host_dst, ssh_ip_dst, ssh_ip_src) as port: if cfg_migrate.file_compression == "dd": run(("ssh -oStrictHostKeyChecking=no %s 'dd bs=1M " + "if=%s' | ssh -oStrictHostKeyChecking=no " + "-p %s localhost 'dd bs=1M of=%s'") % (host_src, path_src, port, path_dst)) elif cfg_migrate.file_compression == "gzip": run(("ssh -oStrictHostKeyChecking=no " + "%s 'gzip -%s -c %s' " + "| ssh -oStrictHostKeyChecking=no -p %s localhost " + "'gunzip | dd bs=1M of=%s'") % (host_src, cfg_migrate.level_compression, path_src, port, path_dst))
def transfer_from_ceph_to_iscsi(cloud_src, cloud_dst, dst_host, dst_path, ceph_pool_src="volumes", name_file_src="volume-"): ssh_ip_src = cloud_src.getIpSsh() ssh_ip_dst = cloud_dst.getIpSsh() with settings(host_string=ssh_ip_src): with utils.forward_agent(env.key_filename): with utils.up_ssh_tunnel(dst_host, ssh_ip_dst) as port: run(("rbd export -p %s %s - | ssh -oStrictHostKeyChecking=no -p %s localhost " + "'dd bs=1M of=%s'") % (ceph_pool_src, name_file_src, port, dst_path))
def transfer(self, data): ssh_ip_src = self.src_cloud.getIpSsh() ssh_ip_dst = self.dst_cloud.getIpSsh() with utils.forward_agent(env.key_filename), utils.up_ssh_tunnel( data['host_dst'], ssh_ip_dst, ssh_ip_src) as port: dd = cmd_cfg.dd_cmd_of ssh_cmd = cmd_cfg.ssh_cmd_port rbd_export = rbd_util.RbdUtil.rbd_export_cmd ssh_dd = ssh_cmd(port, 'localhost', dd) process = rbd_export >> ssh_dd process = process(data['path_src'], '-', '1M', data['path_dst']) self.src_cloud.ssh_util.execute(process)
def transfer(self, data): ssh_ip_src = self.src_cloud.cloud_config.cloud.ssh_host ssh_ip_dst = self.dst_cloud.cloud_config.cloud.ssh_host with utils.forward_agent(env.key_filename), utils.up_ssh_tunnel( data['host_dst'], ssh_ip_dst, ssh_ip_src) as port: dd = cmd_cfg.dd_cmd_of ssh_cmd = cmd_cfg.ssh_cmd_port rbd_export = rbd_util.RbdUtil.rbd_export_cmd ssh_dd = ssh_cmd(port, 'localhost', dd) process = rbd_export >> ssh_dd process = process(data['path_src'], '-', '1M', data['path_dst']) self.src_cloud.ssh_util.execute(process)
def transfer_file_to_file(cloud_src, cloud_dst, host_src, host_dst, path_src, path_dst, cfg_migrate): LOG.debug("| | copy file") ssh_ip_src = cloud_src.getIpSsh() ssh_ip_dst = cloud_dst.getIpSsh() with settings(host_string=ssh_ip_src): with utils.forward_agent(cfg_migrate.key_filename): with utils.up_ssh_tunnel(host_dst, ssh_ip_dst) as port: if cfg_migrate.file_compression == "dd": run(("ssh -oStrictHostKeyChecking=no %s 'dd bs=1M if=%s' " + "| ssh -oStrictHostKeyChecking=no -p %s localhost 'dd bs=1M of=%s'") % (host_src, path_src, port, path_dst)) elif cfg_migrate.file_compression == "gzip": run(("ssh -oStrictHostKeyChecking=no %s 'gzip -%s -c %s' " + "| ssh -oStrictHostKeyChecking=no -p %s localhost 'gunzip | dd bs=1M of=%s'") % (host_src, cfg_migrate.level_compression, path_src, port, path_dst))
def transfer(self, data): if self.cfg.migrate.direct_compute_transfer: return self.transfer_direct(data) LOG.debug("| | copy file") ssh_ip_src = self.src_cloud.cloud_config.cloud.ssh_host ssh_ip_dst = self.dst_cloud.cloud_config.cloud.ssh_host with utils.forward_agent(self.cfg.migrate.key_filename), \ utils.up_ssh_tunnel(data['host_dst'], ssh_ip_dst, ssh_ip_src) as port: if self.cfg.migrate.file_compression == "dd": dd_dst = cmd_cfg.dd_cmd_of ssh_cmd_dst = cmd_cfg.ssh_cmd_port ssh_dst = ssh_cmd_dst(port, 'localhost', dd_dst) dd_src = cmd_cfg.dd_cmd_if ssh_cmd_src = cmd_cfg.ssh_cmd ssh_src = ssh_cmd_src(data['host_src'], dd_src) process = ssh_src >> ssh_dst process = process('1M', data['path_src'], '1M', data['path_dst']) self.src_cloud.ssh_util.execute(process) elif self.cfg.migrate.file_compression == "gzip": dd = cmd_cfg.dd_cmd_of gunzip_dd = cmd_cfg.gunzip_cmd >> dd ssh_cmd_dst = cmd_cfg.ssh_cmd_port ssh_dst = ssh_cmd_dst(port, 'localhost', gunzip_dd) gzip_cmd = cmd_cfg.gzip_cmd ssh_cmd_src = cmd_cfg.ssh_cmd ssh_src = ssh_cmd_src(data['host_src'], gzip_cmd) process = ssh_src >> ssh_dst process = process(self.cfg.migrate.level_compression, data['path_src'], '1M', data['path_dst']) self.src_cloud.ssh_util.execute(process)
def transfer_file_to_file(src_cloud, dst_cloud, host_src, host_dst, path_src, path_dst, cfg_migrate): # TODO: Delete after transport_db_via_ssh action rewriting LOG.debug("| | copy file") ssh_ip_src = src_cloud.getIpSsh() ssh_ip_dst = dst_cloud.getIpSsh() with settings(host_string=ssh_ip_src): with utils.forward_agent(cfg_migrate.key_filename): with utils.up_ssh_tunnel(host_dst, ssh_ip_dst, ssh_ip_src) as port: if cfg_migrate.file_compression == "dd": run(( "ssh -oStrictHostKeyChecking=no %s 'dd bs=1M if=%s' " + "| ssh -oStrictHostKeyChecking=no -p %s localhost 'dd bs=1M of=%s'" ) % (host_src, path_src, port, path_dst)) elif cfg_migrate.file_compression == "gzip": run(( "ssh -oStrictHostKeyChecking=no %s 'gzip -%s -c %s' " + "| ssh -oStrictHostKeyChecking=no -p %s localhost 'gunzip | dd bs=1M of=%s'" ) % (host_src, cfg_migrate.level_compression, path_src, port, path_dst))
def transfer(self, data): if self.cfg.migrate.direct_compute_transfer: return self.transfer_direct(data) LOG.debug("| | copy file") ssh_ip_src = self.src_cloud.getIpSsh() ssh_ip_dst = self.dst_cloud.getIpSsh() with utils.forward_agent(self.cfg.migrate.key_filename), \ utils.up_ssh_tunnel(data['host_dst'], ssh_ip_dst, ssh_ip_src) as port: if self.cfg.migrate.file_compression == "dd": dd_dst = cmd_cfg.dd_cmd_of ssh_cmd_dst = cmd_cfg.ssh_cmd_port ssh_dst = ssh_cmd_dst(port, 'localhost', dd_dst) dd_src = cmd_cfg.dd_cmd_if ssh_cmd_src = cmd_cfg.ssh_cmd ssh_src = ssh_cmd_src(data['host_src'], dd_src) process = ssh_src >> ssh_dst process = process('1M', data['path_src'], '1M', data['path_dst']) self.src_cloud.ssh_util.execute(process) elif self.cfg.migrate.file_compression == "gzip": dd = cmd_cfg.dd_cmd_of gunzip_dd = cmd_cfg.gunzip_cmd >> dd ssh_cmd_dst = cmd_cfg.ssh_cmd_port ssh_dst = ssh_cmd_dst(port, 'localhost', gunzip_dd) gzip_cmd = cmd_cfg.gzip_cmd ssh_cmd_src = cmd_cfg.ssh_cmd ssh_src = ssh_cmd_src(data['host_src'], gzip_cmd) process = ssh_src >> ssh_dst process = process(self.cfg.migrate.level_compression, data['path_src'], '1M', data['path_dst']) self.src_cloud.ssh_util.execute(process)