Пример #1
0
    def test_standard_attr_resource_parent_map(self):
        base = self._make_decl_base()

        class TagSupportModel(standard_attr.HasStandardAttributes,
                              standard_attr.model_base.HasId,
                              base):
            collection_resource_map = {'collection_name': 'member_name'}
            tag_support = True

        class TagUnsupportModel(standard_attr.HasStandardAttributes,
                                standard_attr.model_base.HasId,
                                base):
            collection_resource_map = {'collection_name2': 'member_name2'}
            tag_support = False

        class TagUnsupportModel2(standard_attr.HasStandardAttributes,
                                 standard_attr.model_base.HasId,
                                 base):
            collection_resource_map = {'collection_name3': 'member_name3'}

        parent_map = standard_attr.get_tag_resource_parent_map()
        self.assertEqual('member_name', parent_map['collection_name'])
        self.assertNotIn('collection_name2', parent_map)
        self.assertNotIn('collection_name3', parent_map)

        class DupTagSupportModel(standard_attr.HasStandardAttributes,
                                 standard_attr.model_base.HasId,
                                 base):
            collection_resource_map = {'collection_name': 'member_name'}
            tag_support = True

        with testtools.ExpectedException(RuntimeError):
            standard_attr.get_tag_resource_parent_map()
Пример #2
0
def get_tagging_supported_resources():
    # Removes some resources supported by tag, tag-ext
    parent_map = standard_attr.get_tag_resource_parent_map()
    remove_resources = [res for res in parent_map
                        if res in EXCEPTION_RESOURCES]
    for resource in remove_resources:
        del parent_map[resource]
    return parent_map
Пример #3
0
def get_tagging_supported_resources():
    # Removes some resources supported by tag, tag-ext
    parent_map = standard_attr.get_tag_resource_parent_map()
    remove_resources = [res for res in parent_map
                        if res in EXCEPTION_RESOURCES]
    for resource in remove_resources:
        del parent_map[resource]
    return parent_map
Пример #4
0
 def test_api_tag_support_is_expected(self):
     # NOTE: If this test is being modified, it means the resources for tag
     # support are extended. It changes tag support API. The API change
     # should be exposed in release note for API users. And also it should
     # be list as other tag support resources in doc/source/devref/tag.rst
     expected = ['subnets', 'trunks', 'routers', 'networks', 'policies',
                 'subnetpools', 'ports', 'security_groups', 'floatingips']
     self.assertEqual(
         set(expected),
         set(standard_attr.get_tag_resource_parent_map().keys())
     )
Пример #5
0
import webob.exc

from neutron._i18n import _
from neutron.api import extensions
from neutron.api.v2 import resource as api_resource
from neutron.db import standard_attr

TAG = 'tag'
TAGS = TAG + 's'
TAGS_ANY = TAGS + '-any'
NOT_TAGS = 'not-' + TAGS
NOT_TAGS_ANY = NOT_TAGS + '-any'
MAX_TAG_LEN = 60
TAG_PLUGIN_TYPE = 'TAG'

TAG_SUPPORTED_RESOURCES = standard_attr.get_tag_resource_parent_map()
TAG_ATTRIBUTE_MAP = {
    TAGS: {
        'allow_post': False,
        'allow_put': False,
        'is_visible': True,
        'is_filter': True
    },
    TAGS_ANY: {
        'allow_post': False,
        'allow_put': False,
        'is_visible': False,
        'is_filter': True
    },
    NOT_TAGS: {
        'allow_post': False,
Пример #6
0
from neutron._i18n import _
from neutron.api import extensions
from neutron.api.v2 import resource as api_resource
from neutron.common import rpc as n_rpc
from neutron.db import standard_attr


TAG = 'tag'
TAGS = TAG + 's'
TAGS_ANY = TAGS + '-any'
NOT_TAGS = 'not-' + TAGS
NOT_TAGS_ANY = NOT_TAGS + '-any'
MAX_TAG_LEN = 60
TAG_PLUGIN_TYPE = 'TAG'

TAG_SUPPORTED_RESOURCES = standard_attr.get_tag_resource_parent_map()
TAG_ATTRIBUTE_MAP = {
    TAGS: {'allow_post': False, 'allow_put': False,
           'is_visible': True, 'is_filter': True},
    TAGS_ANY: {'allow_post': False, 'allow_put': False,
               'is_visible': False, 'is_filter': True},
    NOT_TAGS: {'allow_post': False, 'allow_put': False,
               'is_visible': False, 'is_filter': True},
    NOT_TAGS_ANY: {'allow_post': False, 'allow_put': False,
                   'is_visible': False, 'is_filter': True},
}


class TagResourceNotFound(exceptions.NotFound):
    message = _("Resource %(resource)s %(resource_id)s could not be found.")