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


Python Platform.create_external_network方法代码示例

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


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

示例1: test_0000_setup

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import create_external_network [as 别名]
    def test_0000_setup(self):
        """
        Create one external network as per the configuration stated aboveself.

        Choose first unused port group which is not a VxLAN. Unused port groups
        have network names set to '--'. VxLAN port groups have name starting
        with 'vxw-'.

        Test the method Platform.create_external_network().

        This test passes if external network is created successfully.
        """
        logger = Environment.get_default_logger()
        TestExtNet._sys_admin_client = Environment.get_sys_admin_client()
        TestExtNet._config = Environment.get_config()
        TestExtNet._common_ext_net_name = TestExtNet._config[
            'external_network']['name']

        platform = Platform(TestExtNet._sys_admin_client)
        vc_name = TestExtNet._config['vc']['vcenter_host_name']
        TestExtNet._vc2_host_ip = TestExtNet._config['vc2']['vcenter_host_ip']
        portgrouphelper = PortgroupHelper(TestExtNet._sys_admin_client)
        pg_name = portgrouphelper.get_available_portgroup_name(
            vc_name, TestExtNet._portgroupType)

        ext_net = platform.create_external_network(
            name=TestExtNet._name,
            vim_server_name=vc_name,
            port_group_names=[pg_name],
            gateway_ip=TestExtNet._gateway,
            netmask=TestExtNet._netmask,
            ip_ranges=[TestExtNet._ip_range],
            description=TestExtNet._description,
            primary_dns_ip=TestExtNet._dns1,
            secondary_dns_ip=TestExtNet._dns2,
            dns_suffix=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('Created external network ' + TestExtNet._name + '.')
开发者ID:vmware,项目名称:pyvcloud,代码行数:44,代码来源:extnet_tests.py

示例2: _create_external_network

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import create_external_network [as 别名]
    def _create_external_network(cls):
        vc_name = cls._config['vc']['vcenter_host_name']
        portgrouphelper = PortgroupHelper(cls._sys_admin_client)
        port_group = portgrouphelper.get_available_portgroup_name(
            vc_name, Environment._portgroupType)

        if port_group is None:
            raise Exception(
                'None of the port groups are free for new network.')

        ext_config = cls._config['external_network']
        ip_scopes = cls._config['external_network']['ip_scopes']
        if len(ip_scopes) == 0:
            raise Exception('No network spec provided.')
        # [{subnet:'10.10.10.1/24', ip_range:'10.10.10.101-10.10.10.150'}]
        primary_subnet = ip_scopes[0]['subnet']
        gateway_ip, prefix_len = primary_subnet.split('/')
        netmask = cidr_to_netmask(primary_subnet)[1]
        ip_ranges = ip_scopes[0]['ip_ranges']
        primary_dns_ip = '8.8.8.8'
        secondary_dns_ip = '8.8.8.9'
        dns_suffix = 'example.com'
        platform = Platform(cls._sys_admin_client)
        ext_net = platform.create_external_network(
            name=ext_config['name'],
            vim_server_name=vc_name,
            port_group_names=[port_group],
            gateway_ip=gateway_ip,
            netmask=netmask,
            ip_ranges=ip_ranges,
            description=ext_config['name'],
            primary_dns_ip=primary_dns_ip,
            secondary_dns_ip=secondary_dns_ip,
            dns_suffix=dns_suffix)

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        cls._sys_admin_client.get_task_monitor().wait_for_success(task=task)
        return ext_net
开发者ID:vmware,项目名称:pyvcloud,代码行数:40,代码来源:environment.py

示例3: _create_external_network

# 需要导入模块: from pyvcloud.vcd.platform import Platform [as 别名]
# 或者: from pyvcloud.vcd.platform.Platform import create_external_network [as 别名]
    def _create_external_network(self):
        """Creates an external network from the available portgroup."""
        vc_name = TestGateway._config['vc']['vcenter_host_name']
        name_filter = ('vcName', vc_name)
        query = TestGateway._client.get_typed_query(
            ResourceType.PORT_GROUP.value,
            query_result_format=QueryResultFormat.RECORDS,
            equality_filter=name_filter)

        port_group = None
        for record in list(query.execute()):
            if record.get('networkName') == '--':
                if not record.get('name').startswith('vxw-'):
                    port_group = record.get('name')
                    break

        if port_group is None:
            raise Exception(
                'None of the port groups are free for new network.')

        name = 'external_network_' + str(uuid1())
        platform = Platform(TestGateway._client)
        ext_net = platform.create_external_network(
            name=name,
            vim_server_name=vc_name,
            port_group_names=[port_group],
            gateway_ip='10.10.30.1',
            netmask='255.255.255.0',
            ip_ranges=['10.10.30.101-10.10.30.150'],
            description=name,
            primary_dns_ip='8.8.8.8',
            secondary_dns_ip='8.8.8.9',
            dns_suffix='example.com')

        task = ext_net['{' + NSMAP['vcloud'] + '}Tasks'].Task[0]
        TestGateway._client.get_task_monitor().wait_for_success(task=task)
        TestGateway._external_network2 = ext_net
        return ext_net
开发者ID:vmware,项目名称:pyvcloud,代码行数:40,代码来源:gateway_tests.py


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