• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vnc_api.VirtualNetwork类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_network

    def create_network(self, name, proj_obj, pod_subnet, service_subnet):
        vn = VirtualNetwork(
            name=name, parent_obj=proj_obj,
            virtual_network_properties=VirtualNetworkType(forwarding_mode='l3'),
            address_allocation_mode='user-defined-subnet-only')

        try:
            vn_obj = self._vnc_lib.virtual_network_read(
                fq_name=vn.get_fq_name())
        except NoIdError:
            # Virtual network does not exist. Create one.
            vn_uuid = self._vnc_lib.virtual_network_create(vn)
            vn_obj = self._vnc_lib.virtual_network_read(id=vn_uuid)

        pod_ipam_obj = self._create_network_ipam('pod-ipam', 'flat-subnet',
                                                 pod_subnet, proj_obj, vn_obj)
        self._create_network_ipam('service-ipam', '', service_subnet, proj_obj,
                                  vn_obj)
        try:
            self._vnc_lib.virtual_network_update(vn_obj)
        except Exception as e:
            self.logger.error("%s - failed to update virtual network %s %s. %s"
                              % (self._name, vn_obj.uuid, str(vn_obj.fq_name),
                                 str(e)))

        vn_obj = self._vnc_lib.virtual_network_read(
            fq_name=vn_obj.get_fq_name())
        kube = vnc_kubernetes.VncKubernetes.get_instance()
        kube._create_cluster_service_fip_pool(vn_obj, pod_ipam_obj)

        return vn_obj
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:31,代码来源:test_case.py


示例2: test_unset_tag_from_a_resource

    def test_unset_tag_from_a_resource(self):
        project = Project('project-%s' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        vn_uuid = self.api.virtual_network_create(vn)

        type = 'fake_type-%s' % self.id()
        value = 'fake_value-%s' % self.id()
        tag = Tag(tag_type_name=type, tag_value=value, parent_obj=project)
        self.api.tag_create(tag)

        self.api.set_tag(vn, type, value)
        for system_type in constants.TagTypeNameToId:
            self.api.tag_create(
                Tag(tag_type_name=system_type, tag_value=value))
            self.api.set_tag(vn, system_type, value, is_global=True)

        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertEqual(len(vn.get_tag_refs()),
                         len(constants.TagTypeNameToId) + 1)
        self.assertTrue(tag.uuid in {ref['uuid'] for ref in vn.get_tag_refs()})

        self.api.unset_tag(vn, type)

        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertEqual(len(vn.get_tag_refs()),
                         len(constants.TagTypeNameToId))
        self.assertFalse(tag.uuid in
                         {ref['uuid'] for ref in vn.get_tag_refs()})
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:29,代码来源:test_tag.py


示例3: test_deallocate_vxlan_id

    def test_deallocate_vxlan_id(self):
        # enable vxlan routing on project
        proj = self._vnc_lib.project_read(
            fq_name=["default-domain", "default-project"])
        proj.set_vxlan_routing(True)
        self._vnc_lib.project_update(proj)

        mock_zk = self._api_server._db_conn._zk_db
        vn_obj = VirtualNetwork('%s-vn' % self.id())

        vn_obj_properties = VirtualNetworkType(forwarding_mode='l3')
        vn_obj_properties.set_vxlan_network_identifier(6002)
        vn_obj.set_virtual_network_properties(vn_obj_properties)

        self.api.virtual_network_create(vn_obj)

        # VN created, now read back the VN data to check if vxlan_id is set
        vn_obj = self.api.virtual_network_read(id=vn_obj.uuid)
        vn_obj_properties = vn_obj.get_virtual_network_properties()
        if not vn_obj_properties:
            self.fail("VN properties are not set")
        vxlan_id = vn_obj_properties.get_vxlan_network_identifier()
        self.assertEqual(vxlan_id, 6002)

        self.api.virtual_network_delete(id=vn_obj.uuid)
        self.assertNotEqual(vn_obj.get_fq_name_str() + "_vxlan",
                            mock_zk.get_vn_from_id(vxlan_id))
        logger.debug('PASS - test_deallocate_vxlan_id')
开发者ID:rombie,项目名称:contrail-controller,代码行数:28,代码来源:test_virtual_network.py


示例4: test_create_pool

    def test_create_pool(self):
        tenant_id = _uuid()
        pool_id = _uuid()
        vip_id = _uuid()
        subnet_id = _uuid()

        api = self.api_server

        project = Project(name='test')
        project.uuid = tenant_id
        template = ServiceTemplate('lb-test', project)
        template.uuid = _uuid()

        pool_attrs = LoadbalancerPoolType()
        pool_attrs.subnet_id = subnet_id
        pool = LoadbalancerPool(
            pool_id, project, loadbalancer_pool_properties=pool_attrs)
        pool.uuid = pool_id

        vip_attrs = VirtualIpType()
        vip_attrs.subnet_id = subnet_id
        vip_attrs.address = '127.0.0.1'
        vip = VirtualIp(vip_id, project, virtual_ip_properties=vip_attrs)
        vip.uuid = vip_id
        vip.set_loadbalancer_pool(pool)

        vnet = VirtualNetwork('test', project)
        vnet.uuid = _uuid()

        vmi = VirtualMachineInterface(vip_id, project)
        vmi.uuid = _uuid()
        vmi.set_virtual_network(vnet)
        iip = InstanceIp(vip_id, instance_ip_address='127.0.0.1')
        iip.uuid = _uuid()
        iip.set_virtual_machine_interface(vmi)

        iip_refs = [
            {'to': iip.get_fq_name(), 'uuid': iip.uuid}
        ]
        vmi.get_instance_ip_back_refs = mock.Mock()
        vmi.get_instance_ip_back_refs.return_value = iip_refs

        vip.set_virtual_machine_interface(vmi)

        api.virtual_service_template_read = template
        api.loadbalancer_pool_read.return_value = pool
        api.virtual_ip_read.return_value = vip
        api.kv_retrieve.return_value = '%s %s' % (vnet.uuid, subnet_id)
        api.virtual_machine_interface_read.return_value = vmi
        api.instance_ip_read.return_value = iip
        api.service_instance_read.side_effect = NoIdError('404')

        context = {}
        pool_data = {
            'id': pool_id,
            'vip_id': vip_id
        }
        self.driver.create_pool(context, pool_data)
        api.service_instance_create.assert_called_with(mock.ANY)
开发者ID:achanda,项目名称:contrail-neutron-plugin,代码行数:59,代码来源:test_driver.py


示例5: _create_virtual_network

    def _create_virtual_network(self, vn_name, proj_obj, ipam_obj, \
                ipam_update, provider=None, subnets=None, \
                type='flat-subnet-only'):
        vn_exists = False
        vn = VirtualNetwork(name=vn_name, parent_obj=proj_obj,
                 address_allocation_mode=type)
        try:
            vn_obj = self._vnc_lib.virtual_network_read(
                fq_name=vn.get_fq_name())
            vn_exists = True
        except NoIdError:
            # VN does not exist. Create one.
            vn_obj = vn

        if vn_exists:
            return vn_obj

        # Attach IPAM to virtual network.
        #
        # For flat-subnets, the subnets are specified on the IPAM and
        # not on the virtual-network to IPAM link. So pass an empty
        # list of VnSubnetsType.
        # For user-defined-subnets, use the provided subnets
        if ipam_update or \
           not self._is_ipam_exists(vn_obj, ipam_obj.get_fq_name()):
           if subnets and type == 'user-defined-subnet-only':
               vn_obj.add_network_ipam(ipam_obj, subnets)
           else:
               vn_obj.add_network_ipam(ipam_obj, VnSubnetsType([]))

        vn_obj.set_virtual_network_properties(
             VirtualNetworkType(forwarding_mode='l3'))

        fabric_snat = False
        if self.ip_fabric_snat:
            fabric_snat = True

        if not vn_exists:
            if self.ip_fabric_forwarding:
                if provider:
                    #enable ip_fabric_forwarding
                    vn_obj.add_virtual_network(provider)
            elif fabric_snat:
                #enable fabric_snat
                vn_obj.set_fabric_snat(True)
            else:
                #disable fabric_snat
                vn_obj.set_fabric_snat(False)
            # Create VN.
            self._vnc_lib.virtual_network_create(vn_obj)
        else:
            # TODO: Handle Network update
            pass

        vn_obj = self._vnc_lib.virtual_network_read(
            fq_name=vn_obj.get_fq_name())
        VirtualNetworkKM.locate(vn_obj.uuid)

        return vn_obj
开发者ID:rombie,项目名称:contrail-controller,代码行数:59,代码来源:vnc_network.py


示例6: test_create_vn_with_configured_rt_in_system_range

    def test_create_vn_with_configured_rt_in_system_range(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        vn = VirtualNetwork('%s-vn' % self.id())
        rt_name = 'target:%d:%d' % (gsc.autonomous_system,
                                    BGP_RTGT_MIN_ID + 1000)
        vn.set_route_target_list(RouteTargetList([rt_name]))

        self.assertRaises(BadRequest, self.api.virtual_network_create, vn)
开发者ID:rombie,项目名称:contrail-controller,代码行数:8,代码来源:test_virtual_network.py


示例7: test_only_one_value_for_a_type_can_be_associate_to_a_resource2

    def test_only_one_value_for_a_type_can_be_associate_to_a_resource2(self):
        project = Project('project-%s' % self.id())
        self.api.project_create(project)
        tag_type = 'fake_type-%s' % self.id()
        global_tag = Tag(tag_type_name=tag_type,
                         tag_value='global_fake_value-%s' % self.id())
        self.api.tag_create(global_tag)
        scoped_tag = Tag(tag_type_name=tag_type,
                         tag_value='scoped_fake_value-%s' % self.id(),
                         parent_obj=project)
        self.api.tag_create(scoped_tag)

        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        vn.add_tag(global_tag)
        vn.add_tag(scoped_tag)
        self.assertRaises(BadRequest, self.api.virtual_network_create, vn)

        vn.set_tag(global_tag)
        self.api.virtual_network_create(vn)
        vn = self._vnc_lib.virtual_network_read(id=vn.uuid)
        self.assertEqual(len(vn.get_tag_refs()), 1)
        self.assertEqual(vn.get_tag_refs()[0]['uuid'], global_tag.uuid)

        vn.add_tag(scoped_tag)
        self.assertRaises(BadRequest, self.api.virtual_network_update, vn)
开发者ID:Juniper,项目名称:contrail-controller,代码行数:25,代码来源:test_tag.py


示例8: test_deallocate_vn_id

    def test_deallocate_vn_id(self):
        mock_zk = self._api_server._db_conn._zk_db
        vn_obj = VirtualNetwork('%s-vn' % self.id())
        self.api.virtual_network_create(vn_obj)
        vn_obj = self.api.virtual_network_read(id=vn_obj.uuid)
        vn_id = vn_obj.virtual_network_network_id

        self.api.virtual_network_delete(id=vn_obj.uuid)

        self.assertNotEqual(mock_zk.get_vn_from_id(vn_id),
                            vn_obj.get_fq_name_str())
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:11,代码来源:test_virtual_network.py


示例9: test_allocate_vn_id

    def test_allocate_vn_id(self):
        mock_zk = self._api_server._db_conn._zk_db
        vn_obj = VirtualNetwork('%s-vn' % self.id())

        self.api.virtual_network_create(vn_obj)

        vn_obj = self.api.virtual_network_read(id=vn_obj.uuid)
        vn_id = vn_obj.virtual_network_network_id
        self.assertEqual(vn_obj.get_fq_name_str(),
                         mock_zk.get_vn_from_id(vn_id))
        self.assertGreaterEqual(vn_id, VNID_MIN_ALLOC)
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:11,代码来源:test_virtual_network.py


示例10: create_network

    def create_network(self, name, proj_obj):
        vn = VirtualNetwork(
            name=name,
            parent_obj=proj_obj,
            virtual_network_properties=VirtualNetworkType(forwarding_mode='l3'),
            address_allocation_mode='flat-subnet-only')
        try:
            vn_obj = self._vnc_lib.virtual_network_read(
                fq_name=vn.get_fq_name())

        except NoIdError:
            # Virtual network does not exist. Create one.
            uid = self._vnc_lib.virtual_network_create(vn)
            vn_obj = self._vnc_lib.virtual_network_read(id=uid)
        return vn_obj
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:15,代码来源:test_case.py


示例11: test_cannot_update_vn_id

    def test_cannot_update_vn_id(self):
        vn_obj = VirtualNetwork('%s-vn' % self.id())
        self.api.virtual_network_create(vn_obj)
        vn_obj = self.api.virtual_network_read(id=vn_obj.uuid)

        vn_obj.set_virtual_network_network_id(42)
        with ExpectedException(PermissionDenied):
            self.api.virtual_network_update(vn_obj)

        # test can update with same value, needed internally
        # TODO(ethuleau): not sure why it's needed
        vn_obj = self.api.virtual_network_read(id=vn_obj.uuid)
        vn_obj.set_virtual_network_network_id(
            vn_obj.virtual_network_network_id)
        self.api.virtual_network_update(vn_obj)
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:15,代码来源:test_virtual_network.py


示例12: test_resources_exists

 def test_resources_exists(self):
     api = VncApiMock(
         self.args.auth_user,
         self.args.auth_password,
         self.args.auth_tenant,
         self.args.vnc_endpoint_ip,
         self.args.vnc_endpoint_port,
         self.args.auth_token_url
     )
     domain_uuid = api.domain_create(Domain("default-domain"))
     domain = api.domain_read(id=domain_uuid)
     proj_uuid = api.project_create(Project("default", parent_obj=domain))
     proj = api.project_read(id=proj_uuid)
     ipam_uuid = api.network_ipam_create(NetworkIpam("pod-ipam", proj))
     ipam = api.network_ipam_read(id=ipam_uuid)
     net = VirtualNetwork("cluster-network", proj)
     net.add_network_ipam(ipam, VnSubnetsType([]))
     api.virtual_network_create(net)
     vnc_kubernetes.VncKubernetes(self.args, Mock())
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:19,代码来源:test_vnc_kubernetes.py


示例13: test_resources_exists

    def test_resources_exists(self):
        api = VncApiMock(
            self.args.auth_user,
            self.args.auth_password,
            self.args.auth_tenant,
            self.args.vnc_endpoint_ip,
            self.args.vnc_endpoint_port,
            self.args.auth_token_url
        )
        domain_fq_name = ['default-domain']
        domain = api.domain_read(fq_name=domain_fq_name)

        proj_uuid = api.project_create(Project("default", parent_obj=domain))
        proj = api.project_read(id=proj_uuid)

        # Create cluster-default-pod-network
        ipam_uuid = api.network_ipam_create(NetworkIpam("pod-ipam", proj))
        ipam = api.network_ipam_read(id=ipam_uuid)
        net = VirtualNetwork("cluster-default-pod-network", proj)
        # No subnets are associated with IPAM at this point.
        # Subnets will be updated in the IPAM, when cluster is created.
        net.add_network_ipam(ipam, VnSubnetsType([]))
        api.virtual_network_create(net)

        # Create cluster-default-service-network
        ipam_uuid = api.network_ipam_create(NetworkIpam("service-ipam", proj))
        ipam = api.network_ipam_read(id=ipam_uuid)
        net = VirtualNetwork("cluster-default-service-network", proj)
        # No subnets are associated with IPAM at this point.
        # Subnets will be updated in the IPAM, when cluster is created.
        net.add_network_ipam(ipam, VnSubnetsType([]))
        api.virtual_network_create(net)

        vnc_kubernetes.VncKubernetes(self.args, Mock())
开发者ID:Juniper,项目名称:contrail-controller,代码行数:34,代码来源:test_vnc_kubernetes.py


示例14: test_only_one_value_for_a_type_can_be_associate_to_a_resource

    def test_only_one_value_for_a_type_can_be_associate_to_a_resource(self):
        project = Project('project-%s' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        vn_uuid = self.api.virtual_network_create(vn)

        tag_type = 'fake_type-%s' % self.id()
        global_tag_value = 'global_fake_value-%s' % self.id()
        global_tag = Tag(tag_type_name=tag_type, tag_value=global_tag_value)
        self.api.tag_create(global_tag)

        tags_dict = {
            tag_type: {
                'is_global': True,
                'value': global_tag_value,
            },
        }
        self.api.set_tags(vn, tags_dict)

        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertEqual(len(vn.get_tag_refs()), 1)
        self.assertEqual(vn.get_tag_refs()[0]['uuid'], global_tag.uuid)

        scoped_tag_value = 'scoped_fake_value-%s' % self.id()
        scoped_tag = Tag(tag_type_name=tag_type, tag_value=scoped_tag_value,
                         parent_obj=project)
        self.api.tag_create(scoped_tag)

        tags_dict = {
            tag_type: {
                'value': scoped_tag_value,
            },
        }
        self.api.set_tags(vn, tags_dict)

        # Scoped tag which is the same type as the global tag but with a
        # different value, replaced the global tag ref of the VN. One at a time
        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertEqual(len(vn.get_tag_refs()), 1)
        self.assertEqual(vn.get_tag_refs()[0]['uuid'], scoped_tag.uuid)
开发者ID:Juniper,项目名称:contrail-controller,代码行数:40,代码来源:test_tag.py


示例15: test_associate_scoped_tag_to_a_resource

    def test_associate_scoped_tag_to_a_resource(self):
        project = Project('project-%s' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        vn_uuid = self.api.virtual_network_create(vn)

        type = 'fake_type-%s' % self.id()
        value = 'fake_value-%s' % self.id()
        scoped_tag = Tag(tag_type_name=type, tag_value=value,
                         parent_obj=project)
        self.api.tag_create(scoped_tag)

        tags_dict = {
            type: {
                'value': value,
            },
        }
        self.api.set_tags(vn, tags_dict)

        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertEqual(len(vn.get_tag_refs()), 1)
        self.assertEqual(vn.get_tag_refs()[0]['uuid'], scoped_tag.uuid)
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:22,代码来源:test_tag.py


示例16: _create_isolated_ns_virtual_network

    def _create_isolated_ns_virtual_network(self, ns_name, vn_name, proj_obj):
        """
        Create a virtual network for this namespace.
        """
        vn = VirtualNetwork(
            name=vn_name, parent_obj=proj_obj,
            virtual_network_properties=VirtualNetworkType(forwarding_mode='l3'),
            address_allocation_mode='flat-subnet-only')

        # Add annotatins on this isolated virtual-network.
        VirtualNetworkKM.add_annotations(self, vn, namespace=ns_name,
                                         name=ns_name, isolated='True')

        try:
            vn_uuid = self._vnc_lib.virtual_network_create(vn)
        except RefsExistError:
            vn_obj = self._vnc_lib.virtual_network_read(
                fq_name=vn.get_fq_name())
            vn_uuid = vn_obj.uuid

        # Instance-Ip for pods on this VN, should be allocated from
        # cluster pod ipam. Attach the cluster pod-ipam object
        # to this virtual network.
        ipam_fq_name = vnc_kube_config.pod_ipam_fq_name()
        ipam_obj = self._vnc_lib.network_ipam_read(
            fq_name=ipam_fq_name)
        vn.add_network_ipam(ipam_obj, VnSubnetsType([]))

        # Update VN.
        self._vnc_lib.virtual_network_update(vn)

        # Cache the virtual network.
        VirtualNetworkKM.locate(vn_uuid)

        # Cache network info in namespace entry.
        self._set_namespace_virtual_network(ns_name, vn.get_fq_name())

        return vn_uuid
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:38,代码来源:vnc_namespace.py


示例17: test_update_vxlan_id

    def test_update_vxlan_id(self):
        # enable vxlan routing on project
        proj = self._vnc_lib.project_read(
            fq_name=["default-domain", "default-project"])
        proj.set_vxlan_routing(True)
        self._vnc_lib.project_update(proj)

        vn_obj = VirtualNetwork('%s-vn' % self.id())

        vn_obj_properties = VirtualNetworkType(forwarding_mode='l3')
        vn_obj_properties.set_vxlan_network_identifier(6003)
        vn_obj_properties.set_forwarding_mode('l2_l3')
        vn_obj.set_virtual_network_properties(vn_obj_properties)

        self.api.virtual_network_create(vn_obj)

        # VN created, now read back the VN data to check if vxlan_id is set
        vn_obj_read = self.api.virtual_network_read(id=vn_obj.uuid)
        vn_obj_properties_read = vn_obj_read.get_virtual_network_properties()
        if not vn_obj_properties_read:
            self.fail("VN properties are not set")
        vxlan_id = vn_obj_properties_read.get_vxlan_network_identifier()
        self.assertEqual(vxlan_id, 6003)

        # Created VN. Now Update it with a different vxlan_id
        vn_obj_properties.set_vxlan_network_identifier(6004)
        vn_obj.set_virtual_network_properties(vn_obj_properties)
        self.api.virtual_network_update(vn_obj)

        vn_obj_read = self.api.virtual_network_read(id=vn_obj.uuid)
        vn_obj_properties_read = vn_obj_read.get_virtual_network_properties()
        if not vn_obj_properties_read:
            self.fail("VN properties are not set")
        vxlan_id = vn_obj_properties_read.get_vxlan_network_identifier()

        self.assertEqual(vxlan_id, 6004)
        self.api.virtual_network_delete(id=vn_obj.uuid)
        logger.debug('PASS - test_update_vxlan_id')
开发者ID:rombie,项目名称:contrail-controller,代码行数:38,代码来源:test_virtual_network.py


示例18: test_out_of_order_rabbit_publish

    def test_out_of_order_rabbit_publish(self):
        """ Test to make sure api-server preserves the state of the
            object even if the CREATE msg is queued after UPDATE in rabbit
        """
        self.wait_till_api_server_idle()

        api_server = test_common.vnc_cfg_api_server.server
        orig_dbe_create_publish = api_server._db_conn._msgbus.dbe_create_publish
        self.block_untill_update_publish = True
        def out_of_order_dbe_create_publish(obj_type, obj_ids, *args, **kwargs):
            if obj_type == 'virtual_network':
                while self.block_untill_update_publish:
                    gevent.sleep(1)
            return orig_dbe_create_publish(obj_type,obj_ids, *args, **kwargs)

        api_server._db_conn._msgbus.dbe_create_publish = \
                out_of_order_dbe_create_publish
        logger.info("Creating VN object, without publishing it to IFMAP.")
        vn_obj = VirtualNetwork('vn1')
        vn_obj.set_uuid(str(uuid.uuid4()))
        ipam_obj = NetworkIpam('ipam1')
        vn_obj.add_network_ipam(ipam_obj, VnSubnetsType())
        self._vnc_lib.network_ipam_create(ipam_obj)
        vn_create_greenlet = gevent.spawn(self._vnc_lib.virtual_network_create, vn_obj)
        gevent.sleep(0)
        logger.info("Update VN object, Expected to update the object in",
                    "Cassandra DB and skip publishing to IFMAP.")
        vn_obj = self._vnc_lib.virtual_network_read(id=vn_obj.uuid)
        vn_obj.display_name = 'test_update_1'
        self._vnc_lib.virtual_network_update(vn_obj)
        gevent.sleep(2)
        with testtools.ExpectedException(KeyError):
            api_server._db_conn._ifmap_db._id_to_metas[\
                    'contrail:virtual-network:default-domain:default-project:vn1']

        logger.info("Unblock create notify to amqp, Create expected to read from DB",
                    "and publish to IFMAP with the updated object info.")
        self.block_untill_update_publish = False
        vn_uuid = vn_create_greenlet.get(timeout=3)
        gevent.sleep(2)
        self.assertEqual(api_server._db_conn._ifmap_db._id_to_metas[\
                'contrail:virtual-network:default-domain:default-project:vn1'][\
                'display-name']['']._Metadata__value, 'test_update_1')

        logger.info("update after publishing to IFAMAP, Expected to publish to IFMAP")
        vn_obj.display_name = 'test_update_2'
        self._vnc_lib.virtual_network_update(vn_obj)
        gevent.sleep(2)
        self.assertEqual(api_server._db_conn._ifmap_db._id_to_metas[\
                'contrail:virtual-network:default-domain:default-project:vn1'][\
                'display-name']['']._Metadata__value, 'test_update_2')
开发者ID:eonpatapon,项目名称:contrail-controller,代码行数:51,代码来源:test_kombu.py


示例19: test_cannot_update_vxlan_id

    def test_cannot_update_vxlan_id(self):
        # enable vxlan routing on project
        proj = self._vnc_lib.project_read(
            fq_name=["default-domain", "default-project"])
        proj.set_vxlan_routing(True)
        self._vnc_lib.project_update(proj)

        vn1_obj = VirtualNetwork('%s-vn1' % self.id())

        vn1_obj_properties = VirtualNetworkType(forwarding_mode='l3')
        vn1_obj_properties.set_vxlan_network_identifier(6005)
        vn1_obj_properties.set_forwarding_mode('l2_l3')
        vn1_obj.set_virtual_network_properties(vn1_obj_properties)

        self.api.virtual_network_create(vn1_obj)

        # VN created, create second VN with different vxlan_id
        vn2_obj = VirtualNetwork('%s-vn2' % self.id())

        vn2_obj_properties = VirtualNetworkType(forwarding_mode='l3')
        vn2_obj_properties.set_vxlan_network_identifier(6006)
        vn2_obj_properties.set_forwarding_mode('l2_l3')
        vn2_obj.set_virtual_network_properties(vn2_obj_properties)

        self.api.virtual_network_create(vn2_obj)

        # Created Two VNs. Now Update it second VN with 1st VNs VXLAN_ID
        vn2_obj_properties.set_vxlan_network_identifier(6005)
        vn2_obj.set_virtual_network_properties(vn2_obj_properties)

        with ExpectedException(BadRequest):
            self.api.virtual_network_update(vn2_obj)

        vn_obj_read = self.api.virtual_network_read(id=vn2_obj.uuid)
        vn_obj_properties_read = vn_obj_read.get_virtual_network_properties()
        if not vn_obj_properties_read:
            self.fail("VN properties are not set")
        vxlan_id = vn_obj_properties_read.get_vxlan_network_identifier()
        self.assertEqual(vxlan_id, 6006)

        self.api.virtual_network_delete(id=vn2_obj.uuid)
        self.api.virtual_network_delete(id=vn1_obj.uuid)
        logger.debug('PASS - test_cannot_update_vxlan_id')
开发者ID:rombie,项目名称:contrail-controller,代码行数:43,代码来源:test_virtual_network.py


示例20: test_set_unset_multi_value_of_authorized_type_on_one_resource

    def test_set_unset_multi_value_of_authorized_type_on_one_resource(self):
        project = Project('project-%s' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        vn_uuid = self.api.virtual_network_create(vn)

        # Label tag type is the only one type authorized to be set multiple
        # time on a same resource
        type = 'label'
        value1 = '%s-label1' % self.id()
        label_tag1 = Tag(tag_type_name=type, tag_value=value1,
                         parent_obj=project)
        self.api.tag_create(label_tag1)
        value2 = '%s-label2' % self.id()
        label_tag2 = Tag(tag_type_name=type, tag_value=value2,
                         parent_obj=project)
        self.api.tag_create(label_tag2)
        value3 = '%s-label3' % self.id()
        label_tag3 = Tag(tag_type_name=type, tag_value=value3,
                         parent_obj=project)
        self.api.tag_create(label_tag3)

        tags_dict = {
            type: {
                'value': value1,
                'add_values': [value2],
            },
        }
        self.api.set_tags(vn, tags_dict)

        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertEqual(len(vn.get_tag_refs()), 2)
        self.assertEqual({ref['uuid'] for ref in vn.get_tag_refs()},
                         set([label_tag1.uuid, label_tag2.uuid]))

        tags_dict = {
            type: {
                'add_values': [value3],
                'delete_values': [value1],
            },
        }
        self.api.set_tags(vn, tags_dict)

        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertEqual(len(vn.get_tag_refs()), 2)
        self.assertEqual({ref['uuid'] for ref in vn.get_tag_refs()},
                         set([label_tag2.uuid, label_tag3.uuid]))

        self.api.unset_tag(vn, type)

        vn = self._vnc_lib.virtual_network_read(id=vn_uuid)
        self.assertIsNone(vn.get_tag_refs())
开发者ID:nischalsheth,项目名称:contrail-controller,代码行数:52,代码来源:test_tag.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vnc_api.VncApi类代码示例发布时间:2022-05-26
下一篇:
Python vnc_api.VirtualMachineInterface类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap