当前位置: 首页>>代码示例>>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;未经允许,请勿转载。