當前位置: 首頁>>代碼示例>>Python>>正文


Python vcloudair.VCA類代碼示例

本文整理匯總了Python中pyvcloud.vcloudair.VCA的典型用法代碼示例。如果您正苦於以下問題:Python VCA類的具體用法?Python VCA怎麽用?Python VCA使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了VCA類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

class TestVCASSO:
    def __init__(self):
        self.vca = None
        self.instance = None
        self.login_to_vcloud()

    def login_to_vcloud(self):
        """Login to vCloud VCA"""
        username = config["vcloud"]["username"]
        password = config["vcloud"]["password"]
        host = config["vcloud"]["host"]
        version = config["vcloud"]["version"]
        self.instance = config["vcloud"]["instance"]
        self.vca = VCA(host=host, username=username, service_type="vca", version=version, verify=True, log=True)
        assert self.vca
        result = self.vca.login(password=password)
        assert result

    def logout_from_vcloud(self):
        """Logout from vCloud"""
        print "logout"
        self.vca.logout()
        self.vca = None
        assert self.vca is None

    def test_0001(self):
        """Loggin in to vCloud"""
        assert self.vca.token

    def test_002(self):
        """Login to instance no password"""
        result = self.vca.login_to_instance_sso(instance=self.instance)
        assert result
開發者ID:jtyr,項目名稱:pyvcloud,代碼行數:33,代碼來源:vca_sso_tests.py

示例2: login_to_vcloud

def login_to_vcloud(username, password, host, version, org, service_type, instance):       

        vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
        assert vca

        if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type:
            result = vca.login(password=password, org=org)
            assert result, "Wrong password or Org?"
            result = vca.login(token=vca.token, org=org, org_url=vca.vcloud_session.org_url)
            assert result
        elif VCA.VCA_SERVICE_TYPE_VCHS == service_type:
            result = vca.login(password=password)
            assert result, "Wrong Password?"
            result = vca.login(token=vca.token)
            assert result
            result = vca.login_to_org(instance, org)  # service now called instance
            assert result, "Wrong service/aka instance or org?"
        elif VCA.VCA_SERVICE_TYPE_VCA == service_type:
            result = vca.login(password=password)
            assert result
            result = vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
            assert result
            print "token " + vca.vcloud_session.token
            result = vca.login_to_instance(password=None, instance=instance, token=vca.vcloud_session.token, org_url=vca.vcloud_session.org_url)
            assert result

        return vca
開發者ID:vmware,項目名稱:vca-codesamples,代碼行數:27,代碼來源:list_vms_in_vdc.py

示例3: login_to_vcloud

 def login_to_vcloud(self):
     """Login to vCloud"""
     username = config['vcloud']['username']
     password = config['vcloud']['password']
     service_type = config['vcloud']['service_type']
     host = config['vcloud']['host']
     version = config['vcloud']['version']
     org = config['vcloud']['org']
     service = config['vcloud']['service']
     instance = config['vcloud']['instance']
     self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
     assert self.vca
     if vcloudair.VCA_SERVICE_TYPE_STANDALONE == service_type:
         result = self.vca.login(password=password, org=org)
         assert result
         result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
         assert result
     elif vcloudair.VCA_SERVICE_TYPE_SUBSCRIPTION == service_type:
         result = self.vca.login(password=password)
         assert result
         result = self.vca.login(token=self.vca.token)
         assert result
         result = self.vca.login_to_org(service, org)
         assert result
     elif vcloudair.VCA_SERVICE_TYPE_ONDEMAND == service_type:
         result = self.vca.login(password=password)
         assert result
         result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
         assert result
         result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
         assert result
開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:31,代碼來源:catalog_tests.py

示例4: _getVCA

def _getVCA(profile='default'):
    vca = VCA()
    try:
        config = ConfigParser.RawConfigParser()
        config.read(os.path.expanduser('~/.vcarc'))
        section = 'Profile-%s' % profile
        if config.has_option(section, "host") and config.has_option(section, "token"):
            host = config.get(section, "host")
            token = config.get(section, "token")
            if vca.login(host, None, None, token):
                return vca
            else:
                print "token expired"
        else:
            print "please authenticate"
    except ConfigParser.Error:
        print "please authenticate"
    return None
開發者ID:hartsock,項目名稱:vca-cli,代碼行數:18,代碼來源:vca_cli.py

示例5: login

def login(ctx, user, host, password):
    """Login to a vCloud service"""
    vca = VCA()
    result = vca.login(host, user, password, None)
    if result:
        click.echo(click.style('Login successful with profile \'%s\'' % ctx.obj['PROFILE'], fg='blue'))
        config = ConfigParser.RawConfigParser()  
        config.read(os.path.expanduser('~/.vcarc'))            
        section = 'Profile-%s' % ctx.obj['PROFILE']
        if not config.has_section(section):
            config.add_section(section)
        config.set(section, 'host', host)
        config.set(section, 'user', user)        
        config.set(section, 'token', vca.token)
        with open(os.path.expanduser('~/.vcarc'), 'w+') as configfile:
            config.write(configfile)        
    else:
        click.echo(click.style('login failed', fg='red'))    
    return result
開發者ID:hartsock,項目名稱:vca-cli,代碼行數:19,代碼來源:vca_cli.py

示例6: __init__

class TestVDC:

    def __init__(self):
        self.vca = None
        self.login_to_vcloud()

    def login_to_vcloud(self):
        """Login to vCloud"""
        username = config['vcloud']['username']
        password = config['vcloud']['password']
        service_type = config['vcloud']['service_type']
        host = config['vcloud']['host']
        version = config['vcloud']['version']
        instance = config['vcloud']['instance']
        self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
        assert self.vca
        if self.vca.VCA_SERVICE_TYPE_STANDALONE == service_type:
            raise Exception('not-supported')
        elif self.vca.VCA_SERVICE_TYPE_VCHS == service_type:
            raise Exception('not-supported')
        elif self.vca.VCA_SERVICE_TYPE_VCA == service_type:
            result = self.vca.login(password=password)
            assert result
            result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
            assert result
            result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
            assert result

    def logout_from_vcloud(self):
        """Logout from vCloud"""
        print 'logout'
        selfl.vca.logout()
        self.vca = None
        assert self.vca is None

    def test_0001(self):
        """Loggin in to vCloud"""
        assert self.vca.token


    def test_0002(self):
        """Get VDC Templates"""
        templates = self.vca.get_vdc_templates()
開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:43,代碼來源:vdc_tests.py

示例7: login_to_vcloud

 def login_to_vcloud(self):
     """Login to vCloud VCA"""
     username = config["vcloud"]["username"]
     password = config["vcloud"]["password"]
     host = config["vcloud"]["host"]
     version = config["vcloud"]["version"]
     self.instance = config["vcloud"]["instance"]
     self.vca = VCA(host=host, username=username, service_type="vca", version=version, verify=True, log=True)
     assert self.vca
     result = self.vca.login(password=password)
     assert result
開發者ID:jtyr,項目名稱:pyvcloud,代碼行數:11,代碼來源:vca_sso_tests.py

示例8: _login_user_to_service

 def _login_user_to_service(self, user, host, password, service_type,
                            service_version, service, org_name):
     vca = VCA(host, user, service_type, service_version)
     result = vca.login(password=password)
     if result:
         if service_type == 'subscription':
             if not service:
                 if org_name:
                     service = org_name
                 else:
                     services = vca.services.get_Service()
                     if not services:
                         return None
                     service = services[0].serviceId
             if not org_name:
                 org_name = vca.get_vdc_references(service)[0].name
             result = vca.login_to_org(service, org_name)
         if result:
             return vca
     return
開發者ID:Cloudify-PS,項目名稱:walle-service,代碼行數:20,代碼來源:common.py

示例9: __init__

class TestVCAUser:


    def __init__(self):
        self.vca = None
        self.instance = None
        self.login_to_vcloud()

    def login_to_vcloud(self):
        """Login to vCloud VCA"""
        username = config['vcloud']['username']
        password = config['vcloud']['password']
        host = config['vcloud']['host']
        version = config['vcloud']['version']
        self.instance = config['vcloud']['instance']
        self.vca = VCA(host=host, username=username, service_type='vca', version=version, verify=True, log=True)
        assert self.vca
        result = self.vca.login(password=password)
        assert result

    def logout_from_vcloud(self):
        """Logout from vCloud"""
        print 'logout'
        self.vca.logout()
        self.vca = None
        assert self.vca is None

    def test_0001(self):
        """Loggin in to vCloud"""
        assert self.vca.token

    def test_002(self):
        """Get Users"""
        result = self.vca.get_users()
        assert result
        print str(result)
開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:36,代碼來源:vca_user_tests.py

示例10: login_to_vcloud

 def login_to_vcloud(self):
     """Login to vCloud"""
     username = config['vcloud']['username']
     password = config['vcloud']['password']
     service_type = config['vcloud']['service_type']
     host = config['vcloud']['host']
     version = config['vcloud']['version']
     self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
     assert self.vca
     if vcloudair.VCA_SERVICE_TYPE_STANDALONE == service_type:
         raise Exception('not-supported')
     elif vcloudair.VCA_SERVICE_TYPE_SUBSCRIPTION == service_type:
         raise Exception('not-supported')
     elif vcloudair.VCA_SERVICE_TYPE_ONDEMAND == service_type:
         result = self.vca.login(password=password)
         assert result
開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:16,代碼來源:vca_tests.py

示例11: login_to_vcloud

 def login_to_vcloud(self):
     """Login to vCloud"""
     username = config['vcloud']['username']
     password = config['vcloud']['password']
     service_type = config['vcloud']['service_type']
     host = config['vcloud']['host']
     version = config['vcloud']['version']
     instance = config['vcloud']['instance']
     self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
     assert self.vca
     if self.vca.VCA_SERVICE_TYPE_STANDALONE == service_type:
         raise Exception('not-supported')
     elif self.vca.VCA_SERVICE_TYPE_VCHS == service_type:
         raise Exception('not-supported')
     elif self.vca.VCA_SERVICE_TYPE_VCA == service_type:
         result = self.vca.login(password=password)
         assert result
         result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
         assert result
         result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
         assert result
開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:21,代碼來源:vdc_tests.py

示例12: login

 def login(self, host, username, password, instance, org, version,
           save_password=True):
     self.vca = VCA(host=host, username=username, version=version,
                    verify=self.verify, log=self.debug)
     service_type = self.vca.get_service_type()
     if service_type == VCA.VCA_SERVICE_TYPE_UNKNOWN:
         raise Exception('service type unknown')
     self.vca.service_type = service_type
     if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type and \
        org is None:
         self.error_message = 'Org can\'t be null'
         return False
     result = self.vca.login(password=password, org=org)
     if result:
         Log.debug(self.logger, 'logged in, org=%s' % self.vca.org)
         if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type:
             result = self.vca.vcloud_session.login(token=self.vca.
                                                    vcloud_session.token)
             assert result
         if save_password:
             self.password = password
         self.save_config(self.profile, self.profile_file)
     return result
開發者ID:digideskio,項目名稱:vca-cli,代碼行數:23,代碼來源:cmd_proc.py

示例13: vca_login

def vca_login(module=None):
    service_type    = module.params.get('service_type')
    username        = module.params.get('username')
    password        = module.params.get('password')
    instance        = module.params.get('instance_id')
    org             = module.params.get('org')
    service         = module.params.get('service_id')
    vdc_name        = module.params.get('vdc_name')
    version         = module.params.get('api_version')
    verify          = module.params.get('verify_certs')
    if not vdc_name:
        if service_type == 'vchs':
            vdc_name = module.params.get('service_id')
    if not org:
        if service_type == 'vchs':
            if vdc_name:
                org = vdc_name
            else:
                org = service
    if service_type == 'vcd':
        host = module.params.get('host')
    else:
        host = LOGIN_HOST[service_type]

    if not username:
        if 'VCA_USER' in os.environ:
            username = os.environ['VCA_USER']
    if not password:
        if 'VCA_PASS' in os.environ:
            password = os.environ['VCA_PASS']
    if not username or not password:
        module.fail_json(msg = "Either the username or password is not set, please check")

    if service_type == 'vchs':
        version = '5.6'
    if service_type == 'vcd':
        if not version:
            version == '5.6'


    vca = VCA(host=host, username=username, service_type=SERVICE_MAP[service_type], version=version, verify=verify)

    if service_type == 'vca':
        if not vca.login(password=password):
            module.fail_json(msg = "Login Failed: Please check username or password", error=vca.response.content)
        if not vca.login_to_instance(password=password, instance=instance, token=None, org_url=None):
            s_json = serialize_instances(vca.instances)
            module.fail_json(msg = "Login to Instance failed: Seems like instance_id provided is wrong .. Please check",\
                                    valid_instances=s_json)
        if not vca.login_to_instance(instance=instance, password=None, token=vca.vcloud_session.token,
                                     org_url=vca.vcloud_session.org_url):
            module.fail_json(msg = "Error logging into org for the instance", error=vca.response.content)
        return vca

    if service_type == 'vchs':
        if not vca.login(password=password):
            module.fail_json(msg = "Login Failed: Please check username or password", error=vca.response.content)
        if not vca.login(token=vca.token):
            module.fail_json(msg = "Failed to get the token", error=vca.response.content)
        if not vca.login_to_org(service, org):
            module.fail_json(msg = "Failed to login to org, Please check the orgname", error=vca.response.content)
        return vca

    if service_type == 'vcd':
        if not vca.login(password=password, org=org):
            module.fail_json(msg = "Login Failed: Please check username or password or host parameters")
        if not vca.login(password=password, org=org):
            module.fail_json(msg = "Failed to get the token", error=vca.response.content)
        if not vca.login(token=vca.token, org=org, org_url=vca.vcloud_session.org_url):
            module.fail_json(msg = "Failed to login to org", error=vca.response.content)
        return vca
開發者ID:vmware,項目名稱:vca-codesamples,代碼行數:71,代碼來源:vca_fw.py

示例14: __init__

class TestVCloud:

    def __init__(self):
        self.vca = None
        self.login_to_vcloud()

    def login_to_vcloud(self):
        """Login to vCloud"""
        username = config['vcloud']['username']
        password = config['vcloud']['password']
        service_type = config['vcloud']['service_type']
        host = config['vcloud']['host']
        version = config['vcloud']['version']
        org = config['vcloud']['org']
        service = config['vcloud']['service']
        instance = config['vcloud']['instance']
        self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
        assert self.vca
        if vcloudair.VCA_SERVICE_TYPE_STANDALONE == service_type:
            result = self.vca.login(password=password, org=org)
            assert result
            result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
            assert result
        elif vcloudair.VCA_SERVICE_TYPE_SUBSCRIPTION == service_type:
            result = self.vca.login(password=password)
            assert result
            result = self.vca.login(token=self.vca.token)
            assert result
            result = self.vca.login_to_org(service, org)
            assert result
        elif vcloudair.VCA_SERVICE_TYPE_ONDEMAND == service_type:
            result = self.vca.login(password=password)
            assert result
            result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
            assert result
            result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
            assert result

    def logout_from_vcloud(self):
        """Logout from vCloud"""
        print 'logout'
        selfl.vca.logout()
        self.vca = None
        assert self.vca is None

    def test_0001(self):
        """Loggin in to vCloud"""
        assert self.vca.token

    def test_0002(self):
        """Get VDC"""
        vdc_name = config['vcloud']['vdc']
        the_vdc = self.vca.get_vdc(vdc_name)        
        assert the_vdc
        assert the_vdc.get_name() == vdc_name

    def test_0003(self):
        """Create vApp"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        catalog = config['vcloud']['catalog']
        template = config['vcloud']['template']
        network = config['vcloud']['network']
        mode = config['vcloud']['mode']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        task = self.vca.create_vapp(vdc_name, vapp_name, template, catalog, vm_name=vm_name)
        assert task
        result = self.vca.block_until_completed(task)
        assert result
        the_vdc = self.vca.get_vdc(vdc_name)
        the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
        assert the_vapp
        assert the_vapp.name == vapp_name

    def test_0004(self):
        """Disconnect vApp from pre-defined networks"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
        assert the_vapp
        assert the_vapp.name == vapp_name
        task = the_vapp.disconnect_from_networks()
        assert task
        result = self.vca.block_until_completed(task)
        assert result

    def test_0005(self):
        """Connect vApp to network"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        network = config['vcloud']['network']
        mode = config['vcloud']['mode']
        the_vdc = self.vca.get_vdc(vdc_name)
#.........這裏部分代碼省略.........
開發者ID:piraz,項目名稱:pyvcloud,代碼行數:101,代碼來源:vcloud_tests.py

示例15: __init__

class TestVApp:


    def __init__(self):
        self.vca = None
        self.login_to_vcloud()


    def login_to_vcloud(self):
        """Login to vCloud"""
        username = config['vcloud']['username']
        password = config['vcloud']['password']
        service_type = config['vcloud']['service_type']
        host = config['vcloud']['host']
        version = config['vcloud']['version']
        org = config['vcloud']['org']
        service = config['vcloud']['service']
        instance = config['vcloud']['instance']
        self.vca = VCA(host=host, username=username, service_type=service_type, version=version, verify=True, log=True)
        assert self.vca
        if VCA.VCA_SERVICE_TYPE_STANDALONE == service_type:
            result = self.vca.login(password=password, org=org)
            assert result
            result = self.vca.login(token=self.vca.token, org=org, org_url=self.vca.vcloud_session.org_url)
            assert result
        elif VCA.VCA_SERVICE_TYPE_VCHS == service_type:
            result = self.vca.login(password=password)
            assert result
            result = self.vca.login(token=self.vca.token)
            assert result
            result = self.vca.login_to_org(service, org)
            assert result
        elif VCA.VCA_SERVICE_TYPE_VCA == service_type:
            result = self.vca.login(password=password)
            assert result
            result = self.vca.login_to_instance(password=password, instance=instance, token=None, org_url=None)
            assert result
            result = self.vca.login_to_instance(password=None, instance=instance, token=self.vca.vcloud_session.token, org_url=self.vca.vcloud_session.org_url)
            assert result


    def logout_from_vcloud(self):
        """Logout from vCloud"""
        print 'logout'
        selfl.vca.logout()
        self.vca = None
        assert self.vca is None


    def test_0001(self):
        """Loggin in to vCloud"""
        assert self.vca.token


    def test_0002(self):
        """Get VDC"""
        vdc_name = config['vcloud']['vdc']
        the_vdc = self.vca.get_vdc(vdc_name)        
        assert the_vdc
        assert the_vdc.get_name() == vdc_name


    def test_0003(self):
        """Create vApp"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        catalog = config['vcloud']['catalog']
        template = config['vcloud']['template']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        task = self.vca.create_vapp(vdc_name, vapp_name, template, catalog, vm_name=vm_name)
        assert task
        result = self.vca.block_until_completed(task)
        assert result
        the_vdc = self.vca.get_vdc(vdc_name)
        the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
        assert the_vapp
        assert the_vapp.name == vapp_name


    def test_0004(self):
        """Validate vApp State is powered off (8)"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        the_vapp = self.vca.get_vapp(the_vdc, vapp_name)
        assert the_vapp
        assert the_vapp.me.get_status() == 8


    def test_0009(self):
        """Disconnect VM from pre-defined networks"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        the_vdc = self.vca.get_vdc(vdc_name)
#.........這裏部分代碼省略.........
開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:101,代碼來源:vapp_tests.py


注:本文中的pyvcloud.vcloudair.VCA類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。