def retrieve(): vms = [] for vm in ApiIaas.list({"state": ["running", "halted"], "sort_by": "hostname"}): vms.append(ApiIaas.info(vm["id"])) if hasattr(ApiAccount, "all"): account = ApiAccount.all() else: account = ApiAccount.info() account["credit_usage"] = ApiAccount.creditusage() return [vms, account]
def attach(cls, ip, vm, background=False, force=False): """ Attach """ vm_ = Iaas.info(vm) ip_ = cls.info(ip) if not cls._check_and_detach(ip_, vm_): return # then we should attach the ip to the vm attach = Iface._attach(ip_['iface_id'], vm_['id']) if not background: cls.display_progress(attach) return attach
def retrieve(): vms = [] for vm in ApiIaas.list({'state': ['running', 'halted'], 'sort_by': 'hostname'}): vms.append(ApiIaas.info(vm['id'])) if hasattr(ApiAccount, 'all'): account = ApiAccount.all() else: account = ApiAccount.info() account['credit_usage'] = ApiAccount.creditusage() return [vms, account]
def attach(cls, ip, vm, background=False, force=False): """ Attach """ vm_ = Iaas.info(vm) ip_ = cls.info(ip) if not cls.check_and_detach(ip_, vm_, force): return # then we should attach the ip to the vm attach = Iface._attach(ip_['iface_id'], vm_['id']) if not background: cls.display_progress(attach) return attach
def handle(cls, vm, args): """ Setup forwarding connection to given VM and pipe docker cmds over SSH. """ docker = Iaas.info(vm) if not docker: raise Exception('docker vm %s not found' % vm) if docker['state'] != 'running': Iaas.start(vm) # XXX remote_addr = docker['ifaces'][0]['ips'][0]['ip'] port = unixpipe.setup(remote_addr, 'root', '/var/run/docker.sock') os.environ['DOCKER_HOST'] = 'tcp://localhost:%d' % port cls.echo('using DOCKER_HOST=%s' % os.environ['DOCKER_HOST']) subprocess.call(['docker'] + list(args))