本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.get_access_settings方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.get_access_settings方法的具体用法?Python VDC.get_access_settings怎么用?Python VDC.get_access_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyvcloud.vcd.vdc.VDC
的用法示例。
在下文中一共展示了VDC.get_access_settings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_03_get_vdc_access
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_access_settings [as 别名]
def test_03_get_vdc_access(self):
logged_in_org = self.client.get_org()
org = Org(self.client, resource=logged_in_org)
vdc_resource = org.get_vdc(self.config['vcd']['vdc'])
vdc = VDC(self.client, resource=vdc_resource)
control_access = vdc.get_access_settings()
assert len(control_access.AccessSettings.AccessSetting) == 2
示例2: list_acl
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_access_settings [as 别名]
def list_acl(ctx, vdc_name):
try:
restore_session(ctx)
client = ctx.obj['client']
in_use_org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, in_use_org_href)
vdc_resource = org.get_vdc(vdc_name)
vdc = VDC(client, resource=vdc_resource)
acl = vdc.get_access_settings()
stdout(
access_settings_to_list(acl,
ctx.obj['profiles'].get('org_in_use')),
ctx)
except Exception as e:
stderr(e, ctx)
示例3: info
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_access_settings [as 别名]
def info(ctx, name):
try:
restore_session(ctx)
client = ctx.obj['client']
in_use_org_name = ctx.obj['profiles'].get('org_in_use')
in_use_vdc = ctx.obj['profiles'].get('vdc_in_use')
org_href = ctx.obj['profiles'].get('org_href')
org = Org(client, href=org_href)
vdc_resource = org.get_vdc(name)
vdc = VDC(client, resource=vdc_resource)
access_settings = None
try:
access_settings = vdc.get_access_settings()
except OperationNotSupportedException:
pass
result = vdc_to_dict(vdc_resource,
access_settings_to_dict(access_settings))
result['in_use'] = in_use_vdc == name
result['org'] = in_use_org_name
stdout(result, ctx)
except Exception as e:
stderr(e, ctx)
示例4: test_0050_vdc_acl
# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import get_access_settings [as 别名]
def test_0050_vdc_acl(self):
"""Test the methods related to access control list in vdc.py.
This test passes if all the acl operations are successful.
"""
logger = Environment.get_default_logger()
vdc = VDC(TestOrgVDC._client, href=TestOrgVDC._new_vdc_href)
vdc_name = TestOrgVDC._new_vdc_name
vapp_user_name = Environment.get_username_for_role_in_test_org(
CommonRoles.VAPP_USER)
console_user_name = Environment.get_username_for_role_in_test_org(
CommonRoles.CONSOLE_ACCESS_ONLY)
# remove all
logger.debug('Removing all access control from vdc ' + vdc_name)
control_access = vdc.remove_access_settings(remove_all=True)
self.assertFalse(hasattr(control_access, 'AccessSettings'))
# add
logger.debug('Adding 2 access control rule to vdc ' + vdc_name)
vdc.reload()
control_access = vdc.add_access_settings(
access_settings_list=[{
'name': vapp_user_name,
'type': 'user'
}, {
'name': console_user_name,
'type': 'user',
'access_level': 'ReadOnly'
}])
self.assertEqual(len(control_access.AccessSettings.AccessSetting), 2)
# get
logger.debug('Fetching access control rules for vdc ' + vdc_name)
vdc.reload()
control_access = vdc.get_access_settings()
self.assertEqual(len(control_access.AccessSettings.AccessSetting), 2)
# remove
logger.debug('Removing 1 access control rule for vdc ' + vdc_name)
control_access = vdc.remove_access_settings(
access_settings_list=[{
'name': vapp_user_name,
'type': 'user'
}])
self.assertEqual(len(control_access.AccessSettings.AccessSetting), 1)
# share
logger.debug('Sharing vdc ' + vdc_name + ' with everyone in the org')
vdc.reload()
control_access = vdc.share_with_org_members()
self.assertEqual(control_access.IsSharedToEveryone.text, 'true')
self.assertEqual(control_access.EveryoneAccessLevel.text, 'ReadOnly')
# unshare
logger.debug(
'Un-sharing vdc ' + vdc_name + ' from everyone in the org')
vdc.reload()
control_access = vdc.unshare_from_org_members()
self.assertEqual(control_access.IsSharedToEveryone.text, 'false')
# re-share, before performing any other ACL operation to avoid
# running into https://github.com/vmware/pyvcloud/issues/279
logger.debug('Re-sharing vdc ' + vdc_name + ' with everyone in the ' +
'org')
vdc.reload()
control_access = vdc.share_with_org_members()
self.assertEqual(control_access.IsSharedToEveryone.text, 'true')
self.assertEqual(control_access.EveryoneAccessLevel.text, 'ReadOnly')
# remove the last access setting
logger.debug('Removing the last remaining access control from'
' vdc ' + vdc_name)
vdc.reload()
control_access = vdc.remove_access_settings(remove_all=True)
self.assertFalse(hasattr(control_access, 'AccessSettings'))