コード例 #1
0
ファイル: iaas.py プロジェクト: Gandi/gandi.widget
    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]
コード例 #2
0
ファイル: network.py プロジェクト: Gandi/gandi.cli
    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
コード例 #3
0
    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]
コード例 #4
0
ファイル: network.py プロジェクト: lisptick/gandi.cli
    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
コード例 #5
0
ファイル: docker.py プロジェクト: Gandi/gandi.cli
    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))
コード例 #6
0
ファイル: docker.py プロジェクト: ziir/gandi.cli
    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))