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


Python Platform.get_external_network方法代码示例

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


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

示例1: test_0020_add_subnet

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def test_0020_add_subnet(self):
        """Test the method externalNetwork.add_subnet()

        Add subnet to the existing external network

        This test passes if subnet is added successfully.
        """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        ext_net_resource = platform.get_external_network(self._name)
        extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                     resource=ext_net_resource)

        ext_net = extnet_obj.add_subnet(self._name,
                                        TestExtNet._gateway2,
                                        TestExtNet._netmask,
                                        [TestExtNet._ip_range2],
                                        TestExtNet._dns1,
                                        TestExtNet._dns2,
                                        TestExtNet._dns_suffix)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Added subnet to external network ' + TestExtNet._name + '.')

        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
        new_subnet = config.IpScopes.IpScope[-1]
        self.assertEqual(TestExtNet._gateway2, new_subnet.Gateway.text)
        self.assertEqual(TestExtNet._netmask, new_subnet.Netmask.text)
开发者ID:vmware,项目名称:pyvcloud,代码行数:35,代码来源:extnet_tests.py

示例2: test_0010_update

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def test_0010_update(self):
        """Test the method Platform.update_external_network()

        Update name and description of the external network created by setup.
        Verifies name and description after update completes. Reset the name
        and description to original.

        This test passes if name and description are updated successfully.
        """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        new_name = 'updated_' + TestExtNet._name
        new_description = 'Updated ' + TestExtNet._description

        ext_net = platform.update_external_network(TestExtNet._name, new_name,
                                                   new_description)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug('Updated external network ' + TestExtNet._name + '.')

        ext_net = platform.get_external_network(new_name)
        self.assertIsNotNone(ext_net)
        self.assertEqual(new_description,
                         ext_net['{' + NSMAP['vcloud'] + '}Description'].text)

        # Reset the name and description to original
        ext_net = platform.update_external_network(new_name, self._name,
                                                   self._description)
        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
开发者ID:vmware,项目名称:pyvcloud,代码行数:35,代码来源:extnet_tests.py

示例3: test_0061_detach_port_group

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def test_0061_detach_port_group(self):
        """Detach a portgroup from an external network
       This test passes if the portgroup from another vCenter is removed
       from external network successfully.
       """
        if TestExtNet._vc2_host_ip is None or TestExtNet._vc2_host_ip == '':
            return
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        vc_name = TestExtNet._config['vc2']['vcenter_host_name']
        port_group_helper = PortgroupHelper(TestExtNet._sys_admin_client)
        pg_name = port_group_helper.get_ext_net_portgroup_name(vc_name,
                                                               self._name)

        ext_net = self._get_ext_net(platform).detach_port_group(vc_name,
                                                                pg_name)
        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Detach a portgroup from an external network' + TestExtNet._name)
        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        vc_record = platform.get_vcenter(vc_name)
        vc_href = vc_record.get('href')
        vim_port_group_ref = ext_net.VimPortGroupRef
        vc_href_found = False

        if vim_port_group_ref.VimServerRef.get('href') == vc_href:
            vc_href_found = True
        self.assertFalse(vc_href_found)
开发者ID:vmware,项目名称:pyvcloud,代码行数:33,代码来源:extnet_tests.py

示例4: test_0060_attach_port_group

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def test_0060_attach_port_group(self):
        """Attach a portgroup to an external network
       This test passes if the portgroup from another vCenter is added
       to external network successfully.
       """
        if TestExtNet._vc2_host_ip is None or TestExtNet._vc2_host_ip == '':
            return
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        vc_name = TestExtNet._config['vc2']['vcenter_host_name']
        portgrouphelper = PortgroupHelper(TestExtNet._sys_admin_client)
        pg_name = portgrouphelper.get_available_portgroup_name(
            vc_name, TestExtNet._portgroupType)

        ext_net = self._get_ext_net(platform).attach_port_group(
            vc_name,
            pg_name)
        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Attach a portgroup to an external network'
            + TestExtNet._name + '.')
        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        vc_record = platform.get_vcenter(vc_name)
        vc_href = vc_record.get('href')
        vim_port_group_refs = \
            ext_net['{' + NSMAP['vmext'] + '}VimPortGroupRefs']
        vc_href_found = False
        for vim_obj_ref in vim_port_group_refs.VimObjectRef:
            if vim_obj_ref.VimServerRef.get('href') == vc_href:
                vc_href_found = True
                break
        self.assertTrue(vc_href_found)
开发者ID:vmware,项目名称:pyvcloud,代码行数:37,代码来源:extnet_tests.py

示例5: test_0055_delete_ip_range

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def test_0055_delete_ip_range(self):
        """Test the method externalNetwork.delete_ip_range()
       Delete ip range of a subnet in external network
       This test passes if the ip range for a subnet is
       deleted successfully.
       """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)
        ext_net = self._get_ext_net(platform).delete_ip_range(
            TestExtNet._gateway2,
            [TestExtNet._ip_range4])

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Deleted ip-range of a subnet in external network'
            + TestExtNet._name + '.')

        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
        ip_scope = config.IpScopes.IpScope
        for scope in ip_scope:
            if scope.Gateway == TestExtNet._gateway2:
                ip_scope = scope
                break
        self.assertIsNotNone(ip_scope)
        self.assertFalse(self.__validate_ip_range(ip_scope,
                                                  TestExtNet._ip_range4))
开发者ID:vmware,项目名称:pyvcloud,代码行数:32,代码来源:extnet_tests.py

示例6: test_0030_enable_subnet

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def test_0030_enable_subnet(self):
        """Test the method externalNetwork.enable_subnet()

        Enable subnet of external network

        This test passes if subnet is enabled successfully.
        """
        logger = Environment.get_default_logger()
        platform = Platform(TestExtNet._sys_admin_client)

        ext_net = self._get_ext_net(platform).enable_subnet(
            TestExtNet._gateway2, True)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestExtNet._sys_admin_client.get_task_monitor().wait_for_success(
            task=task)
        logger.debug(
            'Enabled subnet of external network ' + TestExtNet._name + '.')

        ext_net = platform.get_external_network(self._name)
        self.assertIsNotNone(ext_net)
        config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
        ip_scope = config.IpScopes.IpScope
        for scope in ip_scope:
            if scope.Gateway == TestExtNet._gateway2:
                ip_scope = scope
                break
        self.assertIsNotNone(ip_scope)
        self.assertEqual(ip_scope.IsEnabled, True)
开发者ID:vmware,项目名称:pyvcloud,代码行数:31,代码来源:extnet_tests.py

示例7: test_0070_list_available_pvdc_with_filter

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
 def test_0070_list_available_pvdc_with_filter(self):
     """List available provider Vdcs.
     """
     platform = Platform(TestExtNet._sys_admin_client)
     ext_net_resource = platform.get_external_network(
         TestExtNet._common_ext_net_name)
     extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                  resource=ext_net_resource)
     pvdc_name_list = extnet_obj.list_provider_vdc('name==*')
开发者ID:vmware,项目名称:pyvcloud,代码行数:11,代码来源:extnet_tests.py

示例8: test_0090_list_allocated_ip_with_gateway_filter

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
 def test_0090_list_allocated_ip_with_gateway_filter(self):
     """List allocated ips.
     """
     platform = Platform(TestExtNet._sys_admin_client)
     ext_net_name = TestExtNet._config['external_network']['name']
     ext_net_resource = platform.get_external_network(ext_net_name)
     extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                  resource=ext_net_resource)
     allocated_ip_dict = extnet_obj.list_allocated_ip_address('name==*')
     self.assertTrue(len(allocated_ip_dict) > 0)
开发者ID:vmware,项目名称:pyvcloud,代码行数:12,代码来源:extnet_tests.py

示例9: test_0080_list_available_gateways_with_filter

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
 def test_0080_list_available_gateways_with_filter(self):
     """List available gateways.
     """
     platform = Platform(TestExtNet._sys_admin_client)
     ext_net_name = TestExtNet._config['external_network']['name']
     ext_net_resource = platform.get_external_network(ext_net_name)
     extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                  resource=ext_net_resource)
     gateway_name_list = extnet_obj.list_extnw_gateways('name==*')
     self.assertTrue(len(gateway_name_list) > 0)
开发者ID:vmware,项目名称:pyvcloud,代码行数:12,代码来源:extnet_tests.py

示例10: test_0095_list_sub_allocated_ip

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
 def test_0095_list_sub_allocated_ip(self):
     """List sub allocated ip.
     """
     self.__add_sub_allocate_ip_pool()
     platform = Platform(TestExtNet._sys_admin_client)
     ext_net_name = TestExtNet._config['external_network']['name']
     ext_net_resource = platform.get_external_network(ext_net_name)
     extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                  resource=ext_net_resource)
     sub_allocated_ip_dict = extnet_obj.list_gateway_ip_suballocation()
     self.assertTrue(len(sub_allocated_ip_dict) > 0)
开发者ID:vmware,项目名称:pyvcloud,代码行数:13,代码来源:extnet_tests.py

示例11: test_0096_list_sub_allocated_ip_with_gateway_filter

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
 def test_0096_list_sub_allocated_ip_with_gateway_filter(self):
     """List sub allocated ips.
     """
     platform = Platform(TestExtNet._sys_admin_client)
     ext_net_name = TestExtNet._config['external_network']['name']
     ext_net_resource = platform.get_external_network(ext_net_name)
     extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                  resource=ext_net_resource)
     sub_allocated_ip_dict = \
         extnet_obj.list_gateway_ip_suballocation('name==*')
     self.assertTrue(len(sub_allocated_ip_dict) > 0)
     self.__remove_sub_allocate_ip_pool()
开发者ID:vmware,项目名称:pyvcloud,代码行数:14,代码来源:extnet_tests.py

示例12: test_0105_list_vsphere_network

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
 def test_0105_list_vsphere_network(self):
     """List associated vSphere Networks.
     """
     platform = Platform(TestExtNet._sys_admin_client)
     ext_net_resource = platform.get_external_network(
         TestExtNet._name)
     extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                  resource=ext_net_resource)
     portgroup_name = 'VM Network'
     vSphere_network_list = \
         extnet_obj.list_vsphere_network('name==' + portgroup_name)
     match_found = False
     for dic in vSphere_network_list:
         if dic['Name'] == portgroup_name:
             match_found = True
     self.assertTrue(match_found)
开发者ID:vmware,项目名称:pyvcloud,代码行数:18,代码来源:extnet_tests.py

示例13: test_0100_list_associated_direct_org_vdc_networks

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
 def test_0100_list_associated_direct_org_vdc_networks(self):
     """List associated direct org vDC networks
     """
     platform = Platform(TestExtNet._sys_admin_client)
     ext_net_resource = platform.get_external_network(
         TestExtNet._common_ext_net_name)
     extnet_obj = ExternalNetwork(TestExtNet._sys_admin_client,
                                  resource=ext_net_resource)
     ovdc_network_name = 'test-direct-vdc-network'
     filter = 'name==' + ovdc_network_name
     direct_ovdc_networks = \
         extnet_obj.list_associated_direct_org_vdc_networks(filter)
     match_found = False
     if ovdc_network_name in direct_ovdc_networks:
         match_found = True
     self.assertTrue(match_found)
开发者ID:vmware,项目名称:pyvcloud,代码行数:18,代码来源:extnet_tests.py

示例14: create_directly_connected_vdc_network

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def create_directly_connected_vdc_network(self,
                                              network_name,
                                              parent_network_name,
                                              description=None,
                                              is_shared=None):
        """Create a new directly connected OrgVdc network in this vdc.

        :param network_name: (str): Name of the new network
        :param parent_network_name: (str): Name of the external network
            that the new network will be directly connected to
        :param description: (str): Description of the new network
        :param is_shared: (bool): True, is the network is shared with
            other vdc(s) in the organization else False
        :return: A :class:`lxml.objectify.StringElement` object representing
            a sparsely populated OrgVdcNetwork element.
        """

        if self.resource is None:
            self.resource = self.client.get_resource(self.href)

        platform = Platform(self.client)
        parent_network = platform.get_external_network(parent_network_name)
        parent_network_href = parent_network.get('href')

        request_payload = E.OrgVdcNetwork(name=network_name)
        if description is not None:
            request_payload.append(E.Description(description))
        vdc_network_configuration = E.Configuration()
        vdc_network_configuration.append(
            E.ParentNetwork(href=parent_network_href))
        vdc_network_configuration.append(E.FenceMode('bridged'))
        request_payload.append(vdc_network_configuration)
        if is_shared is not None:
            request_payload.append(E.IsShared(is_shared))

        return self.client.post_linked_resource(
            self.resource, RelationType.ADD, EntityType.ORG_VDC_NETWORK.value,
            request_payload)
开发者ID:rdbwebster,项目名称:pyvcloud,代码行数:40,代码来源:vdc.py

示例15: add_subnet

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import get_external_network [as 别名]
    def add_subnet(self,
                   name,
                   gateway_ip,
                   netmask,
                   ip_ranges,
                   primary_dns_ip=None,
                   secondary_dns_ip=None,
                   dns_suffix=None):
        """Add subnet to an external network.

        :param str name: Name of external network.

        :param str gateway_ip: IP address of the gateway of the new network.

        :param str netmask: Netmask of the gateway.

        :param list ip_ranges: list of IP ranges used for static pool
            allocation in the network. For example, [192.168.1.2-192.168.1.49,
            192.168.1.100-192.168.1.149].

        :param str primary_dns_ip: IP address of primary DNS server.

        :param str secondary_dns_ip: IP address of secondary DNS Server.

        :param str dns_suffix: DNS suffix.

        :rtype: lxml.objectify.ObjectifiedElement
        """
        if self.resource is None:
            self.reload()

        platform = Platform(self.client)
        ext_net = platform.get_external_network(name)
        config = ext_net['{' + NSMAP['vcloud'] + '}Configuration']
        ip_scopes = config.IpScopes

        ip_scope = E.IpScope()
        ip_scope.append(E.IsInherited(False))
        ip_scope.append(E.Gateway(gateway_ip))
        ip_scope.append(E.Netmask(netmask))
        if primary_dns_ip is not None:
            ip_scope.append(E.Dns1(primary_dns_ip))
        if secondary_dns_ip is not None:
            ip_scope.append(E.Dns2(secondary_dns_ip))
        if dns_suffix is not None:
            ip_scope.append(E.DnsSuffix(dns_suffix))
        ip_scope.append(E.IsEnabled(True))
        e_ip_ranges = E.IpRanges()
        for ip_range in ip_ranges:
            e_ip_range = E.IpRange()
            ip_range_token = ip_range.split('-')
            e_ip_range.append(E.StartAddress(ip_range_token[0]))
            e_ip_range.append(E.EndAddress(ip_range_token[1]))
            e_ip_ranges.append(e_ip_range)
        ip_scope.append(e_ip_ranges)
        ip_scopes.append(ip_scope)

        return self.client.put_linked_resource(
            ext_net,
            rel=RelationType.EDIT,
            media_type=EntityType.EXTERNAL_NETWORK.value,
            contents=ext_net)
开发者ID:vmware,项目名称:pyvcloud,代码行数:64,代码来源:external_network.py


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