use external net api def from lib

The external network extension's API definition was rehomed into
neutron-lib with I9933b91d1e82db3891b3b72f06e94316e56a4f15. This patch
consumes it, switch over to neutron-lib's modules in prep for
I696b52265b9528082cd2524f05febe2338376488

Change-Id: I338af67ad05827d6a770bebe0600e9d08e37afae
This commit is contained in:
Boden R 2017-10-22 08:50:21 -06:00
parent fb9f324039
commit c35d717a88
10 changed files with 36 additions and 36 deletions

View File

@ -15,7 +15,7 @@
# under the License.
#
from neutron.extensions import external_net
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib import constants as const
from neutron_lib import exceptions as n_exc
from oslo_log import log as logging
@ -114,7 +114,7 @@ class MigrationManager(object):
reason = _("LSN already exist")
raise p_exc.LsnMigrationConflict(net_id=network_id, reason=reason)
if network[external_net.EXTERNAL]:
if network[extnet_apidef.EXTERNAL]:
reason = _("Cannot migrate an external network")
raise n_exc.BadRequest(resource='network', msg=reason)

View File

@ -15,6 +15,7 @@
# under the License.
#
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib import constants as const
from neutron_lib import exceptions as n_exc
from oslo_config import cfg
@ -23,7 +24,6 @@ from oslo_utils import excutils
from neutron.db import db_base_plugin_v2
from neutron.db import l3_db
from neutron.extensions import external_net
from vmware_nsx._i18n import _
from vmware_nsx.common import exceptions as p_exc
@ -211,7 +211,7 @@ def handle_network_dhcp_access(plugin, context, network, action):
{"action": action, "resource": network})
if action == 'create_network':
network_id = network['id']
if network.get(external_net.EXTERNAL):
if network.get(extnet_apidef.EXTERNAL):
LOG.info("Network %s is external: no LSN to create",
network_id)
return
@ -280,7 +280,7 @@ def handle_port_metadata_access(plugin, context, port, is_delete=False):
if is_user_port(port, check_dev_id=True):
network_id = port["network_id"]
network = plugin.get_network(context, network_id)
if network[external_net.EXTERNAL]:
if network[extnet_apidef.EXTERNAL]:
LOG.info("Network %s is external: nothing to do",
network_id)
return

View File

@ -15,6 +15,7 @@
import uuid
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api import validators
from neutron_lib import constants
@ -57,7 +58,6 @@ from neutron.db import portsecurity_db
from neutron.db import quota_db # noqa
from neutron.db import securitygroups_db
from neutron.extensions import allowedaddresspairs as addr_pair
from neutron.extensions import external_net as ext_net_extn
from neutron.extensions import extraroute
from neutron.extensions import l3
from neutron.extensions import multiprovidernet as mpnet
@ -833,7 +833,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
'min_id': constants.MIN_VLAN_TAG,
'max_id': constants.MAX_VLAN_TAG})
# Network must be external
if not network.get(ext_net_extn.EXTERNAL):
if not network.get(extnet_apidef.EXTERNAL):
err_msg = (_("The l3_ext provide network type can be "
"used with external networks only"))
else:
@ -949,7 +949,7 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"network %s", net_data.get('name', '<unknown>'))
transport_zone_config = self._convert_to_nsx_transport_zones(
self.cluster, net_data)
external = net_data.get(ext_net_extn.EXTERNAL)
external = net_data.get(extnet_apidef.EXTERNAL)
# NOTE(salv-orlando): Pre-generating uuid for Neutron
# network. This will be removed once the network create operation
# becomes an asynchronous task

View File

@ -17,6 +17,7 @@ from distutils import version
import uuid
import netaddr
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import extra_dhcp_opt as ext_edo
from neutron_lib.api.definitions import network as net_def
from neutron_lib.api.definitions import port as port_def
@ -72,7 +73,6 @@ from neutron.db import securitygroups_db
from neutron.db import vlantransparent_db
from neutron.extensions import allowedaddresspairs as addr_pair
from neutron.extensions import availability_zone as az_ext
from neutron.extensions import external_net as ext_net_extn
from neutron.extensions import flavors
from neutron.extensions import l3
from neutron.extensions import multiprovidernet as mpnet
@ -657,7 +657,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
if segmentation_id_set:
err_msg = _("Segmentation ID cannot be set with VXLAN")
elif network_type == c_utils.NsxVNetworkTypes.PORTGROUP:
external = network.get(ext_net_extn.EXTERNAL)
external = network.get(extnet_apidef.EXTERNAL)
if segmentation_id_set:
err_msg = _("Segmentation ID cannot be set with portgroup")
if not physical_network_set:
@ -1053,7 +1053,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._validate_availability_zones_in_obj(context, 'network', net_data)
net_data['id'] = str(uuid.uuid4())
external = net_data.get(ext_net_extn.EXTERNAL)
external = net_data.get(extnet_apidef.EXTERNAL)
backend_network = (not validators.is_attr_set(external) or
validators.is_attr_set(external) and not external)
network_type = None
@ -3200,7 +3200,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
net = self.get_network(context.elevated(),
subnet['network_id'])
route['network_id'] = net['id']
if net.get(ext_net_extn.EXTERNAL):
if net.get(extnet_apidef.EXTERNAL):
route['external'] = True
def _prepare_edge_extra_routes(self, context, router_id):
@ -3526,7 +3526,7 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
net_id, subnet_id = self._get_interface_info(context, interface_info)
network = self.get_network(context.elevated(), net_id)
# Do not support external subnet/port as a router interface
if network.get(ext_net_extn.EXTERNAL):
if network.get(extnet_apidef.EXTERNAL):
msg = _("cannot add an external subnet/port as a router interface")
raise n_exc.InvalidInput(error_message=msg)

View File

@ -14,6 +14,7 @@
# under the License.
import netaddr
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import network as net_def
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.exceptions import port_security as psec_exc
@ -47,7 +48,6 @@ from neutron.db import portsecurity_db
from neutron.db import securitygroups_db
from neutron.extensions import allowedaddresspairs as addr_pair
from neutron.extensions import availability_zone as az_ext
from neutron.extensions import external_net as ext_net_extn
from neutron.extensions import l3
from neutron.extensions import providernet
from neutron.extensions import securitygroup as ext_sg
@ -906,7 +906,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
def create_network(self, context, network):
net_data = network['network']
external = net_data.get(ext_net_extn.EXTERNAL)
external = net_data.get(extnet_apidef.EXTERNAL)
is_backend_network = False
tenant_id = net_data['tenant_id']

View File

@ -20,8 +20,8 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils
from neutron.extensions import external_net
from neutron_lib.api.definitions import address_scope
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib import constants as n_const
from neutron_lib import exceptions as n_exc
from neutron_lib.plugins import directory
@ -392,7 +392,7 @@ class NSXvBgpDriver(object):
def _validate_gateway_network(self, context, speaker_id, network_id):
ext_net = self._core_plugin.get_network(context, network_id)
if not ext_net.get(external_net.EXTERNAL):
if not ext_net.get(extnet_apidef.EXTERNAL):
raise nsx_exc.NsxBgpNetworkNotExternal(net_id=network_id)
if not ext_net['subnets']:
raise nsx_exc.NsxBgpGatewayNetworkHasNoSubnets(net_id=network_id)

View File

@ -17,10 +17,10 @@
import xml.etree.ElementTree as et
import netaddr
from neutron.extensions import external_net as ext_net_extn
from neutron.extensions import multiprovidernet as mpnet
from neutron.ipam import exceptions as ipam_exc
from neutron.ipam import requests as ipam_req
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib.api import validators
from oslo_log import log as logging
@ -51,7 +51,7 @@ class NsxvIpamDriver(common.NsxAbstractIpamDriver, NsxVIpamBase):
network_id = subnet_request.network_id
if network_id:
network = self._fetch_network(self._context, network_id)
if network.get(ext_net_extn.EXTERNAL):
if network.get(extnet_apidef.EXTERNAL):
# external network
return True
if (validators.is_attr_set(network.get(mpnet.SEGMENTS)) or

View File

@ -18,7 +18,6 @@ import uuid
import mock
from neutron.api.v2 import attributes
from neutron.extensions import dvr
from neutron.extensions import external_net
from neutron.extensions import l3
from neutron.extensions import l3_ext_gw_mode
from neutron.extensions import securitygroup as secgrp
@ -29,6 +28,7 @@ import neutron.tests.unit.extensions.test_l3 as test_l3_plugin
import neutron.tests.unit.extensions.test_l3_ext_gw_mode as test_ext_gw_mode
import neutron.tests.unit.extensions.test_securitygroup as ext_sg
from neutron.tests.unit import testlib_api
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import portbindings
from neutron_lib.api.definitions import provider_net as pnet
from neutron_lib import constants
@ -72,8 +72,8 @@ class NsxPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
# attributes containing a colon to be passed with
# a double underscore instead
kwargs = dict((k.replace('__', ':'), v) for k, v in kwargs.items())
if external_net.EXTERNAL in kwargs:
arg_list = (external_net.EXTERNAL, ) + (arg_list or ())
if extnet_apidef.EXTERNAL in kwargs:
arg_list = (extnet_apidef.EXTERNAL, ) + (arg_list or ())
attrs = kwargs
if providernet_args:
@ -547,7 +547,7 @@ class TestL3NatTestCase(L3NatTest,
net_type = utils.NetworkTypes.L3_EXT
expected = [('subnets', []), ('name', name), ('admin_state_up', True),
('status', 'ACTIVE'), ('shared', False),
(external_net.EXTERNAL, True),
(extnet_apidef.EXTERNAL, True),
(pnet.NETWORK_TYPE, net_type),
(pnet.PHYSICAL_NETWORK, 'l3_gw_uuid'),
(pnet.SEGMENTATION_ID, vlan_id)]
@ -1027,7 +1027,7 @@ class NeutronNsxOutOfSync(NsxPluginV2TestCase,
net_id = net['network']['id']
if external:
self._update('networks', net_id,
{'network': {external_net.EXTERNAL: True}})
{'network': {extnet_apidef.EXTERNAL: True}})
sub_res = self._create_subnet('json', net_id, cidr)
sub = self.deserialize('json', sub_res)
return net_id, sub['subnet']['id']

View File

@ -23,7 +23,6 @@ from neutron.api.v2 import attributes
from neutron.extensions import address_scope
from neutron.extensions import allowedaddresspairs as addr_pair
from neutron.extensions import dvr as dist_router
from neutron.extensions import external_net
from neutron.extensions import l3
from neutron.extensions import l3_ext_gw_mode
from neutron.extensions import l3_flavors
@ -42,6 +41,7 @@ import neutron.tests.unit.extensions.test_portsecurity as test_psec
import neutron.tests.unit.extensions.test_securitygroup as ext_sg
from neutron.tests.unit import testlib_api
from neutron_lib.api.definitions import address_scope as addr_apidef
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import extra_dhcp_opt as edo_ext
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api.definitions import portbindings
@ -126,8 +126,8 @@ class NsxVPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
# attributes containing a colon to be passed with
# a double underscore instead
kwargs = dict((k.replace('__', ':'), v) for k, v in kwargs.items())
if external_net.EXTERNAL in kwargs:
arg_list = (external_net.EXTERNAL, ) + (arg_list or ())
if extnet_apidef.EXTERNAL in kwargs:
arg_list = (extnet_apidef.EXTERNAL, ) + (arg_list or ())
attrs = kwargs
if providernet_args:
@ -311,17 +311,17 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxVPluginV2TestCase):
name = 'ext_net'
expected = [('subnets', []), ('name', name), ('admin_state_up', True),
('status', 'ACTIVE'), ('shared', False),
(external_net.EXTERNAL, True),
(extnet_apidef.EXTERNAL, True),
(pnet.NETWORK_TYPE, 'portgroup'),
(pnet.PHYSICAL_NETWORK, 'tzuuid')]
providernet_args = {pnet.NETWORK_TYPE: 'portgroup',
pnet.PHYSICAL_NETWORK: 'tzuuid',
external_net.EXTERNAL: True}
extnet_apidef.EXTERNAL: True}
with self.network(name=name,
providernet_args=providernet_args,
arg_list=(pnet.NETWORK_TYPE,
pnet.PHYSICAL_NETWORK,
external_net.EXTERNAL)) as net:
extnet_apidef.EXTERNAL)) as net:
for k, v in expected:
self.assertEqual(net['network'][k], v)
@ -2241,7 +2241,7 @@ class L3NatTest(test_l3_plugin.L3BaseForIntTests, NsxVPluginV2TestCase):
def _set_net_external(self, net_id):
self._update('networks', net_id,
{'network': {external_net.EXTERNAL: True}})
{'network': {extnet_apidef.EXTERNAL: True}})
def _add_external_gateway_to_router(self, router_id, network_id,
expected_code=webob.exc.HTTPOk.code,
@ -2786,7 +2786,7 @@ class TestExclusiveRouterTestCase(L3NatTest, L3NatTestCaseBase,
name = 'l3_ext_net'
expected = [('subnets', []), ('name', name), ('admin_state_up', True),
('status', 'ACTIVE'), ('shared', False),
(external_net.EXTERNAL, True)]
(extnet_apidef.EXTERNAL, True)]
with self._create_l3_ext_network(vlan_id) as net:
for k, v in expected:
self.assertEqual(net['network'][k], v)

View File

@ -21,7 +21,6 @@ from webob import exc
from neutron.api.v2 import attributes
from neutron.db import models_v2
from neutron.extensions import address_scope
from neutron.extensions import external_net
from neutron.extensions import extraroute
from neutron.extensions import l3
from neutron.extensions import l3_ext_gw_mode
@ -38,6 +37,7 @@ from neutron.tests.unit.scheduler \
import test_dhcp_agent_scheduler as test_dhcpagent
from neutron_lib.api.definitions import address_scope as addr_apidef
from neutron_lib.api.definitions import external_net as extnet_apidef
from neutron_lib.api.definitions import port_security as psec
from neutron_lib.api.definitions import portbindings
from neutron_lib.api.definitions import provider_net as pnet
@ -223,8 +223,8 @@ class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase,
# attributes containing a colon to be passed with
# a double underscore instead
kwargs = dict((k.replace('__', ':'), v) for k, v in kwargs.items())
if external_net.EXTERNAL in kwargs:
arg_list = (external_net.EXTERNAL, ) + (arg_list or ())
if extnet_apidef.EXTERNAL in kwargs:
arg_list = (extnet_apidef.EXTERNAL, ) + (arg_list or ())
if providernet_args:
kwargs.update(providernet_args)
@ -1054,7 +1054,7 @@ class TestL3NatTestCase(L3NatTest,
net_type = utils.NetworkTypes.L3_EXT
expected = [('subnets', []), ('name', name), ('admin_state_up', True),
('status', 'ACTIVE'), ('shared', False),
(external_net.EXTERNAL, True),
(extnet_apidef.EXTERNAL, True),
(pnet.NETWORK_TYPE, net_type),
(pnet.PHYSICAL_NETWORK, physical_network)]
with self._create_l3_ext_network(physical_network) as net: