コード例 #1
0
 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))
コード例 #2
0
 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))
コード例 #3
0
 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))
コード例 #4
0
    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)
コード例 #5
0
    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)
コード例 #6
0
 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))
コード例 #7
0
 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))
コード例 #8
0
 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))
コード例 #9
0
    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)
コード例 #10
0
 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}
コード例 #11
0
    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
        }
コード例 #12
0
 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
     }
コード例 #13
0
    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)
コード例 #14
0
ファイル: remote_runner.py プロジェクト: japaniel/CloudFerry
    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)
コード例 #15
0
 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))
コード例 #16
0
 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))