From 1331fb208330d1ca385996a716f0bc0c7ad1a07f Mon Sep 17 00:00:00 2001 From: Boden R Date: Fri, 3 Feb 2017 13:43:41 -0700 Subject: [PATCH] rehome plugin common constants This patch rehomes a bulk of constants from neutron.plugins.common.constants as they are used by a number of our sub-projects [1]. Notable differences include: - Service operation status constants are not defined in the plugin constants as they are already available in neutron_lib.constants. - The DEFAULT_SERVICE_PLUGINS is not included. This one appears to be neutron specific and should likely be made private in neutron. - The EXT_TO_SERVICE_MAPPING dict is not included. We'll push this in a separate change so we can discuss in greater detail. A release note is also included. [1] http://codesearch.openstack.org/?q=from%20neutron %5C.plugins%5C.common%20import%20constants Change-Id: I6e86d737064f97d82e36a4e82a9f2a22fd38febe --- neutron_lib/constants.py | 46 +++++++++++++++++++ neutron_lib/plugins/constants.py | 24 ++++++++++ ...ome-plugin-constants-ebf350dfd989957a.yaml | 5 ++ 3 files changed, 75 insertions(+) create mode 100644 neutron_lib/plugins/constants.py create mode 100644 releasenotes/notes/rehome-plugin-constants-ebf350dfd989957a.yaml diff --git a/neutron_lib/constants.py b/neutron_lib/constants.py index 8916a64..2728511 100644 --- a/neutron_lib/constants.py +++ b/neutron_lib/constants.py @@ -203,6 +203,12 @@ IPTABLES_PROTOCOL_MAP = {PROTO_NAME_DCCP: 'dccp', PROTO_NAME_TCP: 'tcp', PROTO_NAME_UDP: 'udp'} +# IP header length +IP_HEADER_LENGTH = { + 4: 20, + 6: 40, +} + # ICMPv6 types: # Destination Unreachable (1) ICMPV6_TYPE_DEST_UNREACH = 1 @@ -260,6 +266,45 @@ DHCPV6_STATELESS = 'dhcpv6-stateless' IPV6_SLAAC = 'slaac' IPV6_MODES = [DHCPV6_STATEFUL, DHCPV6_STATELESS, IPV6_SLAAC] +ACTIVE_PENDING_STATUSES = ( + ACTIVE, + PENDING_CREATE, + PENDING_UPDATE +) + +# Network Type constants +TYPE_FLAT = 'flat' +TYPE_GENEVE = 'geneve' +TYPE_GRE = 'gre' +TYPE_LOCAL = 'local' +TYPE_VXLAN = 'vxlan' +TYPE_VLAN = 'vlan' +TYPE_NONE = 'none' + +# Values for network_type + +# For VLAN Network +MIN_VLAN_TAG = 1 +MAX_VLAN_TAG = 4094 + +# For Geneve Tunnel +MIN_GENEVE_VNI = 1 +MAX_GENEVE_VNI = 2 ** 24 - 1 + +# For GRE Tunnel +MIN_GRE_ID = 1 +MAX_GRE_ID = 2 ** 32 - 1 + +# For VXLAN Tunnel +MIN_VXLAN_VNI = 1 +MAX_VXLAN_VNI = 2 ** 24 - 1 +VXLAN_UDP_PORT = 4789 + +# Overlay (tunnel) protocol overhead +GENEVE_ENCAP_MIN_OVERHEAD = 30 +GRE_ENCAP_OVERHEAD = 22 +VXLAN_ENCAP_OVERHEAD = 30 + class Sentinel(object): """A constant object that does not change even when copied.""" @@ -300,6 +345,7 @@ SNAT_INT_DEV_PREFIX = 'sg-' ########################## # Plugin constants that are universally used across all neutron repos. # The alias for the core plugin. +# TODO(boden): remove and replace consumer usage with plugins/constants.py CORE = 'CORE' # The alias for the L3 plugin. L3 = 'L3_ROUTER_NAT' diff --git a/neutron_lib/plugins/constants.py b/neutron_lib/plugins/constants.py new file mode 100644 index 0000000..264b5ce --- /dev/null +++ b/neutron_lib/plugins/constants.py @@ -0,0 +1,24 @@ +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# Well-known service type constants: +LOADBALANCER = "LOADBALANCER" +LOADBALANCERV2 = "LOADBALANCERV2" +FIREWALL = "FIREWALL" +VPN = "VPN" +METERING = "METERING" +FLAVORS = "FLAVORS" +QOS = "QOS" +CORE = 'CORE' +L3 = 'L3_ROUTER_NAT' diff --git a/releasenotes/notes/rehome-plugin-constants-ebf350dfd989957a.yaml b/releasenotes/notes/rehome-plugin-constants-ebf350dfd989957a.yaml new file mode 100644 index 0000000..9518a94 --- /dev/null +++ b/releasenotes/notes/rehome-plugin-constants-ebf350dfd989957a.yaml @@ -0,0 +1,5 @@ +--- +features: + - Many of the constants from ``neutron.plugins.common.constants`` are + now available in ``neutron_lib.plugins.constants`` and + ``neutron_lib.constants``.