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


Python VCA.get_catalogs方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from pyvcloud.vcloudair import VCA [as 別名]
# 或者: from pyvcloud.vcloudair.VCA import get_catalogs [as 別名]
class TestCatalog:


    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 catalog_exists(self, catalog_name, catalogs):
        for catalog in catalogs:
            if catalog.name == catalog_name:
                return True
        return False


    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_0009(self):
        """Validate that catalog doesn't exist"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        custom_catalog = config['vcloud']['custom_catalog']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        catalogs = self.vca.get_catalogs()
        assert not self.catalog_exists(custom_catalog, catalogs)


    def test_0010(self):
        """Create Catalog"""
        vdc_name = config['vcloud']['vdc']
        vapp_name = config['vcloud']['vapp']
        vm_name = config['vcloud']['vm']
        custom_catalog = config['vcloud']['custom_catalog']
        the_vdc = self.vca.get_vdc(vdc_name)
        assert the_vdc
        assert the_vdc.get_name() == vdc_name
        task = self.vca.create_catalog(custom_catalog, custom_catalog)
        assert task
        result = self.vca.block_until_completed(task)
        assert result
        catalogs = self.vca.get_catalogs()
        assert self.catalog_exists(custom_catalog, catalogs)


    def test_0011(self):
#.........這裏部分代碼省略.........
開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:103,代碼來源:catalog_tests.py

示例2: VCA

# 需要導入模塊: from pyvcloud.vcloudair import VCA [as 別名]
# 或者: from pyvcloud.vcloudair.VCA import get_catalogs [as 別名]
import os
from pyvcloud import vcloudair
from pyvcloud.vcloudair import VCA


username = os.environ['VCAUSER']
password = os.environ['VCAPASS']
service_type = VCA.VCA_SERVICE_TYPE_VCHS
host = 'vchs.vmware.com'
version = '5.6'
vca = VCA(host=host, username=username, service_type=service_type,
          version=version, verify=True, log=True)
assert vca
result = vca.login(password=password)
assert result
assert vca.token
service = 'M684216431-4470'
org = 'M684216431-4470'
result = vca.login_to_org(service, org)
assert result
vdc = 'M684216431-4470'
the_vdc = vca.get_vdc(vdc)
assert the_vdc
print 'vdc name: ' + the_vdc.get_name()
print 'catalogs: '
for catalog in vca.get_catalogs():
    print '  - ' + catalog.get_name()

開發者ID:digideskio,項目名稱:pyvcloud,代碼行數:29,代碼來源:vchs_login_tests.py


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