当前位置: 首页>>代码示例>>Python>>正文


Python VDC.reload方法代码示例

本文整理汇总了Python中pyvcloud.vcd.vdc.VDC.reload方法的典型用法代码示例。如果您正苦于以下问题:Python VDC.reload方法的具体用法?Python VDC.reload怎么用?Python VDC.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvcloud.vcd.vdc.VDC的用法示例。


在下文中一共展示了VDC.reload方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_100_instantiate_vapp_identical

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import reload [as 别名]
 def test_100_instantiate_vapp_identical(self):
     logged_in_org = self.client.get_org()
     org = Org(self.client, resource=logged_in_org)
     v = org.get_vdc(self.config['vcd']['vdc'])
     vdc = VDC(self.client, href=v.get('href'))
     assert self.config['vcd']['vdc'] == vdc.get_resource().get('name')
     result = vdc.instantiate_vapp(
         self.config['vcd']['vapp'],
         self.config['vcd']['catalog'],
         self.config['vcd']['template'],
         network=self.config['vcd']['network'],
         fence_mode='bridged',
         deploy=True,
         power_on=False,
         identical=True)
     task = self.client.get_task_monitor().wait_for_status(
         task=result.Tasks.Task[0],
         timeout=60,
         poll_frequency=2,
         fail_on_statuses=None,
         expected_target_statuses=[
             TaskStatus.SUCCESS, TaskStatus.ABORTED, TaskStatus.ERROR,
             TaskStatus.CANCELED
         ],
         callback=None)
     assert task.get('status') == TaskStatus.SUCCESS.value
     vdc.reload()
     vapp_resource = vdc.get_vapp(self.config['vcd']['vapp'])
     vm = vapp_resource.xpath(
         '//vcloud:VApp/vcloud:Children/vcloud:Vm', namespaces=NSMAP)
     assert len(vm) > 0
     assert vm[0].get('name') == self.config['vcd']['vm']
开发者ID:vmware,项目名称:pyvcloud,代码行数:34,代码来源:vcd_vapp.py

示例2: test_disable_vdc

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import reload [as 别名]
 def test_disable_vdc(self):
     org_to_use = self.client.get_org_by_name(
         self.config['vcd']['org_to_use'])
     org = Org(self.client, href=org_to_use.get('href'))
     resource = org.get_vdc(self.config['vcd']['new_vdc'])
     vdc = VDC(self.client, resource=resource)
     vdc.enable_vdc(False)
     vdc.reload()
     assert vdc.resource.IsEnabled.text == 'false'
开发者ID:vmware,项目名称:pyvcloud,代码行数:11,代码来源:vcd_vdc.py

示例3: test_0050_vdc_acl

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import reload [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'))
开发者ID:vmware,项目名称:pyvcloud,代码行数:79,代码来源:vdc_tests.py

示例4: len

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import reload [as 别名]
            while not network_exists:
                new_network_list = vdc.list_orgvdc_network_resources(
                    name=network['network_name'],
                    type=FenceMode.ISOLATED.value)
                if len(new_network_list) > 0:
                    print("Isolated network is visible in VDC: {0}".format(
                        network['network_name']))
                    network_exists = True
                else:
                    print("Isolated network is not visible yet: {0}".format(
                        network['network_name']))
                    time.sleep(3)

# Check for vApps and create them if they don't exist.  We have to
# reload the VDC object so it has all the links to current vApps.
vdc.reload()
for vapp_cfg in cfg.vapps:
    try:
        vapp = vdc.get_vapp(vapp_cfg['name'])
        print("vApp exists: {0}".format(vapp_cfg['name']))
    except Exception:
        print("vApp does not exist: name={0}".format(vapp_cfg['name']))
        vapp_resource = vdc.instantiate_vapp(**vapp_cfg)
        print("vApp instantiated")
        # We don't track the task as instantiating a vApp takes a while.
        # Uncomment below if you want to ensure the vApps are available.
        # handle_task(client, vapp_resource.Tasks.Task[0])

# Log out.
print("All done!")
client.logout()
开发者ID:vmware,项目名称:pyvcloud,代码行数:33,代码来源:tenant-onboard.py


注:本文中的pyvcloud.vcd.vdc.VDC.reload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。