def convert_file_to_raw(host, disk_format, filepath): with settings(host_string=host, connection_attempts=env.connection_attempts): with forward_agent(env.key_filename): run("qemu-img convert -f %s -O raw %s %s.tmp" % (disk_format, filepath, filepath)) run("mv -f %s.tmp %s" % (filepath, filepath))
def delete_remote_file_on_compute(path_file, host_cloud, host_instance): with settings(host_string=host_cloud, connection_attempts=env.connection_attempts): with forward_agent(env.key_filename): run("ssh -oStrictHostKeyChecking=no %s 'rm -rf %s'" % (host_instance, path_file))
def run(self, image_id=None, base_filename=None, **kwargs): cfg = self.cloud.cloud_config.cloud ssh_attempts = self.cloud.cloud_config.migrate.ssh_connection_attempts with settings(host_string=cfg.host, connection_attempts=ssh_attempts): with forward_agent(env.key_filename): cmd = image.glance_image_download_cmd(cfg, image_id, base_filename) run(cmd)
def run(self, image_id=None, base_filename=None, **kwargs): cfg = self.cloud.cloud_config.cloud with settings(host_string=cfg.host): with forward_agent(env.key_filename): run(( "glance --os-username=%s --os-password=%s --os-tenant-name=%s " + "--os-auth-url=http://%s:35357/v2.0 " + "image-download %s > %s") % (cfg.user, cfg.password, cfg.tenant, cfg.host, image_id, base_filename))
def run(self, cfg=None, cloud_src=None, cloud_dst=None, image_id=None, base_filename=None, **kwargs): with settings(host_string=cfg['host']): with forward_agent(env.key_filename): run(("glance --os-username=%s --os-password=%s --os-tenant-name=%s " + "--os-auth-url=http://%s:35357/v2.0 " + "image-download %s > %s") % (cfg['user'], cfg['password'], cfg['tenant'], cfg['host'], image_id, base_filename))
def run(self, image_id=None, base_filename=None, **kwargs): cfg = self.cloud.cloud_config.cloud with settings(host_string=cfg.host): with forward_agent(env.key_filename): run(("glance --os-username=%s --os-password=%s --os-tenant-name=%s " + "--os-auth-url=%s " + "image-download %s > %s") % (cfg.user, cfg.password, cfg.tenant, cfg.auth_url, image_id, base_filename))
def run(self, cmd): abort_exception = None if not self.ignore_errors: abort_exception = RemoteExecutionError with settings(warn_only=self.ignore_errors, host_string=self.host, user=self.user, password=self.password, abort_exception=abort_exception, reject_unkown_hosts=False): with forward_agent(self.key): LOG.debug("running '%s' on '%s' host as user '%s'", cmd, self.host, self.user) if self.sudo: return sudo(cmd) else: return run(cmd)
def run(self, info=None, **kwargs): cfg = self.cloud.cloud_config.cloud for instance_id, instance in info[utl.INSTANCES_TYPE].iteritems(): image_id = info[INSTANCES][instance_id][ utl.INSTANCE_BODY]['image_id'] base_file = "%s/%s" % (self.cloud.cloud_config.cloud.temp, "temp%s_base" % instance_id) diff_file = "%s/%s" % (self.dst_cloud.cloud_config.cloud.temp, "temp%s" % instance_id) with settings(host_string=cfg.host): with forward_agent(env.key_filename): run(( "glance --os-username=%s --os-password=%s --os-tenant-name=%s " + "--os-auth-url=http://%s:35357/v2.0 " + "image-download %s > %s") % (cfg.user, cfg.password, cfg.tenant, cfg.host, image_id, base_file)) instance[DIFF][PATH_DST] = diff_file instance[DIFF][HOST_DST] = self.dst_cloud.getIpSsh() return {'info': info}
def run(self, info=None, **kwargs): cfg = self.cloud.cloud_config.cloud ssh_attempts = self.cloud.cloud_config.migrate.ssh_connection_attempts for instance_id, instance in info[utl.INSTANCES_TYPE].iteritems(): inst = info[utl.INSTANCES_TYPE][instance_id][utl.INSTANCE_BODY] image_id = inst['image_id'] base_file = "/tmp/%s" % ("temp%s_base" % instance_id) diff_file = "/tmp/%s" % ("temp%s" % instance_id) with settings(host_string=cfg.host, connection_attempts=ssh_attempts): with forward_agent(env.key_filename): cmd = image.glance_image_download_cmd(cfg, image_id, base_file) run(cmd) instance[DIFF][PATH_DST] = diff_file instance[DIFF][HOST_DST] = self.dst_cloud.getIpSsh() return { 'info': info }
def run(self, info=None, **kwargs): cfg = self.cloud.cloud_config.cloud for instance_id, instance in info[utl.INSTANCES_TYPE].iteritems(): image_id = info[INSTANCES][instance_id][utl.INSTANCE_BODY]['image_id'] base_file = "%s/%s" % (self.cloud.cloud_config.cloud.temp, "temp%s_base" % instance_id) diff_file = "%s/%s" % (self.dst_cloud.cloud_config.cloud.temp, "temp%s" % instance_id) with settings(host_string=cfg.host): with forward_agent(env.key_filename): run(("glance --os-username=%s --os-password=%s --os-tenant-name=%s " + "--os-auth-url=%s " + "image-download %s > %s") % (cfg.user, cfg.password, cfg.tenant, cfg.auth_url, image_id, base_file)) instance[DIFF][PATH_DST] = diff_file instance[DIFF][HOST_DST] = self.dst_cloud.getIpSsh() return { 'info': info }
def run(self, cmd): abort_exception = None if not self.ignore_errors: abort_exception = RemoteExecutionError ssh_attempts = cfglib.CONF.migrate.ssh_connection_attempts with settings(warn_only=self.ignore_errors, host_string=self.host, user=self.user, password=self.password, abort_exception=abort_exception, reject_unkown_hosts=False, combine_stderr=False, connection_attempts=ssh_attempts): with forward_agent(self.key): LOG.debug("running '%s' on '%s' host as user '%s'", cmd, self.host, self.user) if self.sudo and self.user != 'root': return sudo(cmd) else: return run(cmd)
def convert_file_to_raw(self, host, filepath): with settings(host_string=host): with forward_agent(env.key_filename): run("qemu-img convert -f %s -O raw %s %s.tmp" % (filepath, filepath, 'qcow')) run("cd %s && mv -f %s.tmp %s" % (filepath, filepath))
def delete_remote_file_on_compute(self, path_file, host_cloud, host_instance): with settings(host_string=host_cloud): with forward_agent(env.key_filename): run("ssh -oStrictHostKeyChecking=no %s 'rm -rf %s'" % (host_instance, path_file))