diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index bc1538a30b6..33e3fc90bd5 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -17,6 +17,7 @@ import collections import os import eventlet +from neutron_lib.agent import constants as agent_consts from neutron_lib import constants from neutron_lib import context from neutron_lib import exceptions @@ -736,7 +737,7 @@ class DhcpAgentWithStateReport(DhcpAgent): ctx = context.get_admin_context_without_session() agent_status = self.state_rpc.report_state( ctx, self.agent_state, True) - if agent_status == n_const.AGENT_REVIVED: + if agent_status == agent_consts.AGENT_REVIVED: LOG.info("Agent has just been revived. " "Scheduling full sync") self.schedule_resync("Agent has just been revived") diff --git a/neutron/agent/firewall.py b/neutron/agent/firewall.py index f648ce34c64..5916d277733 100644 --- a/neutron/agent/firewall.py +++ b/neutron/agent/firewall.py @@ -21,12 +21,11 @@ import six from neutron_lib.api.definitions import port_security as psec from neutron_lib import constants as n_const -import neutron.common.constants as const from neutron.common import utils -INGRESS_DIRECTION = const.INGRESS_DIRECTION -EGRESS_DIRECTION = const.EGRESS_DIRECTION +INGRESS_DIRECTION = n_const.INGRESS_DIRECTION +EGRESS_DIRECTION = n_const.EGRESS_DIRECTION DIRECTION_IP_PREFIX = {INGRESS_DIRECTION: 'source_ip_prefix', EGRESS_DIRECTION: 'dest_ip_prefix'} diff --git a/neutron/agent/l2/extensions/qos.py b/neutron/agent/l2/extensions/qos.py index ca3a7f00ec6..96a3c4f876b 100644 --- a/neutron/agent/l2/extensions/qos.py +++ b/neutron/agent/l2/extensions/qos.py @@ -16,6 +16,7 @@ import abc import collections +from neutron_lib import constants from oslo_concurrency import lockutils from oslo_log import log as logging import six @@ -25,7 +26,6 @@ from neutron.api.rpc.callbacks.consumer import registry from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import resources_rpc -from neutron.common import constants from neutron import manager from neutron.services.qos import qos_consts diff --git a/neutron/agent/l3/agent.py b/neutron/agent/l3/agent.py index c9ab0d95885..f27e0e32b46 100644 --- a/neutron/agent/l3/agent.py +++ b/neutron/agent/l3/agent.py @@ -17,6 +17,7 @@ import itertools import eventlet import netaddr +from neutron_lib.agent import constants as agent_consts from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib.callbacks import resources @@ -731,7 +732,7 @@ class L3NATAgentWithStateReport(L3NATAgent): agent_status = self.state_rpc.report_state(self.context, self.agent_state, True) - if agent_status == l3_constants.AGENT_REVIVED: + if agent_status == agent_consts.AGENT_REVIVED: LOG.info('Agent has just been revived. ' 'Doing a full sync.') self.fullsync = True diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index dfac0f360fe..d6ae60b5a1f 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -1285,7 +1285,7 @@ class DeviceManager(object): {'device_id': device_id, 'network_id': network.id}) for port in network.ports: port_device_id = getattr(port, 'device_id', None) - if port_device_id == n_const.DEVICE_ID_RESERVED_DHCP_PORT: + if port_device_id == constants.DEVICE_ID_RESERVED_DHCP_PORT: try: port = self.plugin.update_dhcp_port( port.id, {'port': {'network_id': network.id, diff --git a/neutron/agent/linux/iptables_firewall.py b/neutron/agent/linux/iptables_firewall.py index bf2a8b8218c..665cbaaa20e 100644 --- a/neutron/agent/linux/iptables_firewall.py +++ b/neutron/agent/linux/iptables_firewall.py @@ -640,9 +640,9 @@ class IptablesFirewallDriver(firewall.FirewallDriver): protocol = 'ipv6-icmp' iptables_rule = ['-p', protocol] - if (is_port and protocol in n_const.IPTABLES_PROTOCOL_MAP): + if (is_port and protocol in constants.IPTABLES_PROTOCOL_MAP): # iptables adds '-m protocol' when the port number is specified - iptables_rule += ['-m', n_const.IPTABLES_PROTOCOL_MAP[protocol]] + iptables_rule += ['-m', constants.IPTABLES_PROTOCOL_MAP[protocol]] return iptables_rule def _port_arg(self, direction, protocol, port_range_min, port_range_max): diff --git a/neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py b/neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py index 64a2a67be16..d12816c7f3e 100644 --- a/neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py +++ b/neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py @@ -22,7 +22,6 @@ from oslo_config import cfg from oslo_log import log as logging import oslo_messaging -from neutron.common import constants as n_const from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.common import utils @@ -144,7 +143,7 @@ class DhcpAgentNotifyAPI(object): return enabled_agents def _is_reserved_dhcp_port(self, port): - return port.get('device_id') == n_const.DEVICE_ID_RESERVED_DHCP_PORT + return port.get('device_id') == constants.DEVICE_ID_RESERVED_DHCP_PORT def _notify_agents(self, context, method, payload, network_id): """Notify all the agents that are hosting the network.""" diff --git a/neutron/api/rpc/handlers/dhcp_rpc.py b/neutron/api/rpc/handlers/dhcp_rpc.py index 56817611114..c3379db673d 100644 --- a/neutron/api/rpc/handlers/dhcp_rpc.py +++ b/neutron/api/rpc/handlers/dhcp_rpc.py @@ -281,7 +281,7 @@ class DhcpRpcCallback(object): plugin = directory.get_plugin() try: old_port = plugin.get_port(context, port['id']) - if (old_port['device_id'] != n_const.DEVICE_ID_RESERVED_DHCP_PORT + if (old_port['device_id'] != constants.DEVICE_ID_RESERVED_DHCP_PORT and old_port['device_id'] != utils.get_dhcp_agent_device_id(port['port']['network_id'], host)): diff --git a/neutron/common/constants.py b/neutron/common/constants.py index 6efff0c7bb7..d50fb38b1ca 100644 --- a/neutron/common/constants.py +++ b/neutron/common/constants.py @@ -19,11 +19,6 @@ from neutron_lib import constants as lib_constants ROUTER_PORT_OWNERS = lib_constants.ROUTER_INTERFACE_OWNERS_SNAT + \ (lib_constants.DEVICE_OWNER_ROUTER_GW,) -ROUTER_STATUS_ACTIVE = 'ACTIVE' -ROUTER_STATUS_ERROR = 'ERROR' - -DEVICE_ID_RESERVED_DHCP_PORT = "reserved_dhcp_port" - HA_ROUTER_STATE_KEY = '_ha_state' METERING_LABEL_KEY = '_metering_labels' FLOATINGIP_AGENT_INTF_KEY = '_floatingip_agent_interfaces' @@ -50,23 +45,10 @@ ETHERTYPE_IPV6 = 0x86DD IP_PROTOCOL_NAME_ALIASES = {lib_constants.PROTO_NAME_IPV6_ICMP_LEGACY: lib_constants.PROTO_NAME_IPV6_ICMP} -VALID_DSCP_MARKS = [0, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, - 36, 38, 40, 46, 48, 56] - IP_PROTOCOL_NUM_TO_NAME_MAP = { str(v): k for k, v in lib_constants.IP_PROTOCOL_MAP.items()} -# When using iptables-save we specify '-p {proto} -m {module}', -# but sometimes those values are not identical. This is a map -# of known protocols that require a '-m {module}', along with -# the module name that should be used. -IPTABLES_PROTOCOL_MAP = {lib_constants.PROTO_NAME_DCCP: 'dccp', - lib_constants.PROTO_NAME_ICMP: 'icmp', - lib_constants.PROTO_NAME_IPV6_ICMP: 'icmp6', - lib_constants.PROTO_NAME_SCTP: 'sctp', - lib_constants.PROTO_NAME_TCP: 'tcp', - lib_constants.PROTO_NAME_UDP: 'udp'} - +# TODO(boden): consume with I9642ed9b513a43c5558f9611f43227299707284a # Special provisional prefix for IPv6 Prefix Delegation PROVISIONAL_IPV6_PD_PREFIX = '::/64' @@ -87,11 +69,6 @@ INTERFACE_PREFIXES = (lib_constants.TAP_DEVICE_PREFIX, ATTRIBUTES_TO_UPDATE = 'attributes_to_update' -# Maximum value integer can take in MySQL and PostgreSQL -# In SQLite integer can be stored in 1, 2, 3, 4, 6, or 8 bytes, -# but here it will be limited by this value for consistency. -DB_INTEGER_MAX_VALUE = 2 ** 31 - 1 - # TODO(amuller): Re-define the RPC namespaces once Oslo messaging supports # Targets with multiple namespaces. Neutron will then implement callbacks # for its RPC clients in order to support rolling upgrades. @@ -115,18 +92,6 @@ IPV6_MIN_MTU = 1280 ROUTER_MARK_MASK = "0xffff" -# Agent states as detected by server, used to reply on agent's state report -# agent has just been registered -AGENT_NEW = 'new' -# agent is alive -AGENT_ALIVE = 'alive' -# agent has just returned to alive after being dead -AGENT_REVIVED = 'revived' - -INGRESS_DIRECTION = 'ingress' -EGRESS_DIRECTION = 'egress' - -VALID_DIRECTIONS = (INGRESS_DIRECTION, EGRESS_DIRECTION) VALID_ETHERTYPES = (lib_constants.IPv4, lib_constants.IPv6) IP_ALLOWED_VERSIONS = [lib_constants.IP_VERSION_4, lib_constants.IP_VERSION_6] @@ -163,10 +128,8 @@ IPAM_ALLOCATION_STATUS_ALLOCATED = 'ALLOCATED' VALID_IPAM_ALLOCATION_STATUSES = (IPAM_ALLOCATION_STATUS_ALLOCATED,) # Port binding states for Live Migration -PORT_BINDING_STATUS_ACTIVE = 'ACTIVE' -PORT_BINDING_STATUS_INACTIVE = 'INACTIVE' -PORT_BINDING_STATUSES = (PORT_BINDING_STATUS_ACTIVE, - PORT_BINDING_STATUS_INACTIVE) +PORT_BINDING_STATUSES = (lib_constants.ACTIVE, + lib_constants.INACTIVE) VALID_FLOATINGIP_STATUS = (lib_constants.FLOATINGIP_STATUS_ACTIVE, lib_constants.FLOATINGIP_STATUS_DOWN, diff --git a/neutron/db/agents_db.py b/neutron/db/agents_db.py index 989a92307fc..a0c88b66f57 100644 --- a/neutron/db/agents_db.py +++ b/neutron/db/agents_db.py @@ -16,6 +16,7 @@ import datetime from eventlet import greenthread +from neutron_lib.agent import constants as agent_consts from neutron_lib.api import converters from neutron_lib.callbacks import events from neutron_lib.callbacks import registry @@ -318,7 +319,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase, AgentAvailabilityZoneMixin): Status is from server point of view: alive, new or revived. It could be used by agent to do some sync with the server if needed. """ - status = n_const.AGENT_ALIVE + status = agent_consts.AGENT_ALIVE with context.session.begin(subtransactions=True): res_keys = ['agent_type', 'binary', 'host', 'topic'] res = dict((k, agent_state[k]) for k in res_keys) @@ -336,7 +337,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase, AgentAvailabilityZoneMixin): agent_db = self._get_agent_by_type_and_host( context, agent_state['agent_type'], agent_state['host']) if not agent_db.is_active: - status = n_const.AGENT_REVIVED + status = agent_consts.AGENT_REVIVED if 'resource_versions' not in agent_state: # updating agent_state with resource_versions taken # from db so that @@ -362,7 +363,7 @@ class AgentDbMixin(ext_agent.AgentPluginBase, AgentAvailabilityZoneMixin): context.session.add(agent_db) event_type = events.AFTER_CREATE self._log_heartbeat(agent_state, agent_db, configurations_dict) - status = n_const.AGENT_NEW + status = agent_consts.AGENT_NEW greenthread.sleep(0) registry.notify(resources.AGENT, event_type, self, context=context, diff --git a/neutron/db/agentschedulers_db.py b/neutron/db/agentschedulers_db.py index d233e965d4d..659a877c978 100644 --- a/neutron/db/agentschedulers_db.py +++ b/neutron/db/agentschedulers_db.py @@ -27,7 +27,6 @@ from sqlalchemy.orm import exc from neutron._i18n import _ from neutron.agent.common import utils as agent_utils -from neutron.common import constants as n_const from neutron.common import utils from neutron.db import agents_db from neutron.db.availability_zone import network as network_az @@ -432,7 +431,7 @@ class DhcpAgentSchedulerDbMixin(dhcpagentscheduler # DHCP agent per network so we don't have to worry about one # update_port passing and another failing for port in ports: - port['device_id'] = n_const.DEVICE_ID_RESERVED_DHCP_PORT + port['device_id'] = constants.DEVICE_ID_RESERVED_DHCP_PORT self.update_port(context, port['id'], dict(port=port)) binding_obj.delete() diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index 30895dd8360..de5d7d3177d 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -210,7 +210,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase, tenant_id=router['tenant_id'], name=router['name'], admin_state_up=router['admin_state_up'], - status=n_const.ROUTER_STATUS_ACTIVE, + status=constants.ACTIVE, description=router.get('description')) context.session.add(router_db) registry.notify(resources.ROUTER, events.PRECOMMIT_CREATE, diff --git a/neutron/db/l3_hamode_db.py b/neutron/db/l3_hamode_db.py index 048b6fb1256..bb5a4388b3b 100644 --- a/neutron/db/l3_hamode_db.py +++ b/neutron/db/l3_hamode_db.py @@ -414,7 +414,7 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin, router_id) router['status'] = self._update_router_db( context, router_id, - {'status': n_const.ROUTER_STATUS_ERROR})['status'] + {'status': constants.ERROR})['status'] @registry.receives(resources.ROUTER, [events.PRECOMMIT_UPDATE]) def _validate_migration(self, resource, event, trigger, context, diff --git a/neutron/db/migration/alembic_migrations/versions/newton/expand/0f5bef0f87d4_add_qos_minimum_bandwidth_rules.py b/neutron/db/migration/alembic_migrations/versions/newton/expand/0f5bef0f87d4_add_qos_minimum_bandwidth_rules.py index 221cf816d02..452b92900ed 100644 --- a/neutron/db/migration/alembic_migrations/versions/newton/expand/0f5bef0f87d4_add_qos_minimum_bandwidth_rules.py +++ b/neutron/db/migration/alembic_migrations/versions/newton/expand/0f5bef0f87d4_add_qos_minimum_bandwidth_rules.py @@ -26,10 +26,9 @@ revision = '0f5bef0f87d4' down_revision = 'a5648cfeeadf' from alembic import op +from neutron_lib import constants import sqlalchemy as sa -from neutron.common import constants - def upgrade(): op.create_table( diff --git a/neutron/db/migration/alembic_migrations/versions/ocata/expand/a9c43481023c_extend_ml2_port_bindings.py b/neutron/db/migration/alembic_migrations/versions/ocata/expand/a9c43481023c_extend_ml2_port_bindings.py index 9cd4c2cb51f..887fe763080 100644 --- a/neutron/db/migration/alembic_migrations/versions/ocata/expand/a9c43481023c_extend_ml2_port_bindings.py +++ b/neutron/db/migration/alembic_migrations/versions/ocata/expand/a9c43481023c_extend_ml2_port_bindings.py @@ -26,10 +26,10 @@ revision = 'a9c43481023c' down_revision = '929c968efe70' from alembic import op +from neutron_lib import constants import sqlalchemy as sa from sqlalchemy.engine.reflection import Inspector as insp -from neutron.common import constants from neutron.db import migration MYSQL_ENGINE = 'mysql' @@ -45,7 +45,7 @@ def upgrade(): sa.Column('status', sa.String(length=16), nullable=False, - server_default=constants.PORT_BINDING_STATUS_ACTIVE)) + server_default=constants.ACTIVE)) if (engine.name == MYSQL_ENGINE): op.execute("ALTER TABLE ml2_port_bindings DROP PRIMARY KEY," diff --git a/neutron/db/migration/alembic_migrations/versions/pike/expand/2b42d90729da_qos_add_direction_to_bw_limit_rule_table.py b/neutron/db/migration/alembic_migrations/versions/pike/expand/2b42d90729da_qos_add_direction_to_bw_limit_rule_table.py index cf6616339c2..16850e1177c 100644 --- a/neutron/db/migration/alembic_migrations/versions/pike/expand/2b42d90729da_qos_add_direction_to_bw_limit_rule_table.py +++ b/neutron/db/migration/alembic_migrations/versions/pike/expand/2b42d90729da_qos_add_direction_to_bw_limit_rule_table.py @@ -26,9 +26,9 @@ revision = '2b42d90729da' down_revision = '804a3c76314c' from alembic import op +from neutron_lib import constants import sqlalchemy as sa -from neutron.common import constants from neutron.db import migration diff --git a/neutron/db/qos/models.py b/neutron/db/qos/models.py index af7271902ea..057290377c5 100644 --- a/neutron/db/qos/models.py +++ b/neutron/db/qos/models.py @@ -13,11 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants from neutron_lib.db import constants as db_const from neutron_lib.db import model_base import sqlalchemy as sa -from neutron.common import constants from neutron.db import models_v2 from neutron.db import rbac_db_models from neutron.db import standard_attr diff --git a/neutron/extensions/qos.py b/neutron/extensions/qos.py index 2959e7bb0f2..cd1d3408dbf 100644 --- a/neutron/extensions/qos.py +++ b/neutron/extensions/qos.py @@ -19,6 +19,7 @@ import re from neutron_lib.api import converters from neutron_lib.api import extensions as api_extensions +from neutron_lib import constants as common_constants from neutron_lib.db import constants as db_const from neutron_lib.plugins import directory from neutron_lib.services import base as service_base @@ -27,7 +28,6 @@ import six from neutron.api import extensions from neutron.api.v2 import base from neutron.api.v2 import resource_helper -from neutron.common import constants as common_constants from neutron.objects.qos import rule as rule_object from neutron.plugins.common import constants from neutron.services.qos import qos_consts @@ -85,12 +85,12 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { 'allow_post': True, 'allow_put': True, 'is_visible': True, 'default': None, 'validate': {'type:range': [0, - common_constants.DB_INTEGER_MAX_VALUE]}}, + db_const.DB_INTEGER_MAX_VALUE]}}, 'max_burst_kbps': { 'allow_post': True, 'allow_put': True, 'is_visible': True, 'default': 0, 'validate': {'type:range': [0, - common_constants.DB_INTEGER_MAX_VALUE]}}}), + db_const.DB_INTEGER_MAX_VALUE]}}}), }, 'dscp_marking_rules': { 'parent': {'collection_name': 'policies', @@ -111,7 +111,7 @@ SUB_RESOURCE_ATTRIBUTE_MAP = { 'allow_post': True, 'allow_put': True, 'is_visible': True, 'validate': {'type:range': [0, - common_constants.DB_INTEGER_MAX_VALUE]}}, + db_const.DB_INTEGER_MAX_VALUE]}}, 'direction': { 'allow_post': True, 'allow_put': True, 'is_visible': True, 'default': 'egress', diff --git a/neutron/extensions/qos_bw_limit_direction.py b/neutron/extensions/qos_bw_limit_direction.py index c8f51aedda9..5da5ab85c0a 100644 --- a/neutron/extensions/qos_bw_limit_direction.py +++ b/neutron/extensions/qos_bw_limit_direction.py @@ -14,8 +14,8 @@ # under the License. from neutron_lib.api import extensions as api_extensions +from neutron_lib import constants as common_constants -from neutron.common import constants as common_constants from neutron.extensions import qos diff --git a/neutron/extensions/quotasv2.py b/neutron/extensions/quotasv2.py index 64e118a03eb..327b932ee58 100644 --- a/neutron/extensions/quotasv2.py +++ b/neutron/extensions/quotasv2.py @@ -15,6 +15,7 @@ from neutron_lib.api import converters from neutron_lib.api import extensions as api_extensions +from neutron_lib.db import constants as const from neutron_lib import exceptions as n_exc from neutron_lib.plugins import directory from oslo_config import cfg @@ -25,7 +26,6 @@ from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import base from neutron.api.v2 import resource -from neutron.common import constants as const from neutron.common import exceptions from neutron import quota from neutron.quota import resource_registry diff --git a/neutron/objects/common_types.py b/neutron/objects/common_types.py index 7baba4cabb7..a4b601eac8d 100644 --- a/neutron/objects/common_types.py +++ b/neutron/objects/common_types.py @@ -157,7 +157,7 @@ class IPVersionEnumField(obj_fields.AutoTypedField): class DscpMark(IntegerEnum): def __init__(self, valid_values=None, **kwargs): super(DscpMark, self).__init__( - valid_values=constants.VALID_DSCP_MARKS) + valid_values=lib_constants.VALID_DSCP_MARKS) class DscpMarkField(obj_fields.AutoTypedField): @@ -165,7 +165,7 @@ class DscpMarkField(obj_fields.AutoTypedField): class FlowDirectionEnumField(obj_fields.AutoTypedField): - AUTO_TYPE = obj_fields.Enum(valid_values=constants.VALID_DIRECTIONS) + AUTO_TYPE = obj_fields.Enum(valid_values=lib_constants.VALID_DIRECTIONS) class IpamAllocationStatusEnumField(obj_fields.AutoTypedField): diff --git a/neutron/objects/ports.py b/neutron/objects/ports.py index fa760fbe226..9f3f6870ce7 100644 --- a/neutron/objects/ports.py +++ b/neutron/objects/ports.py @@ -13,11 +13,11 @@ # under the License. import netaddr +from neutron_lib import constants from oslo_utils import versionutils from oslo_versionedobjects import base as obj_base from oslo_versionedobjects import fields as obj_fields -from neutron.common import constants from neutron.common import utils from neutron.db import api as db_api from neutron.db.models import dns as dns_models @@ -76,7 +76,7 @@ class PortBinding(PortBindingBase): 'vif_details': common_types.DictOfMiscValuesField(nullable=True), 'vnic_type': obj_fields.StringField(), 'status': common_types.PortBindingStatusEnumField( - default=constants.PORT_BINDING_STATUS_ACTIVE), + default=constants.ACTIVE), } primary_keys = ['port_id', 'host'] diff --git a/neutron/objects/qos/policy.py b/neutron/objects/qos/policy.py index 567512c3412..213365c9cfe 100644 --- a/neutron/objects/qos/policy.py +++ b/neutron/objects/qos/policy.py @@ -15,13 +15,13 @@ import itertools +from neutron_lib import constants as n_const from oslo_db import exception as db_exc from oslo_utils import versionutils from oslo_versionedobjects import base as obj_base from oslo_versionedobjects import exception from oslo_versionedobjects import fields as obj_fields -from neutron.common import constants as n_const from neutron.common import exceptions from neutron.db import api as db_api from neutron.db import models_v2 diff --git a/neutron/objects/qos/rule.py b/neutron/objects/qos/rule.py index f53f2ffcb8d..bbd23911e95 100644 --- a/neutron/objects/qos/rule.py +++ b/neutron/objects/qos/rule.py @@ -24,7 +24,6 @@ from oslo_versionedobjects import exception from oslo_versionedobjects import fields as obj_fields import six -from neutron.common import constants as n_const from neutron.db import api as db_api from neutron.db.qos import models as qos_db_model from neutron.objects import base @@ -110,7 +109,7 @@ class QosBandwidthLimitRule(QosRule): 'max_kbps': obj_fields.IntegerField(nullable=True), 'max_burst_kbps': obj_fields.IntegerField(nullable=True), 'direction': common_types.FlowDirectionEnumField( - default=n_const.EGRESS_DIRECTION) + default=constants.EGRESS_DIRECTION) } rule_type = qos_consts.RULE_TYPE_BANDWIDTH_LIMIT @@ -119,7 +118,7 @@ class QosBandwidthLimitRule(QosRule): _target_version = versionutils.convert_version_to_tuple(target_version) if _target_version < (1, 3) and 'direction' in primitive: direction = primitive.pop('direction') - if direction == n_const.INGRESS_DIRECTION: + if direction == constants.INGRESS_DIRECTION: raise exception.IncompatibleObjectVersion( objver=target_version, objtype="QosBandwidthLimitRule") diff --git a/neutron/pecan_wsgi/controllers/quota.py b/neutron/pecan_wsgi/controllers/quota.py index aee3c1061b2..a11ce5d4c28 100644 --- a/neutron/pecan_wsgi/controllers/quota.py +++ b/neutron/pecan_wsgi/controllers/quota.py @@ -23,7 +23,6 @@ from pecan import request from neutron._i18n import _ from neutron.api.v2 import attributes -from neutron.common import constants from neutron.pecan_wsgi.controllers import utils from neutron.quota import resource_registry @@ -91,7 +90,7 @@ class QuotaController(utils.NeutronPecanController): 'allow_put': True, 'convert_to': converters.convert_to_int, 'validate': { - 'type:range': [-1, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [-1, db_const.DB_INTEGER_MAX_VALUE]}, 'is_visible': True} # The quota resource must always declare a tenant_id attribute, # otherwise the attribute will be stripped off when generating the diff --git a/neutron/plugins/ml2/drivers/agent/_common_agent.py b/neutron/plugins/ml2/drivers/agent/_common_agent.py index dade68564f1..5f781481de8 100644 --- a/neutron/plugins/ml2/drivers/agent/_common_agent.py +++ b/neutron/plugins/ml2/drivers/agent/_common_agent.py @@ -19,6 +19,7 @@ import contextlib import sys import time +from neutron_lib.agent import constants as agent_consts from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib.callbacks import resources as local_resources @@ -37,7 +38,6 @@ from neutron.agent import securitygroups_rpc as agent_sg_rpc from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc from neutron.common import config as common_config -from neutron.common import constants as n_const from neutron.common import topics from neutron.plugins.ml2.drivers.agent import _agent_manager_base as amb from neutron.plugins.ml2.drivers.agent import capabilities @@ -126,7 +126,7 @@ class CommonAgentLoop(service.Service): agent_status = self.state_rpc.report_state(self.context, self.agent_state, True) - if agent_status == n_const.AGENT_REVIVED: + if agent_status == agent_consts.AGENT_REVIVED: LOG.info('%s Agent has just been revived. ' 'Doing a full sync.', self.agent_type) diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/qos_driver.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/qos_driver.py index b038fbebf70..35a207c14c8 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/qos_driver.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/qos_driver.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants as const from oslo_config import cfg from oslo_log import helpers as log_helpers from oslo_log import log @@ -19,7 +20,6 @@ from oslo_log import log from neutron.agent.l2.extensions import qos_linux as qos from neutron.agent.linux import iptables_manager from neutron.agent.linux import tc_lib -import neutron.common.constants as const from neutron.services.qos.drivers.linuxbridge import driver LOG = log.getLogger(__name__) diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/extension_drivers/qos_driver.py b/neutron/plugins/ml2/drivers/openvswitch/agent/extension_drivers/qos_driver.py index 7dff5e98670..186f7ad3b9c 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/extension_drivers/qos_driver.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/extension_drivers/qos_driver.py @@ -14,11 +14,11 @@ import collections +from neutron_lib import constants from oslo_config import cfg from oslo_log import log as logging from neutron.agent.l2.extensions import qos_linux as qos -from neutron.common import constants from neutron.services.qos.drivers.openvswitch import driver from neutron.services.qos import qos_consts diff --git a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py index 68c97ebf389..99983dadd7c 100644 --- a/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py @@ -22,6 +22,7 @@ import sys import time import netaddr +from neutron_lib.agent import constants as agent_consts from neutron_lib.api.definitions import portbindings from neutron_lib.callbacks import events as callback_events from neutron_lib.callbacks import registry @@ -51,7 +52,6 @@ from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import dvr_rpc from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc from neutron.common import config -from neutron.common import constants as c_const from neutron.common import topics from neutron.common import utils as n_utils from neutron.conf.agent import xenapi_conf @@ -313,7 +313,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin, agent_status = self.state_rpc.report_state(self.context, self.agent_state, True) - if agent_status == c_const.AGENT_REVIVED: + if agent_status == agent_consts.AGENT_REVIVED: LOG.info('Agent has just been revived. ' 'Doing a full sync.') self.fullsync = True diff --git a/neutron/plugins/ml2/models.py b/neutron/plugins/ml2/models.py index ffc4d2f408e..8922e21c947 100644 --- a/neutron/plugins/ml2/models.py +++ b/neutron/plugins/ml2/models.py @@ -14,11 +14,11 @@ # under the License. from neutron_lib.api.definitions import portbindings +from neutron_lib import constants from neutron_lib.db import model_base import sqlalchemy as sa from sqlalchemy import orm -from neutron.common import constants from neutron.db import models_v2 BINDING_PROFILE_LEN = 4095 @@ -49,8 +49,8 @@ class PortBinding(model_base.BASEV2): vif_details = sa.Column(sa.String(4095), nullable=False, default='', server_default='') status = sa.Column(sa.String(16), nullable=False, - default=constants.PORT_BINDING_STATUS_ACTIVE, - server_default=constants.PORT_BINDING_STATUS_ACTIVE) + default=constants.ACTIVE, + server_default=constants.ACTIVE) # Add a relationship to the Port model in order to instruct SQLAlchemy to # eagerly load port bindings diff --git a/neutron/services/qos/drivers/linuxbridge/driver.py b/neutron/services/qos/drivers/linuxbridge/driver.py index e4613ed15df..78aa8975273 100644 --- a/neutron/services/qos/drivers/linuxbridge/driver.py +++ b/neutron/services/qos/drivers/linuxbridge/driver.py @@ -14,10 +14,11 @@ # under the License. from neutron_lib.api.definitions import portbindings +from neutron_lib import constants +from neutron_lib.db import constants as db_consts from neutron_lib.services.qos import base from oslo_log import log as logging -from neutron.common import constants from neutron.services.qos import qos_consts LOG = logging.getLogger(__name__) @@ -27,9 +28,9 @@ DRIVER = None SUPPORTED_RULES = { qos_consts.RULE_TYPE_BANDWIDTH_LIMIT: { qos_consts.MAX_KBPS: { - 'type:range': [0, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.MAX_BURST: { - 'type:range': [0, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.DIRECTION: { 'type:values': constants.VALID_DIRECTIONS} }, diff --git a/neutron/services/qos/drivers/openvswitch/driver.py b/neutron/services/qos/drivers/openvswitch/driver.py index a4e25d60586..db519df54f1 100644 --- a/neutron/services/qos/drivers/openvswitch/driver.py +++ b/neutron/services/qos/drivers/openvswitch/driver.py @@ -14,10 +14,11 @@ # under the License. from neutron_lib.api.definitions import portbindings +from neutron_lib import constants +from neutron_lib.db import constants as db_consts from neutron_lib.services.qos import base from oslo_log import log as logging -from neutron.common import constants from neutron.services.qos import qos_consts LOG = logging.getLogger(__name__) @@ -27,9 +28,9 @@ DRIVER = None SUPPORTED_RULES = { qos_consts.RULE_TYPE_BANDWIDTH_LIMIT: { qos_consts.MAX_KBPS: { - 'type:range': [0, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.MAX_BURST: { - 'type:range': [0, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.DIRECTION: { 'type:values': constants.VALID_DIRECTIONS} }, diff --git a/neutron/services/qos/drivers/sriov/driver.py b/neutron/services/qos/drivers/sriov/driver.py index 2fb8cc19309..2fe8e3644fa 100644 --- a/neutron/services/qos/drivers/sriov/driver.py +++ b/neutron/services/qos/drivers/sriov/driver.py @@ -14,10 +14,11 @@ # under the License. from neutron_lib.api.definitions import portbindings +from neutron_lib import constants +from neutron_lib.db import constants as db_consts from neutron_lib.services.qos import base from oslo_log import log as logging -from neutron.common import constants from neutron.services.qos import qos_consts LOG = logging.getLogger(__name__) @@ -27,15 +28,15 @@ DRIVER = None SUPPORTED_RULES = { qos_consts.RULE_TYPE_BANDWIDTH_LIMIT: { qos_consts.MAX_KBPS: { - 'type:range': [0, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.MAX_BURST: { - 'type:range': [0, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.DIRECTION: { 'type:values': [constants.EGRESS_DIRECTION]} }, qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { qos_consts.MIN_KBPS: { - 'type:range': [0, constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.DIRECTION: {'type:values': [constants.EGRESS_DIRECTION]} } } diff --git a/neutron/tests/fullstack/test_qos.py b/neutron/tests/fullstack/test_qos.py index 65b0d4c21e3..4509c6c28e6 100644 --- a/neutron/tests/fullstack/test_qos.py +++ b/neutron/tests/fullstack/test_qos.py @@ -20,7 +20,6 @@ from oslo_utils import uuidutils import testscenarios from neutron.agent.linux import tc_lib -from neutron.common import constants as common_constants from neutron.common import utils from neutron.services.qos import qos_consts from neutron.tests.common.agents import l2_extensions @@ -51,10 +50,10 @@ class BaseQoSRuleTestCase(object): @property def reverse_direction(self): - if self.direction == common_constants.INGRESS_DIRECTION: - return common_constants.EGRESS_DIRECTION - elif self.direction == common_constants.EGRESS_DIRECTION: - return common_constants.INGRESS_DIRECTION + if self.direction == constants.INGRESS_DIRECTION: + return constants.EGRESS_DIRECTION + elif self.direction == constants.EGRESS_DIRECTION: + return constants.INGRESS_DIRECTION def setUp(self): host_desc = [ @@ -195,8 +194,8 @@ class _TestBwLimitQoS(BaseQoSRuleTestCase): class TestBwLimitQoSOvs(_TestBwLimitQoS, base.BaseFullStackTestCase): l2_agent_type = constants.AGENT_TYPE_OVS direction_scenarios = [ - ('ingress', {'direction': common_constants.INGRESS_DIRECTION}), - ('egress', {'direction': common_constants.EGRESS_DIRECTION}) + ('ingress', {'direction': constants.INGRESS_DIRECTION}), + ('egress', {'direction': constants.EGRESS_DIRECTION}) ] scenarios = testscenarios.multiply_scenarios( direction_scenarios, fullstack_utils.get_ovs_interface_scenarios()) @@ -205,17 +204,17 @@ class TestBwLimitQoSOvs(_TestBwLimitQoS, base.BaseFullStackTestCase): def _get_expected_burst_value(limit, direction): # For egress bandwidth limit this value should be calculated as # bandwidth_limit * qos_consts.DEFAULT_BURST_RATE - if direction == common_constants.EGRESS_DIRECTION: + if direction == constants.EGRESS_DIRECTION: return TestBwLimitQoSOvs._get_expected_egress_burst_value(limit) else: return 0 def _wait_for_bw_rule_applied(self, vm, limit, burst, direction): - if direction == common_constants.EGRESS_DIRECTION: + if direction == constants.EGRESS_DIRECTION: utils.wait_until_true( lambda: vm.bridge.get_egress_bw_limit_for_port( vm.port.name) == (limit, burst)) - elif direction == common_constants.INGRESS_DIRECTION: + elif direction == constants.INGRESS_DIRECTION: utils.wait_until_true( lambda: vm.bridge.get_ingress_bw_limit_for_port( vm.port.name) == (limit, burst)) @@ -224,15 +223,15 @@ class TestBwLimitQoSOvs(_TestBwLimitQoS, base.BaseFullStackTestCase): class TestBwLimitQoSLinuxbridge(_TestBwLimitQoS, base.BaseFullStackTestCase): l2_agent_type = constants.AGENT_TYPE_LINUXBRIDGE scenarios = [ - ('egress', {'direction': common_constants.EGRESS_DIRECTION}), - ('ingress', {'direction': common_constants.INGRESS_DIRECTION}), + ('egress', {'direction': constants.EGRESS_DIRECTION}), + ('ingress', {'direction': constants.INGRESS_DIRECTION}), ] @staticmethod def _get_expected_burst_value(limit, direction): # For egress bandwidth limit this value should be calculated as # bandwidth_limit * qos_consts.DEFAULT_BURST_RATE - if direction == common_constants.EGRESS_DIRECTION: + if direction == constants.EGRESS_DIRECTION: return TestBwLimitQoSLinuxbridge._get_expected_egress_burst_value( limit) else: @@ -259,10 +258,10 @@ class TestBwLimitQoSLinuxbridge(_TestBwLimitQoS, base.BaseFullStackTestCase): linuxbridge_agent_config.DEFAULT_KERNEL_HZ_VALUE, namespace=vm.host.host_namespace ) - if direction == common_constants.EGRESS_DIRECTION: + if direction == constants.EGRESS_DIRECTION: utils.wait_until_true( lambda: tc.get_filters_bw_limits() == (limit, burst)) - elif direction == common_constants.INGRESS_DIRECTION: + elif direction == constants.INGRESS_DIRECTION: utils.wait_until_true( lambda: tc.get_tbf_bw_limits() == (limit, burst)) diff --git a/neutron/tests/functional/agent/l2/extensions/test_ovs_agent_qos_extension.py b/neutron/tests/functional/agent/l2/extensions/test_ovs_agent_qos_extension.py index 68dea5eeaac..3840f2a4e72 100644 --- a/neutron/tests/functional/agent/l2/extensions/test_ovs_agent_qos_extension.py +++ b/neutron/tests/functional/agent/l2/extensions/test_ovs_agent_qos_extension.py @@ -16,13 +16,13 @@ import copy import mock +from neutron_lib import constants from oslo_utils import uuidutils import testscenarios from neutron.api.rpc.callbacks.consumer import registry as consumer_reg from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources -from neutron.common import constants from neutron.objects.qos import policy from neutron.objects.qos import rule from neutron.tests.common.agents import l2_extensions diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py index 5224c6f4ebc..eb1aaf815f6 100644 --- a/neutron/tests/tempest/api/base.py +++ b/neutron/tests/tempest/api/base.py @@ -403,7 +403,7 @@ class BaseNetworkTest(test.BaseTestCase): @classmethod def create_qos_bandwidth_limit_rule(cls, policy_id, max_kbps, max_burst_kbps, - direction=constants.EGRESS_DIRECTION): + direction=const.EGRESS_DIRECTION): """Wrapper utility that returns a test QoS bandwidth limit rule.""" body = cls.admin_client.create_bandwidth_limit_rule( policy_id, max_kbps, max_burst_kbps, direction) diff --git a/neutron/tests/tools.py b/neutron/tests/tools.py index 74a28174101..0cf19153532 100644 --- a/neutron/tests/tools.py +++ b/neutron/tests/tools.py @@ -275,7 +275,7 @@ def get_random_floatingip_status(): def get_random_flow_direction(): - return random.choice(n_const.VALID_DIRECTIONS) + return random.choice(constants.VALID_DIRECTIONS) def get_random_ha_states(): diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index ad70c6bcf9c..aa9d4cf715d 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -20,6 +20,7 @@ import uuid import eventlet import mock +from neutron_lib.agent import constants as agent_consts from neutron_lib import constants as const from neutron_lib import exceptions from oslo_config import cfg @@ -32,7 +33,6 @@ from neutron.agent.linux import dhcp from neutron.agent.linux import interface from neutron.agent.metadata import driver as metadata_driver from neutron.common import config as common_config -from neutron.common import constants as n_const from neutron.common import utils from neutron.conf.agent import common as config from neutron.conf.agent import dhcp as dhcp_config @@ -474,11 +474,11 @@ class TestDhcpAgent(base.BaseTestCase): with mock.patch.object(dhcp.state_rpc, 'report_state') as report_state,\ mock.patch.object(dhcp, "run"): - report_state.return_value = n_const.AGENT_ALIVE + report_state.return_value = agent_consts.AGENT_ALIVE dhcp._report_state() self.assertEqual({}, dhcp.needs_resync_reasons) - report_state.return_value = n_const.AGENT_REVIVED + report_state.return_value = agent_consts.AGENT_REVIVED dhcp._report_state() self.assertEqual(dhcp.needs_resync_reasons[None], ['Agent has just been revived']) diff --git a/neutron/tests/unit/agent/l2/extensions/test_qos.py b/neutron/tests/unit/agent/l2/extensions/test_qos.py index 59e293c43a8..f14a5ada86c 100644 --- a/neutron/tests/unit/agent/l2/extensions/test_qos.py +++ b/neutron/tests/unit/agent/l2/extensions/test_qos.py @@ -14,7 +14,9 @@ # under the License. import mock +from neutron_lib import constants as common_constants from neutron_lib import context +from neutron_lib.db import constants as db_consts from oslo_utils import uuidutils from neutron.agent.l2.extensions import qos @@ -23,7 +25,6 @@ from neutron.api.rpc.callbacks.consumer import registry from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import resources_rpc -from neutron.common import constants as common_constants from neutron.objects.qos import policy from neutron.objects.qos import rule from neutron.plugins.ml2.drivers.openvswitch.agent import ( @@ -62,9 +63,9 @@ class FakeDriver(qos_linux.QosLinuxAgentDriver): SUPPORTED_RULES = { qos_consts.RULE_TYPE_BANDWIDTH_LIMIT: { qos_consts.MAX_KBPS: { - 'type:range': [0, common_constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.MAX_BURST: { - 'type:range': [0, common_constants.DB_INTEGER_MAX_VALUE]}, + 'type:range': [0, db_consts.DB_INTEGER_MAX_VALUE]}, qos_consts.DIRECTION: { 'type:values': [common_constants.EGRESS_DIRECTION, common_constants.INGRESS_DIRECTION]} diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index d268208db0e..a89a2792cfc 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -20,6 +20,7 @@ from itertools import combinations as iter_combinations import eventlet import mock import netaddr +from neutron_lib.agent import constants as agent_consts from neutron_lib.api.definitions import portbindings from neutron_lib import constants as lib_constants from neutron_lib import exceptions as exc @@ -325,12 +326,12 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): 'report_state') as report_state: agent = l3_agent.L3NATAgentWithStateReport(host=HOSTNAME, conf=self.conf) - report_state.return_value = n_const.AGENT_REVIVED + report_state.return_value = agent_consts.AGENT_REVIVED agent._report_state() self.assertTrue(agent.fullsync) agent.fullsync = False - report_state.return_value = n_const.AGENT_ALIVE + report_state.return_value = agent_consts.AGENT_ALIVE agent._report_state() self.assertFalse(agent.fullsync) diff --git a/neutron/tests/unit/agent/linux/test_dhcp.py b/neutron/tests/unit/agent/linux/test_dhcp.py index eb8edb8bf2c..6f50eef44b8 100644 --- a/neutron/tests/unit/agent/linux/test_dhcp.py +++ b/neutron/tests/unit/agent/linux/test_dhcp.py @@ -25,7 +25,6 @@ from oslo_utils import fileutils import testtools from neutron.agent.linux import dhcp -from neutron.common import constants as n_const from neutron.conf.agent import common as config from neutron.conf.agent import dhcp as dhcp_config from neutron.conf import common as base_config @@ -91,7 +90,7 @@ class FakeReservedPort(object): FakeIPAllocation('fdca:3ba5:a17a:4ba3::2', 'ffffffff-ffff-ffff-ffff-ffffffffffff')] self.mac_address = '00:00:80:aa:bb:ee' - self.device_id = n_const.DEVICE_ID_RESERVED_DHCP_PORT + self.device_id = constants.DEVICE_ID_RESERVED_DHCP_PORT self.extra_dhcp_opts = [] self.id = id diff --git a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py index 9345c52b372..3056f5b2e9b 100644 --- a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py +++ b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py @@ -23,7 +23,6 @@ from neutron_lib.plugins import directory from oslo_db import exception as db_exc from neutron.api.rpc.handlers import dhcp_rpc -from neutron.common import constants as n_const from neutron.common import exceptions from neutron.common import utils from neutron.db import provisioning_blocks @@ -177,7 +176,7 @@ class TestDhcpRpcCallback(base.BaseTestCase): def test_update_port_missing_port_on_update(self): self.plugin.get_port.return_value = { - 'device_id': n_const.DEVICE_ID_RESERVED_DHCP_PORT} + 'device_id': constants.DEVICE_ID_RESERVED_DHCP_PORT} self.plugin.update_port.side_effect = n_exc.PortNotFound(port_id='66') self.assertIsNone(self.callbacks.update_dhcp_port( context='ctx', host='host', port_id='66', @@ -251,7 +250,7 @@ class TestDhcpRpcCallback(base.BaseTestCase): self.assertEqual(expected_port, port) self.plugin.get_port.return_value = { - 'device_id': n_const.DEVICE_ID_RESERVED_DHCP_PORT} + 'device_id': constants.DEVICE_ID_RESERVED_DHCP_PORT} self.callbacks._port_action = _fake_port_action self.callbacks.update_dhcp_port(mock.Mock(), host='foo_host', @@ -303,7 +302,7 @@ class TestDhcpRpcCallback(base.BaseTestCase): 'id': 'foo_port_id' } self.plugin.get_port.return_value = { - 'device_id': n_const.DEVICE_ID_RESERVED_DHCP_PORT} + 'device_id': constants.DEVICE_ID_RESERVED_DHCP_PORT} self.callbacks.update_dhcp_port(mock.Mock(), host='foo_host', port_id='foo_port_id', diff --git a/neutron/tests/unit/db/test_agentschedulers_db.py b/neutron/tests/unit/db/test_agentschedulers_db.py index 3155b7d9e99..df1135f575d 100644 --- a/neutron/tests/unit/db/test_agentschedulers_db.py +++ b/neutron/tests/unit/db/test_agentschedulers_db.py @@ -31,7 +31,6 @@ from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api from neutron.api.rpc.handlers import dhcp_rpc from neutron.api.rpc.handlers import l3_rpc from neutron.api.v2 import attributes -from neutron.common import constants as n_const from neutron.db import agents_db from neutron.db import agentschedulers_db from neutron.db.models import agent as agent_model @@ -640,7 +639,7 @@ class OvsAgentSchedulerTestCase(OvsAgentSchedulerTestCaseBase): network_id=port1['port']['network_id']) port_list = self.deserialize('json', port_res) self.assertEqual(port_list['ports'][0]['device_id'], - n_const.DEVICE_ID_RESERVED_DHCP_PORT) + constants.DEVICE_ID_RESERVED_DHCP_PORT) def _test_get_active_networks_from_admin_state_down_agent(self, keep_services): @@ -1441,7 +1440,7 @@ class OvsDhcpAgentNotifierTestCase(test_agent.AgentDBTestMixIn, return dhcp_notifier_schedule.call_count > 1 def test_reserved_dhcp_port_creation(self): - device_id = n_const.DEVICE_ID_RESERVED_DHCP_PORT + device_id = constants.DEVICE_ID_RESERVED_DHCP_PORT self.assertFalse(self._is_schedule_network_called(device_id)) def test_unreserved_dhcp_port_creation(self): diff --git a/neutron/tests/unit/db/test_l3_hamode_db.py b/neutron/tests/unit/db/test_l3_hamode_db.py index 4cf79ecad9b..f0caa0f1ea6 100644 --- a/neutron/tests/unit/db/test_l3_hamode_db.py +++ b/neutron/tests/unit/db/test_l3_hamode_db.py @@ -477,7 +477,7 @@ class L3HATestCase(L3HATestFramework): @mock.patch('neutron.db.l3_hamode_db.VR_ID_RANGE', new=set(range(1, 1))) def test_vr_id_depleted(self): - self.assertEqual(n_const.ROUTER_STATUS_ERROR, + self.assertEqual(constants.ERROR, self._create_router()['status']) @mock.patch('neutron.db.l3_hamode_db.VR_ID_RANGE', new=set(range(1, 2))) @@ -698,7 +698,7 @@ class L3HATestCase(L3HATestFramework): '_notify_router_updated'): with mock.patch.object(self.plugin, method, side_effect=ValueError): - self.assertEqual(n_const.ROUTER_STATUS_ERROR, + self.assertEqual(constants.ERROR, self._create_router()['status']) def test_get_active_host_for_ha_router(self): diff --git a/neutron/tests/unit/extensions/test_quotasv2.py b/neutron/tests/unit/extensions/test_quotasv2.py index 047dc4baa68..d9309af6459 100644 --- a/neutron/tests/unit/extensions/test_quotasv2.py +++ b/neutron/tests/unit/extensions/test_quotasv2.py @@ -17,6 +17,7 @@ import sys import mock from neutron_lib import context +from neutron_lib.db import constants from oslo_config import cfg import testtools from webob import exc @@ -25,7 +26,6 @@ import webtest from neutron.api import extensions from neutron.api.v2 import router from neutron.common import config -from neutron.common import constants from neutron.common import exceptions from neutron.conf import quota as qconf from neutron.db.quota import driver diff --git a/neutron/tests/unit/objects/qos/test_policy.py b/neutron/tests/unit/objects/qos/test_policy.py index a9a14d94d0c..7838178562d 100644 --- a/neutron/tests/unit/objects/qos/test_policy.py +++ b/neutron/tests/unit/objects/qos/test_policy.py @@ -11,11 +11,11 @@ # under the License. import mock +from neutron_lib import constants as n_const from oslo_utils import uuidutils from oslo_versionedobjects import exception import testtools -from neutron.common import constants as n_const from neutron.common import exceptions as n_exc from neutron.db import models_v2 from neutron.objects.db import api as db_api diff --git a/neutron/tests/unit/objects/qos/test_rule.py b/neutron/tests/unit/objects/qos/test_rule.py index 931bcb41e6b..b7f8fd62bf3 100644 --- a/neutron/tests/unit/objects/qos/test_rule.py +++ b/neutron/tests/unit/objects/qos/test_rule.py @@ -15,7 +15,6 @@ from neutron_lib import constants from oslo_utils import uuidutils from oslo_versionedobjects import exception -from neutron.common import constants as n_const from neutron.objects.qos import policy from neutron.objects.qos import rule from neutron.services.qos import qos_consts @@ -120,7 +119,7 @@ class QosBandwidthLimitRuleObjectTestCase(test_base.BaseObjectIfaceTestCase): self.assertEqual(qos_consts.RULE_TYPE_BANDWIDTH_LIMIT, dict_['type']) def test_bandwidth_limit_object_version_degradation(self): - self.db_objs[0]['direction'] = n_const.EGRESS_DIRECTION + self.db_objs[0]['direction'] = constants.EGRESS_DIRECTION rule_obj = rule.QosBandwidthLimitRule(self.context, **self.db_objs[0]) primitive_rule = rule_obj.obj_to_primitive('1.2') self.assertNotIn( @@ -132,7 +131,7 @@ class QosBandwidthLimitRuleObjectTestCase(test_base.BaseObjectIfaceTestCase): self.db_objs[0]['max_burst_kbps'], primitive_rule['versioned_object.data']['max_burst_kbps']) - self.db_objs[0]['direction'] = n_const.INGRESS_DIRECTION + self.db_objs[0]['direction'] = constants.INGRESS_DIRECTION rule_obj = rule.QosBandwidthLimitRule(self.context, **self.db_objs[0]) self.assertRaises( exception.IncompatibleObjectVersion, diff --git a/neutron/tests/unit/objects/qos/test_rule_type.py b/neutron/tests/unit/objects/qos/test_rule_type.py index bc609812e0f..378e16643ee 100644 --- a/neutron/tests/unit/objects/qos/test_rule_type.py +++ b/neutron/tests/unit/objects/qos/test_rule_type.py @@ -14,6 +14,8 @@ # class on the common base class for all objects import mock +from neutron_lib import constants as lib_consts +from neutron_lib.db import constants as db_consts from oslo_config import cfg from neutron.common import constants @@ -30,15 +32,15 @@ DRIVER_SUPPORTED_PARAMETERS = [ { 'parameter_name': qos_consts.MAX_KBPS, 'parameter_type': constants.VALUES_TYPE_RANGE, - 'parameter_values': {"start": 0, "end": constants.DB_INTEGER_MAX_VALUE} + 'parameter_values': {"start": 0, "end": db_consts.DB_INTEGER_MAX_VALUE} }, { 'parameter_name': qos_consts.MAX_BURST, 'parameter_type': constants.VALUES_TYPE_RANGE, - 'parameter_values': {"start": 0, "end": constants.DB_INTEGER_MAX_VALUE} + 'parameter_values': {"start": 0, "end": db_consts.DB_INTEGER_MAX_VALUE} }, { 'parameter_name': qos_consts.DIRECTION, 'parameter_type': constants.VALUES_TYPE_CHOICES, - 'parameter_values': constants.VALID_DIRECTIONS + 'parameter_values': lib_consts.VALID_DIRECTIONS } ] diff --git a/neutron/tests/unit/objects/test_base.py b/neutron/tests/unit/objects/test_base.py index d86448a9b65..1277f4e1095 100644 --- a/neutron/tests/unit/objects/test_base.py +++ b/neutron/tests/unit/objects/test_base.py @@ -17,6 +17,7 @@ import random import mock import netaddr +from neutron_lib import constants from neutron_lib import context from neutron_lib import exceptions as n_exc from neutron_lib.objects import exceptions as o_exc @@ -30,7 +31,6 @@ from oslo_versionedobjects import fields as obj_fields from oslo_versionedobjects import fixture import testtools -from neutron.common import constants from neutron.db import _model_query as model_query from neutron.db.models import l3 as l3_model from neutron.db import standard_attr diff --git a/neutron/tests/unit/objects/test_common_types.py b/neutron/tests/unit/objects/test_common_types.py index 7463d8a4225..c33c8bb7f9a 100644 --- a/neutron/tests/unit/objects/test_common_types.py +++ b/neutron/tests/unit/objects/test_common_types.py @@ -84,7 +84,7 @@ class DscpMarkFieldTest(test_base.BaseTestCase, TestField): super(DscpMarkFieldTest, self).setUp() self.field = common_types.DscpMarkField() self.coerce_good_values = [(val, val) - for val in constants.VALID_DSCP_MARKS] + for val in const.VALID_DSCP_MARKS] self.coerce_bad_values = ['6', 'str', [], {}, object()] self.to_primitive_values = self.coerce_good_values self.from_primitive_values = self.coerce_good_values @@ -176,7 +176,7 @@ class FlowDirectionEnumFieldTest(test_base.BaseTestCase, TestField): super(FlowDirectionEnumFieldTest, self).setUp() self.field = common_types.FlowDirectionEnumField() self.coerce_good_values = [(val, val) - for val in constants.VALID_DIRECTIONS] + for val in const.VALID_DIRECTIONS] self.coerce_bad_values = ['test', '8', 10, []] self.to_primitive_values = self.coerce_good_values self.from_primitive_values = self.coerce_good_values diff --git a/neutron/tests/unit/plugins/ml2/drivers/agent/test__common_agent.py b/neutron/tests/unit/plugins/ml2/drivers/agent/test__common_agent.py index e3f397c834d..a97372ed825 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/agent/test__common_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/agent/test__common_agent.py @@ -15,6 +15,7 @@ # under the License. import mock +from neutron_lib.agent import constants as agent_consts from neutron_lib.callbacks import events from neutron_lib.callbacks import registry from neutron_lib.callbacks import resources @@ -23,7 +24,6 @@ from oslo_config import cfg import testtools from neutron.agent.linux import bridge_lib -from neutron.common import constants as n_const from neutron.plugins.ml2.drivers.agent import _agent_manager_base as amb from neutron.plugins.ml2.drivers.agent import _common_agent as ca from neutron.tests import base @@ -537,7 +537,7 @@ class TestCommonAgentLoop(base.BaseTestCase): def test_report_state_revived(self): with mock.patch.object(self.agent.state_rpc, "report_state") as report_st: - report_st.return_value = n_const.AGENT_REVIVED + report_st.return_value = agent_consts.AGENT_REVIVED self.agent._report_state() self.assertTrue(self.agent.fullsync) diff --git a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/test_qos_driver.py b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/test_qos_driver.py index 52f9d9d7d70..48fe5317b18 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/test_qos_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/extension_drivers/test_qos_driver.py @@ -14,11 +14,11 @@ import mock +from neutron_lib import constants from oslo_config import cfg from oslo_utils import uuidutils from neutron.agent.linux import tc_lib -from neutron.common import constants from neutron.objects.qos import rule from neutron.plugins.ml2.drivers.linuxbridge.agent.common import config # noqa from neutron.plugins.ml2.drivers.linuxbridge.agent.extension_drivers import ( diff --git a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/extension_drivers/test_qos_driver.py b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/extension_drivers/test_qos_driver.py index 01a64c55649..e08533f98a6 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/extension_drivers/test_qos_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/mech_sriov/agent/extension_drivers/test_qos_driver.py @@ -14,10 +14,10 @@ # limitations under the License. import mock +from neutron_lib import constants from neutron_lib import context from oslo_utils import uuidutils -from neutron.common import constants from neutron.objects.qos import policy from neutron.objects.qos import rule from neutron.plugins.ml2.drivers.mech_sriov.agent.common import exceptions diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/extension_drivers/test_qos_driver.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/extension_drivers/test_qos_driver.py index dba464b3ddb..d0160e0d218 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/extension_drivers/test_qos_driver.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/extension_drivers/test_qos_driver.py @@ -13,10 +13,10 @@ import copy import mock +from neutron_lib import constants from neutron_lib import context from oslo_utils import uuidutils -from neutron.common import constants from neutron.objects.qos import policy from neutron.objects.qos import rule from neutron.plugins.ml2.drivers.openvswitch.agent import ( diff --git a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py index 89f9924810f..dd43522cb39 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py @@ -16,6 +16,7 @@ import sys import time import mock +from neutron_lib.agent import constants as agent_consts from neutron_lib import constants as n_const from oslo_config import cfg from oslo_log import log @@ -27,7 +28,6 @@ from neutron.agent.common import ovs_lib from neutron.agent.common import utils from neutron.agent.linux import async_process from neutron.agent.linux import ip_lib -from neutron.common import constants as c_const from neutron.common import rpc as n_rpc from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc @@ -1089,7 +1089,7 @@ class TestOvsNeutronAgent(object): def test_report_state_revived(self): with mock.patch.object(self.agent.state_rpc, "report_state") as report_st: - report_st.return_value = c_const.AGENT_REVIVED + report_st.return_value = agent_consts.AGENT_REVIVED self.agent._report_state() self.assertTrue(self.agent.fullsync) diff --git a/neutron/tests/unit/services/qos/drivers/test_manager.py b/neutron/tests/unit/services/qos/drivers/test_manager.py index 39e35f21b46..5f77994b740 100644 --- a/neutron/tests/unit/services/qos/drivers/test_manager.py +++ b/neutron/tests/unit/services/qos/drivers/test_manager.py @@ -12,6 +12,7 @@ import mock from neutron_lib.api.definitions import portbindings +from neutron_lib import constants as lib_consts from neutron_lib import context from neutron_lib.services.qos import base as qos_driver_base from oslo_utils import uuidutils @@ -95,7 +96,7 @@ class TestQoSDriversRulesValidations(TestQosDriversManagerBase): qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { "min_kbps": {'type:values': None}, 'direction': { - 'type:values': constants.VALID_DIRECTIONS} + 'type:values': lib_consts.VALID_DIRECTIONS} } }, 'vif_types': [portbindings.VIF_TYPE_OVS], @@ -156,7 +157,7 @@ class TestQosDriversManagerRules(TestQosDriversManagerBase): qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { "min_kbps": {'type:values': None}, 'direction': { - 'type:values': constants.VALID_DIRECTIONS} + 'type:values': lib_consts.VALID_DIRECTIONS} } } }, @@ -166,11 +167,11 @@ class TestQosDriversManagerRules(TestQosDriversManagerBase): qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { "min_kbps": {'type:values': None}, 'direction': { - 'type:values': constants.VALID_DIRECTIONS} + 'type:values': lib_consts.VALID_DIRECTIONS} }, qos_consts.RULE_TYPE_DSCP_MARKING: { "dscp_mark": { - 'type:values': constants.VALID_DSCP_MARKS} + 'type:values': lib_consts.VALID_DSCP_MARKS} } } } @@ -195,11 +196,11 @@ class TestQosDriversManagerRules(TestQosDriversManagerBase): qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { "min_kbps": {'type:values': None}, 'direction': { - 'type:values': constants.VALID_DIRECTIONS} + 'type:values': lib_consts.VALID_DIRECTIONS} }, qos_consts.RULE_TYPE_DSCP_MARKING: { "dscp_mark": { - 'type:values': constants.VALID_DSCP_MARKS} + 'type:values': lib_consts.VALID_DSCP_MARKS} } } } @@ -245,11 +246,11 @@ class TestQosDriversManagerRules(TestQosDriversManagerBase): qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH: { "min_kbps": {'type:range': [0, 1000]}, 'direction': { - 'type:values': constants.VALID_DIRECTIONS} + 'type:values': lib_consts.VALID_DIRECTIONS} }, qos_consts.RULE_TYPE_DSCP_MARKING: { "dscp_mark": { - 'type:values': constants.VALID_DSCP_MARKS} + 'type:values': lib_consts.VALID_DSCP_MARKS} } } }