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


Python VirtualNetwork.get_tag_refs方法代码示例

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


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

示例1: test_unset_tag_from_a_resource

# 需要导入模块: from vnc_api.vnc_api import VirtualNetwork [as 别名]
# 或者: from vnc_api.vnc_api.VirtualNetwork import get_tag_refs [as 别名]
    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,代码行数:31,代码来源:test_tag.py

示例2: test_only_one_value_for_a_type_can_be_associate_to_a_resource2

# 需要导入模块: from vnc_api.vnc_api import VirtualNetwork [as 别名]
# 或者: from vnc_api.vnc_api.VirtualNetwork import get_tag_refs [as 别名]
    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,代码行数:27,代码来源:test_tag.py

示例3: test_set_unset_multi_value_of_authorized_type_on_one_resource

# 需要导入模块: from vnc_api.vnc_api import VirtualNetwork [as 别名]
# 或者: from vnc_api.vnc_api.VirtualNetwork import get_tag_refs [as 别名]
    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,代码行数:54,代码来源:test_tag.py

示例4: test_only_one_value_for_a_type_can_be_associate_to_a_resource

# 需要导入模块: from vnc_api.vnc_api import VirtualNetwork [as 别名]
# 或者: from vnc_api.vnc_api.VirtualNetwork import get_tag_refs [as 别名]
    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,代码行数:42,代码来源:test_tag.py

示例5: test_associate_scoped_tag_to_a_resource

# 需要导入模块: from vnc_api.vnc_api import VirtualNetwork [as 别名]
# 或者: from vnc_api.vnc_api.VirtualNetwork import get_tag_refs [as 别名]
    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,代码行数:24,代码来源:test_tag.py

示例6: test_add_remove_multi_value_of_authorized_type_on_same_resource

# 需要导入模块: from vnc_api.vnc_api import VirtualNetwork [as 别名]
# 或者: from vnc_api.vnc_api.VirtualNetwork import get_tag_refs [as 别名]
    def test_add_remove_multi_value_of_authorized_type_on_same_resource(self):
        project = Project('project-%s' % self.id())
        self.api.project_create(project)
        vn = VirtualNetwork('vn-%s' % self.id(), parent_obj=project)
        # Label tag type is the only one type authorized to be set multiple
        # time on a same resource
        tag_type = 'label'
        tag_value1 = '%s-label1' % self.id()
        label_tag1 = Tag(tag_type_name=tag_type, tag_value=tag_value1,
                         parent_obj=project)
        self.api.tag_create(label_tag1)
        tag_value2 = '%s-label2' % self.id()
        label_tag2 = Tag(tag_type_name=tag_type, tag_value=tag_value2,
                         parent_obj=project)
        self.api.tag_create(label_tag2)
        tag_value3 = '%s-label3' % self.id()
        label_tag3 = Tag(tag_type_name=tag_type, tag_value=tag_value3,
                         parent_obj=project)
        self.api.tag_create(label_tag3)

        vn.add_tag(label_tag1)
        vn.add_tag(label_tag2)
        self.api.virtual_network_create(vn)
        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]))

        vn.add_tag(label_tag3)
        self.api.virtual_network_update(vn)
        vn = self._vnc_lib.virtual_network_read(id=vn.uuid)
        self.assertEqual(len(vn.get_tag_refs()), 3)
        self.assertEqual({ref['uuid'] for ref in vn.get_tag_refs()},
                         set([label_tag1.uuid, label_tag2.uuid,
                              label_tag3.uuid]))

        vn.del_tag(label_tag2)
        self.api.virtual_network_update(vn)
        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_tag3.uuid]))
开发者ID:Juniper,项目名称:contrail-controller,代码行数:44,代码来源:test_tag.py


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