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


Python Platform.list_external_networks方法代码示例

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


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

示例1: create_external_network

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import list_external_networks [as 别名]
    def create_external_network(cls):
        """Creates an external network by the name specified in the config file.

        Skips creating one, if such a network already exists. Also stores the
        href and name of the network as class variables for future use.
        """
        cls._basic_check()
        net_name = cls._config['external_network']['name']

        platform = Platform(cls._sys_admin_client)

        net_refs = platform.list_external_networks()
        if net_name is not '*':
            for net_ref in net_refs:
                if net_ref.get('name').lower() == net_name.lower():
                    cls._logger.debug('Reusing existing ' + net_name)
                    cls._external_network_href = net_ref.get('href')
                    cls._external_network_name = net_name
                    return
            cls._logger.debug('Creating new external network' + net_name)
            ext_nw = cls._create_external_network()
            cls._external_network_href = ext_nw.get('href')
            cls._external_network_name = net_name
            cls._logger.debug('Created external network ' + net_name)
        else:
            if len(net_refs) > 0:
                cls._logger.debug('Defaulting to first network : ' +
                                  net_refs[0].get('name'))
                cls._external_network_href = net_refs[0].get('href')
                cls._external_network_name = net_refs[0].get('name')
            else:
                cls._logger.debug('No usable network found. Aborting test.')
                raise Exception('Test Aborted. No usable external network.')
开发者ID:vmware,项目名称:pyvcloud,代码行数:35,代码来源:environment.py

示例2: test_0015_list_external_network_config_ip_allocations

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import list_external_networks [as 别名]
    def test_0015_list_external_network_config_ip_allocations(self):
        """List external network configure ip allocations.

        Invoke the list_gateways_configure_ip_settings of the gateway.
        """
        for client in (TestGateway._client, TestGateway._org_client):
            gateway_obj = Gateway(client, self._name,
                                  TestGateway._gateway.get('href'))
            ip_allocations = gateway_obj.list_configure_ip_settings()
            platform = Platform(TestGateway._client)
            external_networks = platform.list_external_networks()
            self.assertTrue(bool(ip_allocations))
            exnet = ip_allocations[0].get('external_network')
            self.assertEqual(external_networks[0].get('name'), exnet)
开发者ID:vmware,项目名称:pyvcloud,代码行数:16,代码来源:gateway_tests.py

示例3: test_030_list_external_networks

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import list_external_networks [as 别名]
 def test_030_list_external_networks(self):
     platform = Platform(self.client)
     ext_net_refs = platform.list_external_networks()
     assert len(ext_net_refs) > 0
开发者ID:vmware,项目名称:pyvcloud,代码行数:6,代码来源:vcd_network.py


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