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


Python VirtualNetwork.del_virtual_network方法代码示例

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


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

示例1: test_provider_network

# 需要导入模块: from vnc_api.vnc_api import VirtualNetwork [as 别名]
# 或者: from vnc_api.vnc_api.VirtualNetwork import del_virtual_network [as 别名]
    def test_provider_network(self):
        '''
        Verify:
            1. Check creating a non-provider VNs with
               non-provider VNs connected to it is not allowed
            2. Check a non provider-VN can not be created
               with is_provider_network property set to True
            3. Check is_provider_network property of a
               provider-VN is True by default
            4. Check is_provider_network property of a
               provider-VN can be set as True
            5. Check is_provider_network property of provider-VN
               can not be set as False
            6. Check is_provider_network property of non provider-VN
               can  not be set as True
            7. Check is_provider_network property of non provider-VN
               can be set as False
            8. Check setting other parameters of a non provider-VN
               is not affected
            9. Check db_resync sets is_provider_network property
               of provider-VN as True (simulating upgrade case)
            10. Check non provider VNs can be added to
               provider VN
            11. Check the provider-VN can be added to a VN
            12. Check non provider-VN can not be added to a VN
            13. Check many VNs can be linked to the provider-VN
            14. Check (provider-vn -> any-VN),DENY acl rule is added to
               the provider-VN
            15. Check (VN -> provider-VN),DENY acl rule is added to
               the VN
            16. Adding a (VN -> provider-VN),PASS acl rule at VN removes
               (VN -> provider-VN),DENY acl rule
        Assumption: ip-fabric VN is the provider-VN
        '''
        # create two VNs - vn1, vn2
        vn1_name = self.id() + '_vn1'
        vn2_name = self.id() + '_vn2'
        vn3_name = self.id() + '_vn3'
        vn4_name = self.id() + '_vn4'
        vn1_obj1 = VirtualNetwork(vn1_name)
        vn2_obj1 = VirtualNetwork(vn2_name)
        vn3_obj1 = VirtualNetwork(vn3_name)
        vn4_obj1 = VirtualNetwork(vn4_name)
        self._vnc_lib.virtual_network_create(vn1_obj1)
        self._vnc_lib.virtual_network_create(vn2_obj1)
        self._vnc_lib.virtual_network_create(vn3_obj1)

        # try creating non provider_vn with linked
        # non provider_vn (linked before creating)
        vn4_obj1.add_virtual_network(vn3_obj1)
        self.assertRaises(BadRequest,
                          self._vnc_lib.virtual_network_create,
                          vn4_obj1)

        vn4_obj1.add_virtual_network(vn2_obj1)
        self.assertRaises(BadRequest,
                          self._vnc_lib.virtual_network_create,
                          vn4_obj1)

        # remove vn3_obj1 and vn2_obj1
        # as its not allowed
        vn4_obj1.del_virtual_network(vn3_obj1)
        vn4_obj1.del_virtual_network(vn2_obj1)

        # set is_provider_network on a non provider-vn
        # and try creating it
        vn4_obj1.set_is_provider_network(True)
        self.assertRaises(BadRequest,
                          self._vnc_lib.virtual_network_create,
                          vn4_obj1)

        # set it as False and retry creating it
        vn4_obj1.set_is_provider_network(False)
        self._vnc_lib.virtual_network_create(vn4_obj1)

        # Check updating other parameters of a non provider VN
        # when no provider VN is not connected
        vn4_obj1.set_mac_aging_time(400)
        self._vnc_lib.virtual_network_update(vn4_obj1)

        # retrieve provider network, assuming ip-fabric for now
        provider_fq_name = ['default-domain', 'default-project', 'ip-fabric']
        provider_vn = self._vnc_lib.virtual_network_read(
                fq_name=provider_fq_name)
        self.assertEqual(provider_vn.get_is_provider_network(), True)

        # check is_provider_network of provider_vn
        # can be set to True (ie only as its default)
        provider_vn.set_is_provider_network(True)
        self._vnc_lib.virtual_network_update(provider_vn)

        # check is_provider_network of provider_vn
        # can not be set to False
        provider_vn.set_is_provider_network(False)
        self.assertRaises(BadRequest,
                          self._vnc_lib.virtual_network_update,
                          provider_vn)

        # check is_provider_network of non provider_vn
        # can be set to False
#.........这里部分代码省略.........
开发者ID:Juniper,项目名称:contrail-controller,代码行数:103,代码来源:test_policy.py


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