rehome shared constant

The SHARED constant is used in a number of projects [1]. This patch
rehomes the constant to neutron-lib for consumption and switches all
neutron-lib static uses of 'shared' to use the new constant.

[1] http://codesearch.openstack.org/?q=att.*%5C.SHARED

Change-Id: If123044496b54a8bfc115ab41b8506ec5d7ba5a3
This commit is contained in:
Boden R 2018-01-11 11:15:52 -07:00
parent 040565797c
commit 624d75828f
12 changed files with 89 additions and 57 deletions

View File

@ -50,13 +50,13 @@ RESOURCE_ATTRIBUTE_MAP = {
'type:string': db_constants.PROJECT_ID_FIELD_SIZE},
'required_by_policy': True,
'is_visible': True},
'shared': {'allow_post': True,
'allow_put': True,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True,
'required_by_policy': True,
'enforce_policy': True},
constants.SHARED: {'allow_post': True,
'allow_put': True,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True,
'required_by_policy': True,
'enforce_policy': True},
'ip_version': {'allow_post': True, 'allow_put': False,
'convert_to': converters.convert_to_int,
'validate': {'type:values': [4, 6]},

View File

@ -10,6 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants
KNOWN_ATTRIBUTES = (
'admin_state_up',
'allocation_pools',
@ -38,7 +41,7 @@ KNOWN_ATTRIBUTES = (
'prefixes',
'prefixlen',
'project_id',
'shared',
constants.SHARED,
'status',
'subnets',
'subnetpool_id',

View File

@ -12,6 +12,7 @@
from neutron_lib.api import converters
from neutron_lib.api.definitions import constants as api_const
from neutron_lib import constants
from neutron_lib.db import constants as db_const
# The alias of the extension.
@ -59,11 +60,13 @@ RESOURCE_ATTRIBUTE_MAP = {
'firewall_policy_id': {'allow_post': False, 'allow_put': False,
'validate': {'type:uuid_or_none': None},
'is_visible': True},
'shared': {'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
constants.SHARED: {
'allow_post': True, 'allow_put': True,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True
},
'protocol': {
'allow_post': True, 'allow_put': True,
'is_visible': True, 'default': None,
@ -115,10 +118,12 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:string':
db_const.DESCRIPTION_FIELD_SIZE},
'is_visible': True, 'default': ''},
'shared': {'allow_post': True, 'allow_put': True,
'default': False, 'enforce_policy': True,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True},
constants.SHARED: {
'allow_post': True, 'allow_put': True,
'default': False, 'enforce_policy': True,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True
},
'firewall_rules': {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_list': None},
'convert_to': converters.convert_none_to_empty_list,
@ -147,10 +152,12 @@ RESOURCE_ATTRIBUTE_MAP = {
'convert_to': converters.convert_to_boolean},
'status': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'shared': {'allow_post': True, 'allow_put': True,
'default': False, 'enforce_policy': True,
'convert_to': converters.convert_to_boolean,
'is_visible': False, 'required_by_policy': True},
constants.SHARED: {
'allow_post': True, 'allow_put': True,
'default': False, 'enforce_policy': True,
'convert_to': converters.convert_to_boolean,
'is_visible': False, 'required_by_policy': True
},
'firewall_policy_id': {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_or_none': None},
'is_visible': True},

View File

@ -13,6 +13,7 @@
from neutron_lib.api import converters
from neutron_lib.api.definitions import constants as api_const
from neutron_lib.api.definitions import port
from neutron_lib import constants
from neutron_lib.db import constants as db_const
# The alias of the extension.
@ -62,10 +63,12 @@ RESOURCE_ATTRIBUTE_MAP = {
'firewall_policy_id': {'allow_post': False, 'allow_put': False,
'validate': {'type:uuid_or_none': None},
'is_visible': True},
'shared': {'allow_post': True, 'allow_put': True,
'default': False, 'is_visible': True,
'convert_to': converters.convert_to_boolean,
'required_by_policy': True, 'enforce_policy': True},
constants.SHARED: {
'allow_post': True, 'allow_put': True,
'default': False, 'is_visible': True,
'convert_to': converters.convert_to_boolean,
'required_by_policy': True, 'enforce_policy': True
},
'protocol': {
'allow_post': True, 'allow_put': True,
'is_visible': True, 'default': None,
@ -126,10 +129,12 @@ RESOURCE_ATTRIBUTE_MAP = {
'convert_to': converters.convert_to_boolean},
'status': {'allow_post': False, 'allow_put': False,
'is_visible': True},
'shared': {'allow_post': True, 'allow_put': True, 'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
constants.SHARED: {
'allow_post': True, 'allow_put': True, 'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True
},
port.COLLECTION_NAME: {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_list': None},
'convert_to':
@ -168,10 +173,12 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {'type:string':
db_const.DESCRIPTION_FIELD_SIZE},
'is_visible': True, 'default': ''},
'shared': {'allow_post': True, 'allow_put': True, 'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True},
constants.SHARED: {
'allow_post': True, 'allow_put': True, 'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True, 'required_by_policy': True,
'enforce_policy': True
},
api_const.FIREWALL_RULES: {'allow_post': True, 'allow_put': True,
'validate': {'type:uuid_list': None},
'convert_to':

View File

@ -13,6 +13,7 @@
# under the License.
from neutron_lib.api import converters
from neutron_lib import constants
from neutron_lib.db import constants as db_const
@ -51,7 +52,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'is_visible': True
},
'shared': {
constants.SHARED: {
'allow_post': True, 'allow_put': False,
'is_visible': True, 'default': False,
'convert_to': converters.convert_to_boolean

View File

@ -12,6 +12,7 @@
from neutron_lib.api import converters
from neutron_lib.api.definitions import subnet
from neutron_lib import constants
from neutron_lib.db import constants as db_const
@ -54,13 +55,15 @@ RESOURCE_ATTRIBUTE_MAP = {
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
'required_by_policy': True,
'is_visible': True},
'shared': {'allow_post': True,
'allow_put': True,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True,
'required_by_policy': True,
'enforce_policy': True},
constants.SHARED: {
'allow_post': True,
'allow_put': True,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True,
'required_by_policy': True,
'enforce_policy': True
}
}
}

View File

@ -59,7 +59,7 @@ RESOURCE_ATTRIBUTE_MAP = {
'allow_post': True, 'allow_put': True,
'is_visible': True, 'default': '',
'validate': {'type:string': db_const.NAME_FIELD_SIZE}},
'shared': {
constants.SHARED: {
'allow_post': True, 'allow_put': True,
'is_visible': True, 'default': False,
'convert_to': converters.convert_to_boolean

View File

@ -100,13 +100,15 @@ RESOURCE_ATTRIBUTE_MAP = {
'validate': {
'type:values': constants.IPV6_MODES},
'is_visible': True},
'shared': {'allow_post': False,
'allow_put': False,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': False,
'required_by_policy': True,
'enforce_policy': True},
constants.SHARED: {
'allow_post': False,
'allow_put': False,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': False,
'required_by_policy': True,
'enforce_policy': True
}
}
}

View File

@ -79,13 +79,15 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True,
'required_by_policy': True,
'enforce_policy': True},
'shared': {'allow_post': True,
'allow_put': False,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True,
'required_by_policy': True,
'enforce_policy': True},
constants.SHARED: {
'allow_post': True,
'allow_put': False,
'default': False,
'convert_to': converters.convert_to_boolean,
'is_visible': True,
'required_by_policy': True,
'enforce_policy': True
}
}
}

View File

@ -350,6 +350,8 @@ UUID_PATTERN = '-'.join([HEX_ELEM + '{8}', HEX_ELEM + '{4}',
HEX_ELEM + '{4}', HEX_ELEM + '{4}',
HEX_ELEM + '{12}'])
SHARED = 'shared'
##########################
# Device related constants

View File

@ -11,6 +11,7 @@
# under the License.
from neutron_lib.api.definitions import firewall_v2
from neutron_lib import constants
from neutron_lib.tests.unit.api.definitions import base
@ -23,7 +24,7 @@ class FirewallDefinitionTestCase(base.DefinitionBaseTestCase):
'egress_firewall_policy_id', 'enabled',
'firewall_policy_id', 'firewall_rules',
'ingress_firewall_policy_id', 'ip_version',
'ports', 'position', 'protocol', 'shared',
'ports', 'position', 'protocol', constants.SHARED,
'source_ip_address', 'source_port',
'source_firewall_group_id',
'destination_firewall_group_id')

View File

@ -0,0 +1,4 @@
---
features:
- The ``SHARED`` constant is now available in
``neutron_lib.constants``.