From 42efcef6264b5b22af38b49db901c4515f56904c Mon Sep 17 00:00:00 2001 From: Kailun Qin Date: Thu, 17 Jan 2019 06:24:57 +0800 Subject: [PATCH] Move network segment range types to lib constants Move NETWORK_SEGMENT_RANGE_TYPE_LIST from api-def to neutron_lib.constants and renamed to NETWORK_SEGMENT_RANGE_TYPES so that the constant can be used elsewhere. Co-authored-by: Allain Legacy Partially-implements: blueprint network-segment-range-management Change-Id: I6d49faf9eef9087d6ae5c3722f0b9a2a3f980c63 --- neutron_lib/api/definitions/network_segment_range.py | 8 ++------ neutron_lib/constants.py | 3 +++ ...ent-range-types-to-lib-constants-d45c6959607e9136.yaml | 6 ++++++ 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/move-segment-range-types-to-lib-constants-d45c6959607e9136.yaml diff --git a/neutron_lib/api/definitions/network_segment_range.py b/neutron_lib/api/definitions/network_segment_range.py index cb52cc48e..b3a219804 100644 --- a/neutron_lib/api/definitions/network_segment_range.py +++ b/neutron_lib/api/definitions/network_segment_range.py @@ -35,11 +35,6 @@ RESOURCE_NAME = 'network_segment_range' # The plural for the resource. COLLECTION_NAME = 'network_segment_ranges' -NETWORK_SEGMENT_RANGE_TYPE_LIST = [constants.TYPE_VLAN, - constants.TYPE_VXLAN, - constants.TYPE_GRE, - constants.TYPE_GENEVE] - # Min ID for VLAN, VXLAN, GRE and GENEVE all equal to 1; Max ID for them are # 4094, 2 ** 24 - 1, 2 ** 32 - 1 and 2 ** 24 - 1 respectively. # Take the largest range: [MIN_GRE_ID, MAX_GRE_ID] as the limit for validation. @@ -82,7 +77,8 @@ RESOURCE_ATTRIBUTE_MAP = { 'network_type': {'allow_post': True, 'allow_put': False, 'validate': { - 'type:values': NETWORK_SEGMENT_RANGE_TYPE_LIST}, + 'type:values': + constants.NETWORK_SEGMENT_RANGE_TYPES}, 'default': constants.ATTR_NOT_SPECIFIED, 'is_filter': True, 'is_visible': True}, diff --git a/neutron_lib/constants.py b/neutron_lib/constants.py index 09673f425..50e3d9277 100644 --- a/neutron_lib/constants.py +++ b/neutron_lib/constants.py @@ -289,6 +289,9 @@ TYPE_VXLAN = 'vxlan' TYPE_VLAN = 'vlan' TYPE_NONE = 'none' +# List of supported network segment range types +NETWORK_SEGMENT_RANGE_TYPES = [TYPE_VLAN, TYPE_VXLAN, TYPE_GRE, TYPE_GENEVE] + # Values for network_type # For VLAN Network diff --git a/releasenotes/notes/move-segment-range-types-to-lib-constants-d45c6959607e9136.yaml b/releasenotes/notes/move-segment-range-types-to-lib-constants-d45c6959607e9136.yaml new file mode 100644 index 000000000..c70cf1de5 --- /dev/null +++ b/releasenotes/notes/move-segment-range-types-to-lib-constants-d45c6959607e9136.yaml @@ -0,0 +1,6 @@ +--- +other: + - | + The ``neutron_lib.api.definitions.network_segment_range.NETWORK_SEGMENT_RANGE_TYPE_LIST`` + constant was moved to ``neutron_lib.constants`` and renamed to + ``NETWORK_SEGMENT_RANGE_TYPES`` so that it can be used elsewhere.