當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。