Browse Source

use plugin constants from neutron-lib

neutron-lib contains a number of the plugin related constants from
neutron.plugins.common.constants. This patch consumes those constants
from neutron-lib and removes them from neutron. In addition the notion
of the dummy plugin service type is moved strictly into the test
package of neutron since it's not a real service plugin.

NeutronLibImpact

Change-Id: I767c626f3fe6159ab3abd6a7ae3cb9893b79bf66
changes/95/469495/6
Boden R 5 years ago
parent
commit
95f1e03446
  1. 2
      neutron/agent/common/ovs_lib.py
  2. 5
      neutron/cmd/sanity/checks.py
  3. 2
      neutron/conf/plugins/ml2/drivers/driver_type.py
  4. 3
      neutron/conf/plugins/ml2/drivers/ovs_conf.py
  5. 2
      neutron/core_extensions/qos.py
  6. 2
      neutron/extensions/flavors.py
  7. 2
      neutron/extensions/metering.py
  8. 2
      neutron/extensions/qos.py
  9. 5
      neutron/objects/common_types.py
  10. 2
      neutron/objects/qos/rule_type.py
  11. 81
      neutron/plugins/common/constants.py
  12. 22
      neutron/plugins/common/utils.py
  13. 21
      neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py
  14. 5
      neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py
  15. 3
      neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py
  16. 5
      neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py
  17. 3
      neutron/plugins/ml2/drivers/mech_agent.py
  18. 7
      neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py
  19. 2
      neutron/plugins/ml2/drivers/openvswitch/agent/common/constants.py
  20. 2
      neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_int.py
  21. 3
      neutron/plugins/ml2/drivers/openvswitch/agent/openflow/ovs_ofctl/br_int.py
  22. 21
      neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py
  23. 23
      neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py
  24. 5
      neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py
  25. 2
      neutron/plugins/ml2/drivers/type_flat.py
  26. 2
      neutron/plugins/ml2/drivers/type_geneve.py
  27. 2
      neutron/plugins/ml2/drivers/type_gre.py
  28. 2
      neutron/plugins/ml2/drivers/type_local.py
  29. 2
      neutron/plugins/ml2/drivers/type_tunnel.py
  30. 2
      neutron/plugins/ml2/drivers/type_vlan.py
  31. 2
      neutron/plugins/ml2/drivers/type_vxlan.py
  32. 2
      neutron/services/flavors/flavors_plugin.py
  33. 4
      neutron/services/l3_router/service_providers/driver_controller.py
  34. 3
      neutron/tests/functional/agent/l2/base.py
  35. 4
      neutron/tests/functional/pecan_wsgi/test_controllers.py
  36. 3
      neutron/tests/tools.py
  37. 7
      neutron/tests/unit/_test_extension_portbindings.py
  38. 2
      neutron/tests/unit/agent/common/test_ovs_lib.py
  39. 7
      neutron/tests/unit/api/test_extensions.py
  40. 22
      neutron/tests/unit/api/v2/test_base.py
  41. 13
      neutron/tests/unit/common/test_utils.py
  42. 2
      neutron/tests/unit/core_extensions/test_qos.py
  43. 2
      neutron/tests/unit/db/metering/test_metering_db.py
  44. 16
      neutron/tests/unit/dummy_plugin.py
  45. 14
      neutron/tests/unit/extensions/test_flavors.py
  46. 35
      neutron/tests/unit/extensions/test_segment.py
  47. 27
      neutron/tests/unit/extensions/test_servicetype.py
  48. 2
      neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py
  49. 82
      neutron/tests/unit/plugins/ml2/drivers/linuxbridge/agent/test_linuxbridge_neutron_agent.py
  50. 5
      neutron/tests/unit/plugins/ml2/drivers/mech_fake_agent.py
  51. 7
      neutron/tests/unit/plugins/ml2/drivers/mech_sriov/mech_driver/test_mech_sriov_nic_switch.py
  52. 43
      neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_neutron_agent.py
  53. 19
      neutron/tests/unit/plugins/ml2/drivers/openvswitch/agent/test_ovs_tunnel.py
  54. 2
      neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py
  55. 3
      neutron/tests/unit/plugins/ml2/drivers/test_type_geneve.py
  56. 3
      neutron/tests/unit/plugins/ml2/drivers/test_type_gre.py
  57. 2
      neutron/tests/unit/plugins/ml2/drivers/test_type_local.py
  58. 2
      neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py
  59. 3
      neutron/tests/unit/plugins/ml2/drivers/test_type_vxlan.py
  60. 7
      neutron/tests/unit/plugins/ml2/test_plugin.py
  61. 2
      neutron/tests/unit/services/l3_router/service_providers/test_driver_controller.py
  62. 2
      neutron/tests/unit/services/metering/test_metering_plugin.py
  63. 2
      neutron/tests/unit/services/qos/test_qos_plugin.py
  64. 2
      neutron/tests/unit/services/test_provider_configuration.py
  65. 41
      neutron/tests/unit/test_manager.py

2
neutron/agent/common/ovs_lib.py

@ -21,6 +21,7 @@ import time
import uuid
from debtcollector import removals
from neutron_lib import constants as p_const
from neutron_lib import exceptions
from oslo_config import cfg
from oslo_log import log as logging
@ -32,7 +33,6 @@ from neutron.agent.common import ip_lib
from neutron.agent.common import utils
from neutron.agent.ovsdb import api as ovsdb_api
from neutron.conf.agent import ovs_conf
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
import constants

5
neutron/cmd/sanity/checks.py

@ -34,7 +34,6 @@ from neutron.agent.linux import utils as agent_utils
from neutron.cmd import runtime_checks
from neutron.common import constants
from neutron.common import utils as common_utils
from neutron.plugins.common import constants as const
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
import constants as ovs_const
@ -49,14 +48,14 @@ MINIMUM_DIBBLER_VERSION = '1.0.1'
def ovs_vxlan_supported(from_ip='192.0.2.1', to_ip='192.0.2.2'):
name = common_utils.get_rand_device_name(prefix='vxlantest-')
with ovs_lib.OVSBridge(name) as br:
port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
port = br.add_tunnel_port(from_ip, to_ip, n_consts.TYPE_VXLAN)
return port != ovs_lib.INVALID_OFPORT
def ovs_geneve_supported(from_ip='192.0.2.3', to_ip='192.0.2.4'):
name = common_utils.get_rand_device_name(prefix='genevetest-')
with ovs_lib.OVSBridge(name) as br:
port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_GENEVE)
port = br.add_tunnel_port(from_ip, to_ip, n_consts.TYPE_GENEVE)
return port != ovs_lib.INVALID_OFPORT

2
neutron/conf/plugins/ml2/drivers/driver_type.py

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants as p_const
from oslo_config import cfg
from neutron._i18n import _
from neutron.plugins.common import constants as p_const
gre_opts = [

3
neutron/conf/plugins/ml2/drivers/ovs_conf.py

@ -16,7 +16,6 @@ from neutron_lib import constants as n_const
from oslo_config import cfg
from neutron._i18n import _
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
import constants
@ -111,7 +110,7 @@ agent_opts = [
cfg.ListOpt('tunnel_types', default=DEFAULT_TUNNEL_TYPES,
help=_("Network types supported by the agent "
"(gre and/or vxlan).")),
cfg.PortOpt('vxlan_udp_port', default=p_const.VXLAN_UDP_PORT,
cfg.PortOpt('vxlan_udp_port', default=n_const.VXLAN_UDP_PORT,
help=_("The UDP port to use for VXLAN tunnels.")),
cfg.IntOpt('veth_mtu', default=9000,
help=_("MTU size of veth interfaces")),

2
neutron/core_extensions/qos.py

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.plugins import constants as plugin_constants
from neutron_lib.plugins import directory
from neutron.common import exceptions as n_exc
from neutron.core_extensions import base
from neutron.db import api as db_api
from neutron.objects.qos import policy as policy_object
from neutron.plugins.common import constants as plugin_constants
from neutron.services.qos import qos_consts

2
neutron/extensions/flavors.py

@ -17,13 +17,13 @@ from neutron_lib.api import extensions as api_extensions
from neutron_lib.api import validators
from neutron_lib.db import constants as db_const
from neutron_lib import exceptions as nexception
from neutron_lib.plugins import constants
from neutron_lib.plugins import directory
from neutron._i18n import _
from neutron.api import extensions
from neutron.api.v2 import base
from neutron.api.v2 import resource_helper
from neutron.plugins.common import constants
# Flavor Exceptions

2
neutron/extensions/metering.py

@ -18,12 +18,12 @@ from neutron_lib.api import converters
from neutron_lib.api import extensions
from neutron_lib.db import constants as db_const
from neutron_lib import exceptions as nexception
from neutron_lib.plugins import constants
from neutron_lib.services import base as service_base
import six
from neutron._i18n import _
from neutron.api.v2 import resource_helper
from neutron.plugins.common import constants
class MeteringLabelNotFound(nexception.NotFound):

2
neutron/extensions/qos.py

@ -20,6 +20,7 @@ import re
from neutron_lib.api import converters
from neutron_lib.api import extensions as api_extensions
from neutron_lib.db import constants as db_const
from neutron_lib.plugins import constants
from neutron_lib.plugins import directory
from neutron_lib.services import base as service_base
import six
@ -29,7 +30,6 @@ 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

5
neutron/objects/common_types.py

@ -26,7 +26,6 @@ import six
from neutron._i18n import _
from neutron.common import constants
from neutron.common import utils
from neutron.plugins.common import constants as plugin_constants
class HARouterEnumField(obj_fields.AutoTypedField):
@ -85,8 +84,8 @@ class PortRangeWith0Field(obj_fields.AutoTypedField):
class VlanIdRange(RangeConstrainedInteger):
def __init__(self, **kwargs):
super(VlanIdRange, self).__init__(start=plugin_constants.MIN_VLAN_TAG,
end=plugin_constants.MAX_VLAN_TAG,
super(VlanIdRange, self).__init__(start=lib_constants.MIN_VLAN_TAG,
end=lib_constants.MAX_VLAN_TAG,
**kwargs)

2
neutron/objects/qos/rule_type.py

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron.plugins.common import constants
from neutron_lib.plugins import constants
from neutron_lib.plugins import directory
from oslo_log import log as logging
from oslo_utils import versionutils

81
neutron/plugins/common/constants.py

@ -13,31 +13,23 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.plugins import constants
from neutron_lib import constants
from neutron_lib.plugins import constants as p_const
# Neutron well-known service type constants:
DUMMY = "DUMMY"
LOADBALANCER = "LOADBALANCER"
LOADBALANCERV2 = "LOADBALANCERV2"
FIREWALL = "FIREWALL"
VPN = "VPN"
METERING = "METERING"
FLAVORS = "FLAVORS"
QOS = "QOS"
# TODO(boden): consume once I208c976c3e7e43e27e1907ed196af8efccd73f22 releases
LOG_API = "LOGGING"
# Maps extension alias to service type that
# can be implemented by the core plugin.
EXT_TO_SERVICE_MAPPING = {
'dummy': DUMMY,
'lbaas': LOADBALANCER,
'lbaasv2': LOADBALANCERV2,
'fwaas': FIREWALL,
'vpnaas': VPN,
'metering': METERING,
'lbaas': p_const.LOADBALANCER,
'lbaasv2': p_const.LOADBALANCERV2,
'fwaas': p_const.FIREWALL,
'vpnaas': p_const.VPN,
'metering': p_const.METERING,
'router': constants.L3,
'qos': QOS,
'qos': p_const.QOS,
}
# Maps default service plugins entry points to their extension aliases
@ -49,58 +41,3 @@ DEFAULT_SERVICE_PLUGINS = {
'flavors': 'flavors',
'revisions': 'revisions',
}
# Service operation status constants
ACTIVE = "ACTIVE"
DOWN = "DOWN"
CREATED = "CREATED"
PENDING_CREATE = "PENDING_CREATE"
PENDING_UPDATE = "PENDING_UPDATE"
PENDING_DELETE = "PENDING_DELETE"
INACTIVE = "INACTIVE"
ERROR = "ERROR"
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
# IP header length
IP_HEADER_LENGTH = {
4: 20,
6: 40,
}

22
neutron/plugins/common/utils.py

@ -35,7 +35,7 @@ import webob.exc
from neutron._i18n import _
from neutron.api.v2 import attributes
from neutron.common import exceptions as n_exc
from neutron.plugins.common import constants as p_const
INTERFACE_HASH_LEN = 6
LOG = logging.getLogger(__name__)
@ -53,26 +53,26 @@ def get_deployment_physnet_mtu():
def is_valid_vlan_tag(vlan):
return p_const.MIN_VLAN_TAG <= vlan <= p_const.MAX_VLAN_TAG
return n_const.MIN_VLAN_TAG <= vlan <= n_const.MAX_VLAN_TAG
def is_valid_gre_id(gre_id):
return p_const.MIN_GRE_ID <= gre_id <= p_const.MAX_GRE_ID
return n_const.MIN_GRE_ID <= gre_id <= n_const.MAX_GRE_ID
def is_valid_vxlan_vni(vni):
return p_const.MIN_VXLAN_VNI <= vni <= p_const.MAX_VXLAN_VNI
return n_const.MIN_VXLAN_VNI <= vni <= n_const.MAX_VXLAN_VNI
def is_valid_geneve_vni(vni):
return p_const.MIN_GENEVE_VNI <= vni <= p_const.MAX_GENEVE_VNI
return n_const.MIN_GENEVE_VNI <= vni <= n_const.MAX_GENEVE_VNI
def verify_tunnel_range(tunnel_range, tunnel_type):
"""Raise an exception for invalid tunnel range or malformed range."""
mappings = {p_const.TYPE_GRE: is_valid_gre_id,
p_const.TYPE_VXLAN: is_valid_vxlan_vni,
p_const.TYPE_GENEVE: is_valid_geneve_vni}
mappings = {n_const.TYPE_GRE: is_valid_gre_id,
n_const.TYPE_VXLAN: is_valid_vxlan_vni,
n_const.TYPE_GENEVE: is_valid_geneve_vni}
if tunnel_type in mappings:
for ident in tunnel_range:
if not mappings[tunnel_type](ident):
@ -147,9 +147,9 @@ def parse_network_vlan_ranges(network_vlan_ranges_cfg_entries):
def in_pending_status(status):
return status in (p_const.PENDING_CREATE,
p_const.PENDING_UPDATE,
p_const.PENDING_DELETE)
return status in (n_const.PENDING_CREATE,
n_const.PENDING_UPDATE,
n_const.PENDING_DELETE)
def _fixup_res_dict(context, attr_name, res_dict, check_allow_post=True):

21
neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py

@ -39,7 +39,6 @@ from neutron.common import exceptions
from neutron.common import profiler as setup_profiler
from neutron.common import topics
from neutron.common import utils
from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as p_utils
from neutron.plugins.ml2.drivers.agent import _agent_manager_base as amb
from neutron.plugins.ml2.drivers.agent import _common_agent as ca
@ -197,7 +196,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
return lb_utils.get_tap_device_name(interface_id)
def get_vxlan_device_name(self, segmentation_id):
if 0 <= int(segmentation_id) <= p_const.MAX_VXLAN_VNI:
if 0 <= int(segmentation_id) <= constants.MAX_VXLAN_VNI:
return VXLAN_INTERFACE_PREFIX + str(segmentation_id)
else:
LOG.warning("Invalid Segmentation ID: %s, will lead to "
@ -450,7 +449,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
network_type,
physical_network,
segmentation_id):
if network_type == p_const.TYPE_VXLAN:
if network_type == constants.TYPE_VXLAN:
if self.vxlan_mode == lconst.VXLAN_NONE:
LOG.error("Unable to add vxlan interface for network %s",
network_id)
@ -465,10 +464,10 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
" for physical network %s",
physical_network)
return
if network_type == p_const.TYPE_FLAT:
if network_type == constants.TYPE_FLAT:
return self.ensure_flat_bridge(network_id, physical_bridge,
physical_interface)
elif network_type == p_const.TYPE_VLAN:
elif network_type == constants.TYPE_VLAN:
return self.ensure_vlan_bridge(network_id, physical_bridge,
physical_interface,
segmentation_id)
@ -509,7 +508,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
if not bridge_name:
bridge_name = self.get_bridge_name(network_id)
if network_type == p_const.TYPE_LOCAL:
if network_type == constants.TYPE_LOCAL:
self.ensure_local_bridge(network_id, bridge_name)
elif not self.ensure_physical_in_bridge(network_id,
network_type,
@ -666,7 +665,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
return False
test_iface = None
for seg_id in moves.range(1, p_const.MAX_VXLAN_VNI + 1):
for seg_id in moves.range(1, constants.MAX_VXLAN_VNI + 1):
if (ip_lib.device_exists(self.get_vxlan_device_name(seg_id))
or ip_lib.vxlan_in_use(seg_id)):
continue
@ -781,7 +780,7 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase):
}
if self.vxlan_mode != lconst.VXLAN_NONE:
configurations['tunneling_ip'] = self.local_ip
configurations['tunnel_types'] = [p_const.TYPE_VXLAN]
configurations['tunnel_types'] = [constants.TYPE_VXLAN]
configurations['l2_population'] = cfg.CONF.VXLAN.l2_population
return configurations
@ -874,7 +873,7 @@ class LinuxBridgeRpcCallbacks(
if not segment:
return
if segment.network_type != p_const.TYPE_VXLAN:
if segment.network_type != constants.TYPE_VXLAN:
return
interface = self.agent.mgr.get_vxlan_device_name(
@ -896,7 +895,7 @@ class LinuxBridgeRpcCallbacks(
if not segment:
return
if segment.network_type != p_const.TYPE_VXLAN:
if segment.network_type != constants.TYPE_VXLAN:
return
interface = self.agent.mgr.get_vxlan_device_name(
@ -918,7 +917,7 @@ class LinuxBridgeRpcCallbacks(
if not segment:
return
if segment.network_type != p_const.TYPE_VXLAN:
if segment.network_type != constants.TYPE_VXLAN:
return
interface = self.agent.mgr.get_vxlan_device_name(

5
neutron/plugins/ml2/drivers/linuxbridge/mech_driver/mech_linuxbridge.py

@ -17,7 +17,6 @@ from neutron_lib.api.definitions import portbindings
from neutron_lib import constants
from neutron.agent import securitygroups_rpc
from neutron.plugins.common import constants as p_constants
from neutron.plugins.ml2.drivers import mech_agent
from neutron.services.qos.drivers.linuxbridge import driver as lb_qos_driver
@ -42,8 +41,8 @@ class LinuxbridgeMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def get_allowed_network_types(self, agent):
return (agent['configurations'].get('tunnel_types', []) +
[p_constants.TYPE_LOCAL, p_constants.TYPE_FLAT,
p_constants.TYPE_VLAN])
[constants.TYPE_LOCAL, constants.TYPE_FLAT,
constants.TYPE_VLAN])
def get_mappings(self, agent):
mappings = dict(agent['configurations'].get('interface_mappings', {}),

3
neutron/plugins/ml2/drivers/macvtap/agent/macvtap_neutron_agent.py

@ -29,7 +29,6 @@ from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc
from neutron.common import config as common_config
from neutron.common import topics
from neutron.conf.plugins.ml2.drivers import macvtap as config
from neutron.plugins.common import constants as p_constants
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.plugins.ml2.drivers.macvtap import macvtap_common
@ -61,7 +60,7 @@ class MacvtapRPCCallBack(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
return
segment = self.network_map.get(network_id)
if segment and segment.network_type == p_constants.TYPE_VLAN:
if segment and segment.network_type == constants.TYPE_VLAN:
if_mappings = self.agent.mgr.interface_mappings
vlan_device_name = macvtap_common.get_vlan_device_name(
if_mappings[segment.physical_network],

5
neutron/plugins/ml2/drivers/macvtap/mech_driver/mech_macvtap.py

@ -19,7 +19,6 @@ from neutron_lib import constants
from neutron_lib.plugins.ml2 import api
from oslo_log import log
from neutron.plugins.common import constants as p_constants
from neutron.plugins.ml2.drivers.macvtap import macvtap_common
from neutron.plugins.ml2.drivers import mech_agent
@ -45,7 +44,7 @@ class MacvtapMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
{portbindings.CAP_PORT_FILTER: False})
def get_allowed_network_types(self, agent):
return [p_constants.TYPE_FLAT, p_constants.TYPE_VLAN]
return [constants.TYPE_FLAT, constants.TYPE_VLAN]
def get_mappings(self, agent):
return agent['configurations'].get('interface_mappings', {})
@ -80,7 +79,7 @@ class MacvtapMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
interface = mappings[segment['physical_network']]
network_type = segment[api.NETWORK_TYPE]
if network_type == p_constants.TYPE_VLAN:
if network_type == constants.TYPE_VLAN:
vlan_id = segment[api.SEGMENTATION_ID]
macvtap_src = macvtap_common.get_vlan_device_name(interface,
vlan_id)

3
neutron/plugins/ml2/drivers/mech_agent.py

@ -23,7 +23,6 @@ from oslo_log import log
import six
from neutron.db import provisioning_blocks
from neutron.plugins.common import constants as p_constants
LOG = log.getLogger(__name__)
@ -249,7 +248,7 @@ class SimpleAgentMechanismDriverBase(AgentMechanismDriverBase):
'allowed_network_types': allowed_network_types})
return False
if network_type in [p_constants.TYPE_FLAT, p_constants.TYPE_VLAN]:
if network_type in [const.TYPE_FLAT, const.TYPE_VLAN]:
physnet = segment[api.PHYSICAL_NETWORK]
if not self.physnet_in_mappings(physnet, mappings):
LOG.debug(

7
neutron/plugins/ml2/drivers/mech_sriov/mech_driver/mech_driver.py

@ -18,7 +18,6 @@ from neutron_lib import constants
from neutron_lib.plugins.ml2 import api
from oslo_log import log
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import mech_agent
from neutron.plugins.ml2.drivers.mech_sriov.mech_driver \
import exceptions as exc
@ -66,7 +65,7 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
sriov_qos_driver.register()
def get_allowed_network_types(self, agent):
return (p_const.TYPE_FLAT, p_const.TYPE_VLAN)
return (constants.TYPE_FLAT, constants.TYPE_VLAN)
def get_mappings(self, agent):
return agent['configurations'].get('device_mappings', {})
@ -157,9 +156,9 @@ class SriovNicSwitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def _get_vif_details(self, segment):
network_type = segment[api.NETWORK_TYPE]
if network_type == p_const.TYPE_FLAT:
if network_type == constants.TYPE_FLAT:
vlan_id = FLAT_VLAN
elif network_type == p_const.TYPE_VLAN:
elif network_type == constants.TYPE_VLAN:
vlan_id = segment[api.SEGMENTATION_ID]
else:
raise exc.SriovUnsupportedNetworkType(net_type=network_type)

2
neutron/plugins/ml2/drivers/openvswitch/agent/common/constants.py

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from neutron.plugins.common import constants as p_const
from neutron_lib import constants as p_const
# Special vlan_id value in ovs_vlan_allocations table indicating flat network

2
neutron/plugins/ml2/drivers/openvswitch/agent/openflow/native/br_int.py

@ -21,12 +21,12 @@
import netaddr
from neutron_lib import constants as p_const
from oslo_log import log as logging
from ryu.lib.packet import ether_types
from ryu.lib.packet import icmpv6
from ryu.lib.packet import in_proto
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.native \
import ovs_bridge

3
neutron/plugins/ml2/drivers/openvswitch/agent/openflow/ovs_ofctl/br_int.py

@ -24,7 +24,6 @@ import netaddr
from neutron_lib import constants as const
from neutron.common import constants as n_const
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl \
import ovs_bridge
@ -71,7 +70,7 @@ class OVSIntegrationBridge(ovs_bridge.OVSAgentBridge):
@staticmethod
def _dvr_to_src_mac_table_id(network_type):
if network_type == p_const.TYPE_VLAN:
if network_type == const.TYPE_VLAN:
return constants.DVR_TO_SRC_MAC_VLAN
else:
return constants.DVR_TO_SRC_MAC

21
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_dvr_neutron_agent.py

@ -24,7 +24,6 @@ from osprofiler import profiler
from neutron.agent.common import ovs_lib
from neutron.common import utils as n_utils
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
LOG = logging.getLogger(__name__)
@ -374,7 +373,7 @@ class OVSDVRNeutronAgent(object):
ldm.set_dvr_owned(True)
vlan_to_use = lvm.vlan
if lvm.network_type == p_const.TYPE_VLAN:
if lvm.network_type == n_const.TYPE_VLAN:
vlan_to_use = lvm.segmentation_id
subnet_info = ldm.get_subnet_info()
@ -413,7 +412,7 @@ class OVSDVRNeutronAgent(object):
dst_mac=comp_ovsport.get_mac(),
dst_port=comp_ovsport.get_ofport())
if lvm.network_type == p_const.TYPE_VLAN:
if lvm.network_type == n_const.TYPE_VLAN:
# TODO(vivek) remove the IPv6 related flows once SNAT is not
# used for IPv6 DVR.
br = self.phys_brs[lvm.physical_network]
@ -474,7 +473,7 @@ class OVSDVRNeutronAgent(object):
ovsport.add_subnet(subnet_uuid)
self.local_ports[port.vif_id] = ovsport
vlan_to_use = lvm.vlan
if lvm.network_type == p_const.TYPE_VLAN:
if lvm.network_type == n_const.TYPE_VLAN:
vlan_to_use = lvm.segmentation_id
# create a rule for this vm port
self.int_br.install_dvr_to_src_mac(
@ -534,7 +533,7 @@ class OVSDVRNeutronAgent(object):
ovsport.add_subnet(subnet_uuid)
self.local_ports[port.vif_id] = ovsport
vlan_to_use = lvm.vlan
if lvm.network_type == p_const.TYPE_VLAN:
if lvm.network_type == n_const.TYPE_VLAN:
vlan_to_use = lvm.segmentation_id
self.int_br.install_dvr_to_src_mac(
network_type=lvm.network_type,
@ -549,7 +548,7 @@ class OVSDVRNeutronAgent(object):
return
if local_vlan_map.network_type not in (constants.TUNNEL_NETWORK_TYPES
+ [p_const.TYPE_VLAN]):
+ [n_const.TYPE_VLAN]):
LOG.debug("DVR: Port %s is with network_type %s not supported"
" for dvr plumbing", port.vif_id,
local_vlan_map.network_type)
@ -586,7 +585,7 @@ class OVSDVRNeutronAgent(object):
network_type = lvm.network_type
physical_network = lvm.physical_network
vlan_to_use = lvm.vlan
if network_type == p_const.TYPE_VLAN:
if network_type == n_const.TYPE_VLAN:
vlan_to_use = lvm.segmentation_id
# ensure we process for all the subnets laid on this removed port
for sub_uuid in subnet_set:
@ -612,7 +611,7 @@ class OVSDVRNeutronAgent(object):
# this subnet from local_dvr_map, as no dvr (or) csnat
# ports available on this agent anymore
self.local_dvr_map.pop(sub_uuid, None)
if network_type == p_const.TYPE_VLAN:
if network_type == n_const.TYPE_VLAN:
br = self.phys_brs[physical_network]
if network_type in constants.TUNNEL_NETWORK_TYPES:
br = self.tun_br
@ -624,7 +623,7 @@ class OVSDVRNeutronAgent(object):
vlan_tag=lvm.vlan, gateway_mac=subnet_info['gateway_mac'])
ovsport.remove_subnet(sub_uuid)
if lvm.network_type == p_const.TYPE_VLAN:
if lvm.network_type == n_const.TYPE_VLAN:
br = self.phys_brs[physical_network]
if lvm.network_type in constants.TUNNEL_NETWORK_TYPES:
br = self.tun_br
@ -646,7 +645,7 @@ class OVSDVRNeutronAgent(object):
ldm = self.local_dvr_map[sub_uuid]
ldm.remove_compute_ofport(port.vif_id)
vlan_to_use = lvm.vlan
if lvm.network_type == p_const.TYPE_VLAN:
if lvm.network_type == n_const.TYPE_VLAN:
vlan_to_use = lvm.segmentation_id
# first remove this vm port rule
self.int_br.delete_dvr_to_src_mac(
@ -667,7 +666,7 @@ class OVSDVRNeutronAgent(object):
ldm = self.local_dvr_map[sub_uuid]
ldm.set_csnat_ofport(constants.OFPORT_INVALID)
vlan_to_use = lvm.vlan
if lvm.network_type == p_const.TYPE_VLAN:
if lvm.network_type == n_const.TYPE_VLAN:
vlan_to_use = lvm.segmentation_id
# then remove csnat port rule
self.int_br.delete_dvr_to_src_mac(

23
neutron/plugins/ml2/drivers/openvswitch/agent/ovs_neutron_agent.py

@ -55,7 +55,6 @@ 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
from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as p_utils
from neutron.plugins.ml2.drivers.agent import capabilities
from neutron.plugins.ml2.drivers.l2pop.rpc_manager import l2population_rpc
@ -148,8 +147,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
self.use_veth_interconnection = ovs_conf.use_veth_interconnection
self.veth_mtu = agent_conf.veth_mtu
self.available_local_vlans = set(moves.range(p_const.MIN_VLAN_TAG,
p_const.MAX_VLAN_TAG + 1))
self.available_local_vlans = set(moves.range(n_const.MIN_VLAN_TAG,
n_const.MAX_VLAN_TAG + 1))
self.tunnel_types = agent_conf.tunnel_types or []
self.l2_pop = agent_conf.l2_population
# TODO(ethuleau): Change ARP responder so it's not dependent on the
@ -359,9 +358,9 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
self._local_vlan_hints = {}
def _reset_tunnel_ofports(self):
self.tun_br_ofports = {p_const.TYPE_GENEVE: {},
p_const.TYPE_GRE: {},
p_const.TYPE_VXLAN: {}}
self.tun_br_ofports = {n_const.TYPE_GENEVE: {},
n_const.TYPE_GRE: {},
n_const.TYPE_VXLAN: {}}
def setup_rpc(self):
self.plugin_rpc = OVSPluginApi(topics.PLUGIN)
@ -676,7 +675,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
"net-id=%(net_uuid)s - tunneling disabled",
{'network_type': network_type,
'net_uuid': net_uuid})
elif network_type == p_const.TYPE_FLAT:
elif network_type == n_const.TYPE_FLAT:
if physical_network in self.phys_brs:
self._local_vlan_for_flat(lvid, physical_network)
else:
@ -685,7 +684,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
"physical_network %(physical_network)s",
{'net_uuid': net_uuid,
'physical_network': physical_network})
elif network_type == p_const.TYPE_VLAN:
elif network_type == n_const.TYPE_VLAN:
if physical_network in self.phys_brs:
self._local_vlan_for_vlan(lvid, physical_network,
segmentation_id)
@ -695,7 +694,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
"physical_network %(physical_network)s",
{'net_uuid': net_uuid,
'physical_network': physical_network})
elif network_type == p_const.TYPE_LOCAL:
elif network_type == n_const.TYPE_LOCAL:
# no flows needed for local networks
pass
else:
@ -732,7 +731,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
for ofport in lvm.tun_ofports:
self.cleanup_tunnel_port(self.tun_br, ofport,
lvm.network_type)
elif lvm.network_type == p_const.TYPE_FLAT:
elif lvm.network_type == n_const.TYPE_FLAT:
if lvm.physical_network in self.phys_brs:
# outbound
br = self.phys_brs[lvm.physical_network]
@ -744,7 +743,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
br.reclaim_local_vlan(
port=self.int_ofports[lvm.physical_network],
segmentation_id=None)
elif lvm.network_type == p_const.TYPE_VLAN:
elif lvm.network_type == n_const.TYPE_VLAN:
if lvm.physical_network in self.phys_brs:
# outbound
br = self.phys_brs[lvm.physical_network]
@ -756,7 +755,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
br.reclaim_local_vlan(
port=self.int_ofports[lvm.physical_network],
segmentation_id=lvm.segmentation_id)
elif lvm.network_type == p_const.TYPE_LOCAL:
elif lvm.network_type == n_const.TYPE_LOCAL:
# no flows needed for local networks
pass
else:

5
neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py

@ -23,7 +23,6 @@ from oslo_config import cfg
from oslo_log import log
from neutron.agent import securitygroups_rpc
from neutron.plugins.common import constants as p_constants
from neutron.plugins.ml2.drivers import mech_agent
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
import constants as a_const
@ -66,8 +65,8 @@ class OpenvswitchMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
def get_allowed_network_types(self, agent):
return (agent['configurations'].get('tunnel_types', []) +
[p_constants.TYPE_LOCAL, p_constants.TYPE_FLAT,
p_constants.TYPE_VLAN])
[constants.TYPE_LOCAL, constants.TYPE_FLAT,
constants.TYPE_VLAN])
def get_mappings(self, agent):
return agent['configurations'].get('bridge_mappings', {})

2
neutron/plugins/ml2/drivers/type_flat.py

@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants as p_const
from neutron_lib import exceptions as exc
from neutron_lib.objects import exceptions as obj_base
from neutron_lib.plugins.ml2 import api
@ -24,7 +25,6 @@ from neutron.common import exceptions as n_exc
from neutron.conf.plugins.ml2.drivers import driver_type
from neutron.db import api as db_api
from neutron.objects.plugins.ml2 import flatallocation as flat_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import helpers
LOG = log.getLogger(__name__)

2
neutron/plugins/ml2/drivers/type_geneve.py

@ -14,13 +14,13 @@
# under the License.
from neutron_lib import constants as p_const
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
from oslo_log import log
from neutron.conf.plugins.ml2.drivers import driver_type
from neutron.objects.plugins.ml2 import geneveallocation as geneve_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import type_tunnel
LOG = log.getLogger(__name__)

2
neutron/plugins/ml2/drivers/type_gre.py

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants as p_const
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
from oslo_log import log
from neutron.conf.plugins.ml2.drivers import driver_type
from neutron.objects.plugins.ml2 import greallocation as gre_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import type_tunnel
LOG = log.getLogger(__name__)

2
neutron/plugins/ml2/drivers/type_local.py

@ -13,12 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants as p_const
from neutron_lib import exceptions as exc
from neutron_lib.plugins.ml2 import api
from oslo_log import log
from neutron._i18n import _
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2 import driver_api
LOG = log.getLogger(__name__)

2
neutron/plugins/ml2/drivers/type_tunnel.py

@ -17,6 +17,7 @@ import itertools
import operator
import netaddr
from neutron_lib import constants as p_const
from neutron_lib import context
from neutron_lib import exceptions as exc
from neutron_lib.plugins.ml2 import api
@ -31,7 +32,6 @@ from neutron._i18n import _
from neutron.common import topics
from neutron.db import api as db_api
from neutron.objects import base as base_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as plugin_utils
from neutron.plugins.ml2.drivers import helpers

2
neutron/plugins/ml2/drivers/type_vlan.py

@ -15,6 +15,7 @@
import sys
from neutron_lib import constants as p_const
from neutron_lib import context
from neutron_lib import exceptions as exc
from neutron_lib.plugins.ml2 import api
@ -26,7 +27,6 @@ from neutron._i18n import _
from neutron.conf.plugins.ml2.drivers import driver_type
from neutron.db import api as db_api
from neutron.objects.plugins.ml2 import vlanallocation as vlanalloc
from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as plugin_utils
from neutron.plugins.ml2.drivers import helpers

2
neutron/plugins/ml2/drivers/type_vxlan.py

@ -13,13 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import constants as p_const
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
from oslo_log import log
from neutron.conf.plugins.ml2.drivers import driver_type
from neutron.objects.plugins.ml2 import vxlanallocation as vxlan_obj
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers import type_tunnel
LOG = log.getLogger(__name__)

2
neutron/services/flavors/flavors_plugin.py

@ -13,10 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib.plugins import constants
from neutron_lib.services import base as service_base
from neutron.db import flavors_db
from neutron.plugins.common import constants
class FlavorsPlugin(service_base.ServicePluginBase,

4
neutron/services/l3_router/service_providers/driver_controller.py

@ -24,7 +24,6 @@ from oslo_log import log as logging
from neutron._i18n import _
from neutron.db import servicetype_db as st_db
from neutron.plugins.common import constants
from neutron.services import provider_configuration
from neutron.services import service_base
@ -60,7 +59,8 @@ class DriverController(object):
@property
def _flavor_plugin(self):
if not hasattr(self, '_flavor_plugin_ref'):
self._flavor_plugin_ref = directory.get_plugin(constants.FLAVORS)
self._flavor_plugin_ref = directory.get_plugin(
plugin_constants.FLAVORS)
return self._flavor_plugin_ref
@registry.receives(resources.ROUTER, [events.BEFORE_CREATE])

3
neutron/tests/functional/agent/l2/base.py

@ -31,7 +31,6 @@ from neutron.common import utils
from neutron.conf.agent import common as agent_config
from neutron.conf import common as common_config
from neutron.conf.plugins.ml2.drivers import ovs_conf
from neutron.plugins.common import constants as p_const
from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants
from neutron.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl \
import br_int
@ -100,7 +99,7 @@ class OVSAgentTestFramework(base.BaseOVSLinuxTestCase):
def create_agent(self, create_tunnels=True, ancillary_bridge=None,
local_ip='192.168.10.1'):
if create_tunnels:
tunnel_types = [p_const.TYPE_VXLAN]
tunnel_types = [n_const.TYPE_VXLAN]
else:
tunnel_types = None
bridge_mappings = ['physnet:%s' % self.br_phys]

4
neutron/tests/functional/pecan_wsgi/test_controllers.py

@ -32,6 +32,8 @@ from neutron import policy
from neutron.tests.common import helpers
from neutron.tests.functional.pecan_wsgi import test_functional
from neutron.tests.functional.pecan_wsgi import utils as pecan_utils
from neutron.tests.unit import dummy_plugin
_SERVICE_PLUGIN_RESOURCE = 'serviceplugin'
_SERVICE_PLUGIN_COLLECTION = _SERVICE_PLUGIN_RESOURCE + 's'
@ -787,7 +789,7 @@ class TestRequestProcessing(TestRootController):
def test_service_plugin_uri(self):
nm = manager.NeutronManager.get_instance()
nm.path_prefix_resource_mappings['dummy'] = [
nm.path_prefix_resource_mappings[dummy_plugin.RESOURCE_NAME] = [
_SERVICE_PLUGIN_COLLECTION]
response = self.do_request('/v2.0/dummy/serviceplugins.json')
self.assertEqual(200, response.status_int)

3
neutron/tests/tools.py

@ -33,7 +33,6 @@ import unittest2
from neutron.api.v2 import attributes
from neutron.common import constants as n_const
from neutron.plugins.common import constants as p_const
from neutron.services.logapi.common import constants as log_const
@ -231,7 +230,7 @@ def get_random_port(start=n_const.PORT_RANGE_MIN):
def get_random_vlan():
return random.randint(p_const.MIN_VLAN_TAG, p_const.MAX_VLAN_TAG)
return random.randint(constants.MIN_VLAN_TAG, constants.MAX_VLAN_TAG)
def get_random_ip_version():

7
neutron/tests/unit/_test_extension_portbindings.py

@ -21,6 +21,7 @@ from six.moves import http_client as httplib
from webob import exc
from neutron.tests.unit.db import test_db_base_plugin_v2
from neutron.tests.unit import dummy_plugin
class PortBindingsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
@ -129,7 +130,8 @@ class PortBindingsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
self._test_update_port_binding_profile({})
def test_port_create_portinfo_non_admin(self):
profile_arg = {portbindings.PROFILE: {'dummy': 'dummy'}}
profile_arg = {portbindings.PROFILE: {dummy_plugin.RESOURCE_NAME:
dummy_plugin.RESOURCE_NAME}}
with self.network(set_context=True, tenant_id='test') as net1:
with self.subnet(network=net1) as subnet1:
# succeed without binding:profile
@ -148,7 +150,8 @@ class PortBindingsTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
pass
def test_port_update_portinfo_non_admin(self):
profile_arg = {portbindings.PROFILE: {'dummy': 'dummy'}}
profile_arg = {portbindings.PROFILE: {dummy_plugin.RESOURCE_NAME:
dummy_plugin.RESOURCE_NAME}}
with self.network() as net1:
with self.subnet(network=net1) as subnet1:
with self.port(subnet=subnet1) as port:

2
neutron/tests/unit/agent/common/test_ovs_lib.py

@ -15,6 +15,7 @@
import collections
import mock
from neutron_lib import constants
from neutron_lib import exceptions
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
@ -24,7 +25,6 @@ import testtools
from neutron.agent.common import ovs_lib
from neutron.agent.common import utils
from neutron.conf.agent import common as config
from neutron.plugins.common import constants
from neutron.plugins.ml2.drivers.openvswitch.agent.common \
import constants as p_const
from neutron.tests import base

7
neutron/tests/unit/api/test_extensions.py

@ -39,6 +39,7 @@ from neutron.plugins.common import constants
from neutron import quota
from neutron.tests import base
from neutron.tests.unit.api.v2 import test_base
from neutron.tests.unit import dummy_plugin
from neutron.tests.unit import extension_stubs as ext_stubs
import neutron.tests.unit.extensions
from neutron.tests.unit.extensions import extendedattribute as extattr
@ -160,7 +161,7 @@ class ResourceExtensionTest(base.BaseTestCase):
class DummySvcPlugin(wsgi.Controller):
@classmethod
def get_plugin_type(cls):
return constants.DUMMY
return dummy_plugin.DUMMY_SERVICE_TYPE
def index(self, request, **kwargs):
return "resource index"
@ -209,7 +210,7 @@ class ResourceExtensionTest(base.BaseTestCase):
@classmethod
def get_plugin_type(cls):
return constants.DUMMY
return dummy_plugin.DUMMY_SERVICE_TYPE
res_ext = extensions.ResourceExtension(
'tweedles', DummySvcPlugin(), path_prefix="/dummy_svc")
@ -781,7 +782,7 @@ class PluginAwareExtensionManagerTest(base.BaseTestCase):
return None
stub_plugin = ext_stubs.StubPlugin(supported_extensions=["e1"])
plugin_info = {constants.DUMMY: stub_plugin}
plugin_info = {dummy_plugin.DUMMY_SERVICE_TYPE: stub_plugin}
with mock.patch("neutron.api.extensions.PluginAwareExtensionManager."
"check_if_plugin_extensions_loaded"):
ext_mgr = extensions.PluginAwareExtensionManager('', plugin_info)

22
neutron/tests/unit/api/v2/test_base.py

@ -43,6 +43,7 @@ from neutron.quota import resource_registry
from neutron.tests import base
from neutron.tests import fake_notifier
from neutron.tests import tools
from neutron.tests.unit import dummy_plugin
from neutron.tests.unit import testlib_api
@ -1134,7 +1135,7 @@ class SubresourceTest(base.BaseTestCase):
SUB_RESOURCES = {}
RESOURCE_ATTRIBUTE_MAP = {}
SUB_RESOURCES['dummy'] = {
SUB_RESOURCES[dummy_plugin.RESOURCE_NAME] = {
'collection_name': 'dummies',
'parent': {'collection_name': 'networks',
'member_name': 'network'}
@ -1148,9 +1149,10 @@ class SubresourceTest(base.BaseTestCase):
'required_by_policy': True,
'is_visible': True}
}
collection_name = SUB_RESOURCES['dummy'].get('collection_name')
resource_name = 'dummy'
parent = SUB_RESOURCES['dummy'].get('parent')
collection_name = SUB_RESOURCES[
dummy_plugin.RESOURCE_NAME].get('collection_name')
resource_name = dummy_plugin.RESOURCE_NAME
parent = SUB_RESOURCES[dummy_plugin.RESOURCE_NAME].get('parent')
params = RESOURCE_ATTRIBUTE_MAP['dummies']
member_actions = {'mactions': 'GET'}
_plugin = directory.get_plugin()
@ -1197,8 +1199,12 @@ class SubresourceTest(base.BaseTestCase):
instance = self.plugin.return_value
tenant_id = _uuid()
body = {'dummy': {'foo': 'bar', 'tenant_id': tenant_id,
'project_id': tenant_id}}
body = {
dummy_plugin.RESOURCE_NAME: {
'foo': 'bar', 'tenant_id': tenant_id,
'project_id': tenant_id
}
}
self.api.post_json('/networks/id1/dummies', body)
instance.create_network_dummy.assert_called_once_with(mock.ANY,
network_id='id1',
@ -1208,7 +1214,7 @@ class SubresourceTest(base.BaseTestCase):
instance = self.plugin.return_value
dummy_id = _uuid()
body = {'dummy': {'foo': 'bar'}}
body = {dummy_plugin.RESOURCE_NAME: {'foo': 'bar'}}
self.api.put_json('/networks/id1' + _get_path('dummies', id=dummy_id),
body)
instance.update_network_dummy.assert_called_once_with(mock.ANY,
@ -1220,7 +1226,7 @@ class SubresourceTest(base.BaseTestCase):
instance = self.plugin.return_value
dummy_id = _uuid()
body = {'dummy': {}}
body = {dummy_plugin.RESOURCE_NAME: {}}
self.api.put_json('/networks/id1' + _get_path('dummies', id=dummy_id),
body)
instance.update_network_dummy.assert_called_once_with(mock.ANY,

13
neutron/tests/unit/common/test_utils.py

@ -30,7 +30,6 @@ import testtools
from neutron.common import exceptions as n_exc
from neutron.common import utils
from neutron.plugins.common import constants as p_const
from neutron.plugins.common import utils as plugin_utils
from neutron.tests import base
from neutron.tests.unit import tests
@ -145,16 +144,16 @@ class TestParseTunnelRangesMixin(object):
<