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


Python VDC.list_orgvdc_network_resources方法代码示例

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


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

示例1: add_network

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import list_orgvdc_network_resources [as 别名]
    def add_network(self):
        network_name = self.params.get('network')
        fence_mode = self.params.get('fence_mode')
        parent_network = self.params.get('parent_network')
        ip_scope = self.params.get('ip_scope')

        response = dict()
        response['changed'] = False

        try:
            self.get_network()
        except EntityNotFoundException:
            network_config_section = self.vapp.resource.NetworkConfigSection
            config = E.Configuration()
            if parent_network:
                vdc = self.params.get('vdc')
                org_resource = Org(self.client, resource=self.client.get_org())
                vdc_resource = VDC(self.client, resource=org_resource.get_vdc(vdc))
                orgvdc_networks = vdc_resource.list_orgvdc_network_resources(parent_network)
                parent = next((network for network in orgvdc_networks if network.get('name') == parent_network), None)
                if parent:
                    config.append(E.ParentNetwork(href=parent.get('href')))
                else:
                    raise EntityNotFoundException('Parent network \'%s\' does not exist'.format(parent_network))
            elif ip_scope:
                scope = E.IpScope(
                    E.IsInherited('false'),
                    E.Gateway(str(ip_network(ip_scope, strict=False).network_address+1)),
                    E.Netmask(str(ip_network(ip_scope, strict=False).netmask)))
                config.append(E.IpScopes(scope))
            else:
                raise VappNetworkCreateError('Either parent_network or ip_scope must be set')
            config.append(E.FenceMode(fence_mode))

            network_config = E.NetworkConfig(config, networkName=network_name)
            network_config_section.append(network_config)

            add_network_task = self.client.put_linked_resource(
                self.vapp.resource.NetworkConfigSection, RelationType.EDIT,
                EntityType.NETWORK_CONFIG_SECTION.value,
                network_config_section)
            self.execute_task(add_network_task)
            response['msg'] = 'Vapp Network {} has been added'.format(network_name)
            response['changed'] = True
        else:
            response['warnings'] = 'Vapp Network {} is already present.'.format(network_name)

        return response
开发者ID:equinix-ms,项目名称:ansible-module-vcloud-director,代码行数:50,代码来源:vcd_vapp_network.py

示例2: print

# 需要导入模块: from pyvcloud.vcd.vdc import VDC [as 别名]
# 或者: from pyvcloud.vcd.vdc.VDC import list_orgvdc_network_resources [as 别名]
                # state we need to wait.
                if item_dict['status'] != "RESOLVED":
                    print("Template unresolved: {0} {1} {2}".format(
                        item_dict['catalogName'],
                        item_dict['name'], item_dict['status']))
                    find_unresolved = True
                    time.sleep(3)

print("No unresolved templates found")

# Check for desired networks and create them if they don't exist.
# (We might add other kinds of networks later.)
if cfg.networks.get("isolated"):
    print("Checking isolated networks...")
    for network in cfg.networks['isolated']:
        isolated_network_list = vdc.list_orgvdc_network_resources(
            name=network['network_name'], type=FenceMode.ISOLATED.value)
        if len(isolated_network_list) > 0:
            print("Isolated network exists: {0}".format(
                network['network_name']))
        else:
            # Create the network in the vDC.
            print("Network does not exist, creating: {0}".format(
                network['network_name']))
            network_resource = vdc.create_isolated_vdc_network(**network)
            handle_task(client, network_resource.Tasks.Task[0])
            print("Network created")

            # Ensure the network is visible in the VDC.
            network_exists = False
            while not network_exists:
                new_network_list = vdc.list_orgvdc_network_resources(
开发者ID:vmware,项目名称:pyvcloud,代码行数:34,代码来源:tenant-onboard.py


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