本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.get_metadata_value方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.get_metadata_value方法的具体用法?Python VDC.get_metadata_value怎么用?Python VDC.get_metadata_value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.get_metadata_value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_0060_vdc_metadata
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_metadata_value [as 别名]
def test_0060_vdc_metadata(self):
"""Test the methods related to metadata manipulation in vdc.py.
This test passes if all the metadata operations are successful.
"""
vapp_author_client = None
sys_admin_client = None
try:
logger = Environment.get_default_logger()
vapp_author_client = Environment.get_client_in_default_org(
CommonRoles.VAPP_AUTHOR)
vdc_vapp_author_view = VDC(client=vapp_author_client,
href=TestOrgVDC._new_vdc_href)
sys_admin_client = Environment.get_sys_admin_client()
vdc_sys_admin_view = VDC(client=sys_admin_client,
href=TestOrgVDC._new_vdc_href)
# try to add new metadata as vapp author
try:
logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key}'
', value={TestOrgVDC._metadata_value}]) as vApp '
'author')
vdc_vapp_author_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_value)
self.assertFail('vApp author shouldn\'t have been able to '
'add new metadta entry.')
except OperationNotSupportedException as e:
pass
# add new metadata as sys admin
logger.debug(f'Adding metadata [key={TestOrgVDC._metadata_key},'
'value={TestOrgVDC._metadata_value}]) as Sys admin.')
task = vdc_sys_admin_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_value)
result = sys_admin_client.get_task_monitor().wait_for_success(task)
self.assertEqual(result.get('status'), TaskStatus.SUCCESS.value)
# retrieve metadata as vapp author
logger.debug(f'Retriving metadata with key='
'{TestOrgVDC._metadata_key} as vApp author.')
metadata_value = vdc_vapp_author_view.get_metadata_value(
key=TestOrgVDC._metadata_key)
self.assertEqual(extract_metadata_value(metadata_value),
TestOrgVDC._metadata_value)
# try to retrieve non existent metadata entry
try:
logger.debug(f'Retriving metadata with invalid key='
'{TestOrgVDC._non_existent_metadata_key} as vApp '
'author')
metadata_value = vdc_vapp_author_view.get_metadata_value(
key=TestOrgVDC._non_existent_metadata_key)
self.assertFail('Shouldn\'t have been able to retrieve metadta'
' entry with bad key.')
except AccessForbiddenException as e:
pass
# try to update metadata value as vapp author
try:
logger.debug(f'Trying to update metadata with key='
'{TestOrgVDC._metadata_key} to value='
'{TestOrgVDC._metadata_new_value} as vApp '
'author.')
vdc_vapp_author_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_new_value)
self.assertFail('Shouldn\'t have been able to update metadta'
' entry as vApp author.')
except OperationNotSupportedException as e:
pass
# update metadata value as sys admin
logger.debug(f'Updtaing metadata with key='
'{TestOrgVDC._metadata_key} to value='
'{TestOrgVDC._metadata_new_value} as Sys Admin.')
task = vdc_sys_admin_view.set_metadata(
key=TestOrgVDC._metadata_key,
value=TestOrgVDC._metadata_new_value)
sys_admin_client.get_task_monitor().wait_for_success(task)
metadata_value = vdc_sys_admin_view.get_metadata_value(
key=TestOrgVDC._metadata_key)
self.assertEqual(extract_metadata_value(metadata_value),
TestOrgVDC._metadata_new_value)
# try to remove metadata as vapp author
try:
logger.debug(f'Trying to remove metadata with key='
'{TestOrgVDC._metadata_key} as vApp author.')
task = vdc_vapp_author_view.remove_metadata(
key=TestOrgVDC._metadata_key)
self.assertFail('Shouldn\'t have been able to remove metadta '
'entry as vApp author.')
except OperationNotSupportedException as e:
pass
# remove metadata entry as sys admin
#.........这里部分代码省略.........