Merge "use neutron-lib constants rather than plugin constants"
This commit is contained in:
commit
6e6f82acbb
@ -15,10 +15,10 @@
|
||||
# under the License.
|
||||
|
||||
import neutron.db.api as db
|
||||
from neutron.plugins.common import constants as neutron_const
|
||||
|
||||
import decorator
|
||||
from neutron_lib.api.definitions import portbindings as pbin
|
||||
from neutron_lib import constants as lib_const
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
@ -69,7 +69,7 @@ def warn_on_binding_status_error(f, *args, **kwargs):
|
||||
bindings = [result]
|
||||
|
||||
for binding in bindings:
|
||||
if binding and binding['status'] == neutron_const.ERROR:
|
||||
if binding and binding['status'] == lib_const.ERROR:
|
||||
LOG.warning("Found NSXV router binding entry with status "
|
||||
"%(status)s: router %(router)s, "
|
||||
"edge %(edge)s, lswitch %(lswitch)s, "
|
||||
|
@ -40,12 +40,12 @@ from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.extensions import vlantransparent as vlan_ext
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.plugins.common import utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron_lib.api.definitions import portbindings as pbin
|
||||
from neutron_lib.api.definitions import provider_net as pnet
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
|
||||
import vmware_nsx
|
||||
|
@ -63,7 +63,6 @@ from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.plugins.common import utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron_lib.api.definitions import portbindings as pbin
|
||||
@ -811,8 +810,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
err_msg = (_("%(segmentation_id)s out of range "
|
||||
"(%(min_id)s through %(max_id)s)") %
|
||||
{'segmentation_id': segmentation_id,
|
||||
'min_id': plugin_const.MIN_VLAN_TAG,
|
||||
'max_id': plugin_const.MAX_VLAN_TAG})
|
||||
'min_id': constants.MIN_VLAN_TAG,
|
||||
'max_id': constants.MAX_VLAN_TAG})
|
||||
else:
|
||||
# Verify segment is not already allocated
|
||||
bindings = (
|
||||
@ -830,8 +829,8 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
err_msg = (_("%(segmentation_id)s out of range "
|
||||
"(%(min_id)s through %(max_id)s)") %
|
||||
{'segmentation_id': segmentation_id,
|
||||
'min_id': plugin_const.MIN_VLAN_TAG,
|
||||
'max_id': plugin_const.MAX_VLAN_TAG})
|
||||
'min_id': constants.MIN_VLAN_TAG,
|
||||
'max_id': constants.MAX_VLAN_TAG})
|
||||
# Network must be external
|
||||
if not network.get(ext_net_extn.EXTERNAL):
|
||||
err_msg = (_("The l3_ext provide network type can be "
|
||||
@ -1435,7 +1434,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
raise nsx_exc.NsxPluginException(
|
||||
err_msg=(_("Unable to create router %s on NSX backend") %
|
||||
router['id']))
|
||||
lrouter['status'] = plugin_const.ACTIVE
|
||||
lrouter['status'] = constants.ACTIVE
|
||||
return lrouter
|
||||
|
||||
def _process_extra_attr_router_create(self, context, router_db, r):
|
||||
|
@ -14,8 +14,8 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from neutron.plugins.common import constants
|
||||
from neutron_lib import constants as n_consts
|
||||
from neutron_lib.plugins import constants as plugin_const
|
||||
|
||||
from vmware_nsx._i18n import _
|
||||
from vmware_nsx.common import exceptions as nsxv_exc
|
||||
@ -271,8 +271,8 @@ class RouterExclusiveDriver(router_driver.RouterBaseDriver):
|
||||
|
||||
def _check_lb_on_subnet(self, context, subnet_id):
|
||||
# Check lbaas
|
||||
dev_owner_v1 = 'neutron:' + constants.LOADBALANCER
|
||||
dev_owner_v2 = 'neutron:' + constants.LOADBALANCERV2
|
||||
dev_owner_v1 = 'neutron:' + plugin_const.LOADBALANCER
|
||||
dev_owner_v2 = 'neutron:' + plugin_const.LOADBALANCERV2
|
||||
filters = {'device_owner': [dev_owner_v1, dev_owner_v2],
|
||||
'fixed_ips': {'subnet_id': [subnet_id]}}
|
||||
ports = super(nsx_v.NsxVPluginV2, self.plugin).get_ports(
|
||||
|
@ -24,6 +24,7 @@ from neutron_lib import constants
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib.db import constants as db_const
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import constants as plugin_const
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
@ -73,7 +74,6 @@ from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.extensions import vlantransparent as ext_vlan
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.plugins.common import utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron.services.flavors import flavors_plugin
|
||||
@ -633,8 +633,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
err_msg = (_("%(segmentation_id)s out of range "
|
||||
"(%(min_id)s through %(max_id)s)") %
|
||||
{'segmentation_id': segmentation_id,
|
||||
'min_id': plugin_const.MIN_VLAN_TAG,
|
||||
'max_id': plugin_const.MAX_VLAN_TAG})
|
||||
'min_id': constants.MIN_VLAN_TAG,
|
||||
'max_id': constants.MAX_VLAN_TAG})
|
||||
else:
|
||||
# Verify segment is not already allocated
|
||||
bindings = nsxv_db.get_network_bindings_by_vlanid(
|
||||
|
@ -16,7 +16,7 @@ from distutils import version
|
||||
import random
|
||||
import time
|
||||
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron_lib import constants as lib_const
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
@ -421,7 +421,7 @@ class EdgeApplianceDriver(object):
|
||||
if router_id:
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_id,
|
||||
status=plugin_const.ERROR)
|
||||
status=lib_const.ERROR)
|
||||
error = _('Failed to deploy edge')
|
||||
raise nsxv_exc.NsxPluginException(err_msg=error)
|
||||
|
||||
|
@ -34,9 +34,9 @@ from six import moves
|
||||
|
||||
from neutron.extensions import extra_dhcp_opt as ext_edo
|
||||
from neutron.extensions import l3
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
|
||||
from vmware_nsx._i18n import _
|
||||
@ -234,7 +234,7 @@ class EdgeManager(object):
|
||||
error_reason="backend error"):
|
||||
for binding in nsxv_db.get_nsxv_router_bindings_by_edge(
|
||||
context.session, edge_id):
|
||||
if binding['status'] == plugin_const.ERROR:
|
||||
if binding['status'] == constants.ERROR:
|
||||
continue
|
||||
LOG.error('Mark router binding ERROR for resource '
|
||||
'%(res_id)s on edge %(edge_id)s due to '
|
||||
@ -244,7 +244,7 @@ class EdgeManager(object):
|
||||
'reason': error_reason})
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, binding['router_id'],
|
||||
status=plugin_const.ERROR)
|
||||
status=constants.ERROR)
|
||||
|
||||
def _deploy_edge(self, context, lrouter,
|
||||
lswitch=None, appliance_size=nsxv_constants.COMPACT,
|
||||
@ -272,7 +272,7 @@ class EdgeManager(object):
|
||||
for router_id in router_ids:
|
||||
nsxv_db.add_nsxv_router_binding(
|
||||
context.session, router_id, None, None,
|
||||
plugin_const.PENDING_CREATE,
|
||||
constants.PENDING_CREATE,
|
||||
appliance_size=appliance_size, edge_type=edge_type,
|
||||
availability_zone=availability_zone.name)
|
||||
return router_ids
|
||||
@ -297,14 +297,14 @@ class EdgeManager(object):
|
||||
availability_zone=availability_zone)
|
||||
|
||||
def _delete_edge(self, context, router_binding):
|
||||
if router_binding['status'] == plugin_const.ERROR:
|
||||
if router_binding['status'] == constants.ERROR:
|
||||
LOG.warning("Start deleting %(router_id)s corresponding "
|
||||
"edge: %(edge_id)s due to status error",
|
||||
{'router_id': router_binding['router_id'],
|
||||
'edge_id': router_binding['edge_id']})
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_binding['router_id'],
|
||||
status=plugin_const.PENDING_DELETE)
|
||||
status=constants.PENDING_DELETE)
|
||||
self._get_worker_pool().spawn_n(
|
||||
self.nsxv_manager.delete_edge, q_context.get_admin_context(),
|
||||
router_binding['router_id'], router_binding['edge_id'],
|
||||
@ -314,7 +314,7 @@ class EdgeManager(object):
|
||||
for binding in backup_router_bindings:
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, binding['router_id'],
|
||||
status=plugin_const.PENDING_DELETE)
|
||||
status=constants.PENDING_DELETE)
|
||||
|
||||
def _delete_backup_edges_at_backend(self, context, backup_router_bindings):
|
||||
for binding in backup_router_bindings:
|
||||
@ -329,13 +329,13 @@ class EdgeManager(object):
|
||||
def _clean_all_error_edge_bindings(self, context, availability_zone):
|
||||
# Find all backup edges in error state &
|
||||
# backup edges which are in pending-create state for too long
|
||||
filters = {'status': [plugin_const.ERROR, plugin_const.PENDING_CREATE],
|
||||
filters = {'status': [constants.ERROR, constants.PENDING_CREATE],
|
||||
'availability_zone': [availability_zone.name]}
|
||||
like_filters = {'router_id': vcns_const.BACKUP_ROUTER_PREFIX + "%"}
|
||||
router_bindings = nsxv_db.get_nsxv_router_bindings(
|
||||
context.session, filters=filters, like_filters=like_filters)
|
||||
error_router_bindings = [binding for binding in router_bindings if
|
||||
binding.status == plugin_const.ERROR or
|
||||
binding.status == constants.ERROR or
|
||||
timeutils.is_older_than(binding.created_at, 600)]
|
||||
self._delete_backup_edges_on_db(context,
|
||||
error_router_bindings)
|
||||
@ -350,9 +350,9 @@ class EdgeManager(object):
|
||||
filters = {'appliance_size': [appliance_size],
|
||||
'edge_type': [edge_type],
|
||||
'availability_zone': [availability_zone.name],
|
||||
'status': [plugin_const.PENDING_CREATE,
|
||||
plugin_const.PENDING_UPDATE,
|
||||
plugin_const.ACTIVE]}
|
||||
'status': [constants.PENDING_CREATE,
|
||||
constants.PENDING_UPDATE,
|
||||
constants.ACTIVE]}
|
||||
like_filters = {'router_id': vcns_const.BACKUP_ROUTER_PREFIX + "%"}
|
||||
return nsxv_db.get_nsxv_router_bindings(
|
||||
context.session, filters=filters, like_filters=like_filters)
|
||||
@ -434,7 +434,7 @@ class EdgeManager(object):
|
||||
availability_zone=availability_zone)
|
||||
while backup_router_bindings:
|
||||
router_binding = random.choice(backup_router_bindings)
|
||||
if (router_binding['status'] == plugin_const.ACTIVE):
|
||||
if (router_binding['status'] == constants.ACTIVE):
|
||||
if not self.check_edge_active_at_backend(
|
||||
router_binding['edge_id']):
|
||||
LOG.debug("Delete unavailable backup resource "
|
||||
@ -664,7 +664,7 @@ class EdgeManager(object):
|
||||
if edge_pool_range is None:
|
||||
nsxv_db.add_nsxv_router_binding(
|
||||
context.session, resource_id, None, None,
|
||||
plugin_const.PENDING_CREATE,
|
||||
constants.PENDING_CREATE,
|
||||
appliance_size=appliance_size,
|
||||
edge_type=edge_type,
|
||||
availability_zone=availability_zone.name)
|
||||
@ -684,13 +684,13 @@ class EdgeManager(object):
|
||||
# in case of other threads select the same router binding
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, available_router_binding['router_id'],
|
||||
status=plugin_const.PENDING_UPDATE)
|
||||
status=constants.PENDING_UPDATE)
|
||||
# Synchronously deploy an edge if no available edge in pool.
|
||||
if not available_router_binding:
|
||||
# store router-edge mapping binding
|
||||
nsxv_db.add_nsxv_router_binding(
|
||||
context.session, resource_id, None, None,
|
||||
plugin_const.PENDING_CREATE,
|
||||
constants.PENDING_CREATE,
|
||||
appliance_size=appliance_size,
|
||||
edge_type=edge_type,
|
||||
availability_zone=availability_zone.name)
|
||||
@ -711,7 +711,7 @@ class EdgeManager(object):
|
||||
lrouter['id'],
|
||||
available_router_binding['edge_id'],
|
||||
None,
|
||||
plugin_const.PENDING_CREATE,
|
||||
constants.PENDING_CREATE,
|
||||
appliance_size=appliance_size,
|
||||
edge_type=edge_type,
|
||||
availability_zone=availability_zone.name)
|
||||
@ -769,18 +769,18 @@ class EdgeManager(object):
|
||||
backup_router_id,
|
||||
edge_id,
|
||||
None,
|
||||
plugin_const.PENDING_UPDATE,
|
||||
constants.PENDING_UPDATE,
|
||||
appliance_size=binding['appliance_size'],
|
||||
edge_type=binding['edge_type'],
|
||||
availability_zone=availability_zone_name)
|
||||
|
||||
router_id = backup_router_id
|
||||
if (binding['status'] == plugin_const.ERROR or
|
||||
if (binding['status'] == constants.ERROR or
|
||||
not self.check_edge_active_at_backend(edge_id) or
|
||||
not edge_pool_range):
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_id,
|
||||
status=plugin_const.PENDING_DELETE)
|
||||
status=constants.PENDING_DELETE)
|
||||
# delete edge
|
||||
self._get_worker_pool().spawn_n(
|
||||
self.nsxv_manager.delete_edge, q_context.get_admin_context(),
|
||||
@ -814,12 +814,12 @@ class EdgeManager(object):
|
||||
if update_result:
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, backup_router_id,
|
||||
status=plugin_const.ACTIVE)
|
||||
status=constants.ACTIVE)
|
||||
LOG.debug("Collect edge: %s to pool", edge_id)
|
||||
else:
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_id,
|
||||
status=plugin_const.PENDING_DELETE)
|
||||
status=constants.PENDING_DELETE)
|
||||
# delete edge
|
||||
self._get_worker_pool().spawn_n(
|
||||
self.nsxv_manager.delete_edge, q_context.get_admin_context(),
|
||||
@ -1148,7 +1148,7 @@ class EdgeManager(object):
|
||||
all_dhcp_edges = {binding['router_id']: binding['edge_id'] for
|
||||
binding in router_bindings if (binding['router_id'].
|
||||
startswith(vcns_const.DHCP_EDGE_PREFIX) and
|
||||
binding['status'] == plugin_const.ACTIVE)}
|
||||
binding['status'] == constants.ACTIVE)}
|
||||
vdr_dhcp_edges = self._get_vdr_dhcp_edges(context)
|
||||
|
||||
if all_dhcp_edges:
|
||||
@ -1237,7 +1237,7 @@ class EdgeManager(object):
|
||||
context = q_context.get_admin_context()
|
||||
nsxv_db.add_nsxv_router_binding(
|
||||
context.session, resource_id,
|
||||
edge_id, None, plugin_const.ACTIVE,
|
||||
edge_id, None, constants.ACTIVE,
|
||||
appliance_size=app_size,
|
||||
availability_zone=availability_zone.name)
|
||||
nsxv_db.allocate_edge_vnic_with_tunnel_index(
|
||||
@ -1329,7 +1329,7 @@ class EdgeManager(object):
|
||||
# Delete the existing vnic interface if there is
|
||||
# an overlapping subnet or the binding is in ERROR status
|
||||
if (edge_id in conflict_edge_ids or
|
||||
dhcp_edge_binding['status'] == plugin_const.ERROR):
|
||||
dhcp_edge_binding['status'] == constants.ERROR):
|
||||
LOG.debug("Removing network %s from dhcp edge %s",
|
||||
network_id, edge_id)
|
||||
self.remove_network_from_dhcp_edge(context,
|
||||
@ -1853,7 +1853,7 @@ class EdgeManager(object):
|
||||
for router_id in optional_router_ids:
|
||||
binding = nsxv_db.get_nsxv_router_binding(
|
||||
context.session, router_id)
|
||||
if (binding and binding.status == plugin_const.ACTIVE and
|
||||
if (binding and binding.status == constants.ACTIVE and
|
||||
binding.availability_zone == availability_zone.name and
|
||||
binding.edge_id not in optional_edge_ids):
|
||||
optional_edge_ids.append(binding.edge_id)
|
||||
@ -2142,7 +2142,7 @@ def create_lrouter(nsxv_manager, context, lrouter, lswitch=None, dist=False,
|
||||
# store router-edge mapping binding
|
||||
nsxv_db.add_nsxv_router_binding(
|
||||
context.session, router_id, None, None,
|
||||
plugin_const.PENDING_CREATE,
|
||||
constants.PENDING_CREATE,
|
||||
appliance_size=appliance_size,
|
||||
availability_zone=availability_zone.name)
|
||||
|
||||
@ -2157,7 +2157,7 @@ def delete_lrouter(nsxv_manager, context, router_id, dist=False):
|
||||
if binding:
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_id,
|
||||
status=plugin_const.PENDING_DELETE)
|
||||
status=constants.PENDING_DELETE)
|
||||
edge_id = binding['edge_id']
|
||||
# delete edge
|
||||
nsxv_manager.delete_edge(context, router_id, edge_id, dist=dist)
|
||||
@ -2679,11 +2679,11 @@ class NsxVCallbacks(object):
|
||||
{'edge_id': edge_id,
|
||||
'name': name})
|
||||
if (router_db and
|
||||
router_db['status'] == plugin_const.PENDING_CREATE):
|
||||
router_db['status'] = plugin_const.ACTIVE
|
||||
router_db['status'] == constants.PENDING_CREATE):
|
||||
router_db['status'] = constants.ACTIVE
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_id,
|
||||
status=plugin_const.ACTIVE)
|
||||
status=constants.ACTIVE)
|
||||
if (not dist and
|
||||
self._vcm and availability_zone and
|
||||
availability_zone.edge_ha and
|
||||
@ -2694,10 +2694,10 @@ class NsxVCallbacks(object):
|
||||
else:
|
||||
LOG.error("Failed to deploy Edge for router %s", name)
|
||||
if router_db:
|
||||
router_db['status'] = plugin_const.ERROR
|
||||
router_db['status'] = constants.ERROR
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_id,
|
||||
status=plugin_const.ERROR)
|
||||
status=constants.ERROR)
|
||||
if not dist and edge_id:
|
||||
nsxv_db.clean_edge_vnic_binding(
|
||||
context.session, edge_id)
|
||||
@ -2718,12 +2718,12 @@ class NsxVCallbacks(object):
|
||||
if nsxv_db.get_nsxv_router_binding(admin_ctx.session, router_id):
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
admin_ctx.session, router_id,
|
||||
status=plugin_const.ERROR)
|
||||
status=constants.ERROR)
|
||||
if set_errors and context:
|
||||
# Set the router status to ERROR
|
||||
try:
|
||||
router_db = self.plugin._get_router(context, router_id)
|
||||
router_db['status'] = plugin_const.ERROR
|
||||
router_db['status'] = constants.ERROR
|
||||
except l3.RouterNotFound:
|
||||
# Router might have been deleted before deploy finished
|
||||
LOG.warning("Router %s not found", router_id)
|
||||
|
@ -51,7 +51,6 @@ from neutron.extensions import l3
|
||||
from neutron.extensions import portsecurity as psec
|
||||
from neutron.extensions import providernet
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.plugins.common import utils as n_utils
|
||||
from neutron.quota import resource_registry
|
||||
from neutron.services.qos import qos_consts
|
||||
@ -619,8 +618,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
err_msg = (_('Segmentation ID %(segmentation_id)s out of '
|
||||
'range (%(min_id)s through %(max_id)s)') %
|
||||
{'segmentation_id': vlan_id,
|
||||
'min_id': plugin_const.MIN_VLAN_TAG,
|
||||
'max_id': plugin_const.MAX_VLAN_TAG})
|
||||
'min_id': const.MIN_VLAN_TAG,
|
||||
'max_id': const.MAX_VLAN_TAG})
|
||||
else:
|
||||
# Verify VLAN id is not already allocated
|
||||
bindings = (
|
||||
|
@ -13,8 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.plugins.common import constants
|
||||
from neutron_lib import constants as lib_const
|
||||
from neutron_lib.plugins import constants as plugin_const
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ class EdgeLoadbalancerBaseManager(object):
|
||||
def lbv2_driver(self):
|
||||
if not EdgeLoadbalancerBaseManager._lbv2_driver:
|
||||
plugin = self._get_plugin(
|
||||
constants.LOADBALANCERV2)
|
||||
plugin_const.LOADBALANCERV2)
|
||||
EdgeLoadbalancerBaseManager._lbv2_driver = (
|
||||
plugin.drivers['vmwareedge'])
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.plugins.common import constants
|
||||
from neutron.services.qos import qos_consts
|
||||
from neutron_lib.plugins import constants as plugin_const
|
||||
from neutron_lib.plugins import directory
|
||||
|
||||
from oslo_config import cfg
|
||||
@ -47,7 +47,7 @@ class NsxVQosRule(object):
|
||||
|
||||
def _get_qos_plugin(self):
|
||||
if not self._qos_plugin:
|
||||
self._qos_plugin = directory.get_plugin(constants.QOS)
|
||||
self._qos_plugin = directory.get_plugin(plugin_const.QOS)
|
||||
return self._qos_plugin
|
||||
|
||||
# init the nsx_v qos data (outShapingPolicy) from a neutron qos policy
|
||||
|
@ -29,7 +29,6 @@ from neutron.extensions import l3_ext_gw_mode
|
||||
from neutron.extensions import l3_flavors
|
||||
from neutron.extensions import router_availability_zone
|
||||
from neutron.extensions import securitygroup as secgrp
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.services.qos import qos_consts
|
||||
from neutron.tests.unit import _test_extension_portbindings as test_bindings
|
||||
import neutron.tests.unit.db.test_allowedaddresspairs_db as test_addr_pair
|
||||
@ -47,6 +46,7 @@ from neutron_lib.api import validators
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.plugins import constants as plugin_const
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.utils import helpers
|
||||
from neutron_lib.utils import net
|
||||
@ -3293,7 +3293,7 @@ class TestExclusiveRouterTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
available_edge = {'edge_id': 'edge-11', 'router_id': 'fake_id'}
|
||||
nsxv_db.add_nsxv_router_binding(
|
||||
context.get_admin_context().session, available_edge['router_id'],
|
||||
available_edge['edge_id'], None, plugin_const.ACTIVE)
|
||||
available_edge['edge_id'], None, constants.ACTIVE)
|
||||
with mock.patch.object(p.edge_manager,
|
||||
'_get_available_router_binding',
|
||||
return_value=available_edge):
|
||||
@ -3309,12 +3309,12 @@ class TestExclusiveRouterTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
returned_router = p.create_router(context.get_admin_context(),
|
||||
router)
|
||||
# router status should be 'error'
|
||||
self.assertEqual(plugin_const.ERROR, returned_router['status'])
|
||||
self.assertEqual(constants.ERROR, returned_router['status'])
|
||||
|
||||
# check the same after get_router
|
||||
new_router = p.get_router(context.get_admin_context(),
|
||||
returned_router['id'])
|
||||
self.assertEqual(plugin_const.ERROR, new_router['status'])
|
||||
self.assertEqual(constants.ERROR, new_router['status'])
|
||||
|
||||
def test_create_router_with_bad_az_hint(self):
|
||||
p = directory.get_plugin()
|
||||
|
@ -14,12 +14,12 @@
|
||||
#
|
||||
|
||||
import mock
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
from six import moves
|
||||
|
||||
from neutron.plugins.common import constants as plugin_const
|
||||
from neutron.tests.unit import testlib_api
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from vmware_nsx.common import config as conf
|
||||
@ -101,19 +101,19 @@ class EdgeDHCPManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
self.check.return_value = True
|
||||
|
||||
def test_create_dhcp_edge_service(self):
|
||||
fake_edge_pool = [{'status': plugin_const.ACTIVE,
|
||||
fake_edge_pool = [{'status': constants.ACTIVE,
|
||||
'edge_id': 'edge-1',
|
||||
'router_id': 'backup-11111111-1111',
|
||||
'appliance_size': 'compact',
|
||||
'edge_type': 'service',
|
||||
'availability_zone': DEFAULT_AZ},
|
||||
{'status': plugin_const.PENDING_DELETE,
|
||||
{'status': constants.PENDING_DELETE,
|
||||
'edge_id': 'edge-2',
|
||||
'router_id': 'dhcp-22222222-2222',
|
||||
'appliance_size': 'compact',
|
||||
'edge_type': 'service',
|
||||
'availability_zone': DEFAULT_AZ},
|
||||
{'status': plugin_const.PENDING_DELETE,
|
||||
{'status': constants.PENDING_DELETE,
|
||||
'edge_id': 'edge-3',
|
||||
'router_id': 'backup-33333333-3333',
|
||||
'appliance_size': 'compact',
|
||||
@ -394,7 +394,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
self, num, size=nsxv_constants.LARGE,
|
||||
edge_type=nsxv_constants.SERVICE_EDGE,
|
||||
availability_zone=None):
|
||||
status = plugin_const.ACTIVE
|
||||
status = constants.ACTIVE
|
||||
id_prefix = EDGE_AVAIL + size + '-' + edge_type
|
||||
return self._create_router_bindings(
|
||||
num, status, id_prefix, size, edge_type,
|
||||
@ -404,14 +404,14 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
self, num, size=nsxv_constants.LARGE,
|
||||
edge_type=nsxv_constants.SERVICE_EDGE,
|
||||
availability_zone=None):
|
||||
status = plugin_const.PENDING_CREATE
|
||||
status = constants.PENDING_CREATE
|
||||
id_prefix = EDGE_CREATING + size + '-' + edge_type
|
||||
return self._create_router_bindings(
|
||||
num, status, id_prefix, size, edge_type,
|
||||
availability_zone)
|
||||
|
||||
def _create_error_router_bindings(
|
||||
self, num, status=plugin_const.ERROR,
|
||||
self, num, status=constants.ERROR,
|
||||
size=nsxv_constants.LARGE,
|
||||
edge_type=nsxv_constants.SERVICE_EDGE,
|
||||
availability_zone=None):
|
||||
@ -421,7 +421,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
availability_zone)
|
||||
|
||||
def _create_error_router_bindings_at_backend(
|
||||
self, num, status=plugin_const.ACTIVE,
|
||||
self, num, status=constants.ACTIVE,
|
||||
size=nsxv_constants.LARGE,
|
||||
edge_type=nsxv_constants.SERVICE_EDGE,
|
||||
availability_zone=None):
|
||||
@ -434,7 +434,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
self, num, size=nsxv_constants.LARGE,
|
||||
edge_type=nsxv_constants.SERVICE_EDGE,
|
||||
availability_zone=None):
|
||||
status = plugin_const.PENDING_DELETE
|
||||
status = constants.PENDING_DELETE
|
||||
id_prefix = EDGE_DELETING + size + '-' + edge_type
|
||||
return self._create_router_bindings(
|
||||
num, status, id_prefix, size, edge_type,
|
||||
@ -469,8 +469,8 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
|
||||
def _create_backup_router_bindings(
|
||||
self, avail, creating, error, error_at_backend, deleting,
|
||||
error_status=plugin_const.PENDING_DELETE,
|
||||
error_at_backend_status=plugin_const.PENDING_DELETE,
|
||||
error_status=constants.PENDING_DELETE,
|
||||
error_at_backend_status=constants.PENDING_DELETE,
|
||||
size=nsxv_constants.LARGE,
|
||||
edge_type=nsxv_constants.SERVICE_EDGE,
|
||||
availability_zone=None):
|
||||
@ -516,7 +516,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
self._populate_vcns_router_binding(pool_edges)
|
||||
expect_backup_bindings = self._create_backup_router_bindings(
|
||||
1, 2, 0, 4, 0,
|
||||
error_at_backend_status=plugin_const.ACTIVE,
|
||||
error_at_backend_status=constants.ACTIVE,
|
||||
size=nsxv_constants.LARGE)
|
||||
backup_bindings = self.edge_manager._get_backup_edge_bindings(self.ctx,
|
||||
appliance_size=nsxv_constants.LARGE, availability_zone=self.az)
|
||||
@ -530,7 +530,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
1, 2, 3, 0, 5, size=nsxv_constants.COMPACT))
|
||||
self._populate_vcns_router_binding(pool_edges)
|
||||
expect_backup_bindings = self._create_backup_router_bindings(
|
||||
1, 2, 3, 0, 5, error_status=plugin_const.ERROR)
|
||||
1, 2, 3, 0, 5, error_status=constants.ERROR)
|
||||
binding = self.edge_manager._get_available_router_binding(
|
||||
self.ctx, appliance_size=appliance_size, edge_type=edge_type,
|
||||
availability_zone=self.az)
|
||||
@ -555,8 +555,8 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
self._populate_vcns_router_binding(pool_edges)
|
||||
expect_pool_bindings = self._create_backup_router_bindings(
|
||||
1, 2, 3, 4, 5,
|
||||
error_status=plugin_const.ERROR,
|
||||
error_at_backend_status=plugin_const.PENDING_DELETE)
|
||||
error_status=constants.ERROR,
|
||||
error_at_backend_status=constants.PENDING_DELETE)
|
||||
self.edge_manager._check_backup_edge_pool(
|
||||
0, 3,
|
||||
appliance_size=appliance_size, edge_type=edge_type,
|
||||
@ -586,7 +586,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
binding
|
||||
for binding in nsxv_db.get_nsxv_router_bindings(self.ctx.session)
|
||||
if binding['edge_id'] is None
|
||||
and binding['status'] == plugin_const.PENDING_CREATE]
|
||||
and binding['status'] == constants.PENDING_CREATE]
|
||||
|
||||
binding_ids = [bind.router_id for bind in router_bindings]
|
||||
self.assertEqual(2, len(router_bindings))
|
||||
@ -603,7 +603,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
self.edge_manager._check_backup_edge_pools()
|
||||
router_bindings = nsxv_db.get_nsxv_router_bindings(self.ctx.session)
|
||||
for binding in router_bindings:
|
||||
self.assertEqual(plugin_const.PENDING_DELETE, binding['status'])
|
||||
self.assertEqual(constants.PENDING_DELETE, binding['status'])
|
||||
|
||||
def test_check_backup_edge_pools_with_default(self):
|
||||
self.edge_manager.edge_pool_dicts = self.default_edge_pool_dicts
|
||||
@ -618,8 +618,8 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
|
||||
expect_large_bindings = self._create_backup_router_bindings(
|
||||
1, 2, 3, 4, 5,
|
||||
error_status=plugin_const.PENDING_DELETE,
|
||||
error_at_backend_status=plugin_const.PENDING_DELETE)
|
||||
error_status=constants.PENDING_DELETE,
|
||||
error_at_backend_status=constants.PENDING_DELETE)
|
||||
large_bindings = [
|
||||
binding
|
||||
for binding in router_bindings
|
||||
@ -629,8 +629,8 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
|
||||
expect_compact_bindings = self._create_backup_router_bindings(
|
||||
1, 2, 3, 4, 5,
|
||||
error_status=plugin_const.PENDING_DELETE,
|
||||
error_at_backend_status=plugin_const.PENDING_DELETE,
|
||||
error_status=constants.PENDING_DELETE,
|
||||
error_at_backend_status=constants.PENDING_DELETE,
|
||||
size=nsxv_constants.COMPACT)
|
||||
compact_bindings = [
|
||||
binding
|
||||
@ -645,7 +645,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
if (binding['appliance_size'] == nsxv_constants.LARGE and
|
||||
binding['edge_type'] == nsxv_constants.VDR_EDGE)]
|
||||
for binding in vdr_bindings:
|
||||
self.assertEqual(plugin_const.PENDING_DELETE, binding['status'])
|
||||
self.assertEqual(constants.PENDING_DELETE, binding['status'])
|
||||
|
||||
def test_check_backup_edge_pools_with_vdr(self):
|
||||
self.edge_manager.edge_pool_dicts = self.vdr_edge_pool_dicts
|
||||
@ -659,8 +659,8 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
router_bindings = nsxv_db.get_nsxv_router_bindings(self.ctx.session)
|
||||
expect_vdr_bindings = self._create_backup_router_bindings(
|
||||
1, 2, 3, 4, 5,
|
||||
error_status=plugin_const.PENDING_DELETE,
|
||||
error_at_backend_status=plugin_const.PENDING_DELETE,
|
||||
error_status=constants.PENDING_DELETE,
|
||||
error_at_backend_status=constants.PENDING_DELETE,
|
||||
edge_type=nsxv_constants.VDR_EDGE)
|
||||
vdr_bindings = [
|
||||
binding
|
||||
@ -673,7 +673,7 @@ class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):
|
||||
for binding in router_bindings
|
||||
if binding['edge_type'] == nsxv_constants.SERVICE_EDGE]
|
||||
for binding in service_bindings:
|
||||
self.assertEqual(plugin_const.PENDING_DELETE, binding['status'])
|
||||
self.assertEqual(constants.PENDING_DELETE, binding['status'])
|
||||
|
||||
def test_allocate_edge_appliance_with_empty(self):
|
||||
self.edge_manager._clean_all_error_edge_bindings = mock.Mock()
|
||||
|
Loading…
Reference in New Issue
Block a user