本文整理匯總了Python中pyvcloud.vcd.platform.Platform.get_ref_by_name方法的典型用法代碼示例。如果您正苦於以下問題:Python Platform.get_ref_by_name方法的具體用法?Python Platform.get_ref_by_name怎麽用?Python Platform.get_ref_by_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyvcloud.vcd.platform.Platform
的用法示例。
在下文中一共展示了Platform.get_ref_by_name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_0000_setup
# 需要導入模塊: from pyvcloud.vcd.platform import Platform [as 別名]
# 或者: from pyvcloud.vcd.platform.Platform import get_ref_by_name [as 別名]
def test_0000_setup(self):
"""Setup the org vdc required for the other tests in this module.
Create one org vdc as per the configuration stated above. Test the
method Org.create_org_vdc().
This test passes if the vdc href is not None.
"""
logger = Environment.get_default_logger()
TestPVDC._sys_admin_client = Environment.get_sys_admin_client()
org = Environment.get_test_org(TestPVDC._sys_admin_client)
platform = Platform(TestPVDC._sys_admin_client)
vdc_name = TestPVDC._new_vdc_name
pvdc_name = Environment.get_test_pvdc_name()
provider_vdc = platform.get_ref_by_name(ResourceType.PROVIDER_VDC,
pvdc_name)
pvdc_ext_href = get_admin_extension_href(provider_vdc.get('href'))
pvdc_ext_resource = TestPVDC._sys_admin_client.get_resource(
pvdc_ext_href)
vc_name = pvdc_ext_resource.VimServer.get('name')
res_pools_in_pvdc = TestPVDC._sys_admin_client.get_linked_resource(
resource=pvdc_ext_resource,
rel=RelationType.DOWN,
media_type=EntityType.VMW_PROVIDER_VDC_RESOURCE_POOL_SET.value)
if hasattr(res_pools_in_pvdc,
'{' + NSMAP['vmext'] + '}VMWProviderVdcResourcePool'):
src_respool = res_pools_in_pvdc.VMWProviderVdcResourcePool[0]
name_filter = ('vcName', vc_name)
query = TestPVDC._sys_admin_client.get_typed_query(
ResourceType.RESOURCE_POOL.value,
query_result_format=QueryResultFormat.RECORDS,
equality_filter=name_filter)
res_pools_in_use = {}
for res_pool in list(query.execute()):
res_pools_in_use[res_pool.get('moref')] = res_pool.get('name')
source_respool_name = res_pools_in_use[
src_respool.ResourcePoolVimObjectRef.MoRef]
TestPVDC._source_resource_pool = source_respool_name
storage_profiles = [{
'name': '*',
'enabled': True,
'units': 'MB',
'limit': 0,
'default': True
}]
vdc_resource = org.create_org_vdc(
vdc_name,
pvdc_name,
storage_profiles=storage_profiles,
uses_fast_provisioning=True,
is_thin_provision=True)
TestPVDC._sys_admin_client.get_task_monitor().wait_for_success(
task=vdc_resource.Tasks.Task[0])
logger.debug('Created ovdc ' + vdc_name + '.')
# The following contraption is required to get the non admin href of
# the ovdc. vdc_resource contains the admin version of the href since
# we created the ovdc as a sys admin.
org.reload()
for vdc in org.list_vdcs():
if vdc.get('name').lower() == vdc_name.lower():
TestPVDC._new_vdc_href = vdc.get('href')
self.assertIsNotNone(TestPVDC._new_vdc_href)