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 and removing the rehomed code in neutron. NeutronLibImpact Change-Id: I696b52265b9528082cd2524f05febe2338376488
This commit is contained in:
parent
c0600ca674
commit
b834bd5048
@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
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 import validators
|
||||
from neutron_lib.callbacks import events
|
||||
@ -20,6 +21,7 @@ from neutron_lib.callbacks import registry
|
||||
from neutron_lib.callbacks import resources
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.exceptions import external_net as extnet_exc
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
from neutron_lib.plugins import directory
|
||||
from sqlalchemy.sql import expression as expr
|
||||
@ -31,7 +33,6 @@ from neutron.db import _utils as db_utils
|
||||
from neutron.db.models import l3 as l3_models
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import rbac_db_models as rbac_db
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import rbac as rbac_ext
|
||||
from neutron.objects import network as net_obj
|
||||
|
||||
@ -57,7 +58,7 @@ def _network_filter_hook(context, original_model, conditions):
|
||||
|
||||
|
||||
def _network_result_filter_hook(query, filters):
|
||||
vals = filters and filters.get(external_net.EXTERNAL, [])
|
||||
vals = filters and filters.get(extnet_apidef.EXTERNAL, [])
|
||||
if not vals:
|
||||
return query
|
||||
if vals[0]:
|
||||
@ -87,11 +88,11 @@ class External_net_db_mixin(object):
|
||||
@resource_extend.extends([net_def.COLLECTION_NAME])
|
||||
def _extend_network_dict_l3(network_res, network_db):
|
||||
# Comparing with None for converting uuid into bool
|
||||
network_res[external_net.EXTERNAL] = network_db.external is not None
|
||||
network_res[extnet_apidef.EXTERNAL] = network_db.external is not None
|
||||
return network_res
|
||||
|
||||
def _process_l3_create(self, context, net_data, req_data):
|
||||
external = req_data.get(external_net.EXTERNAL)
|
||||
external = req_data.get(extnet_apidef.EXTERNAL)
|
||||
external_set = validators.is_attr_set(external)
|
||||
|
||||
if not external_set:
|
||||
@ -103,21 +104,21 @@ class External_net_db_mixin(object):
|
||||
context.session.add(rbac_db.NetworkRBAC(
|
||||
object_id=net_data['id'], action='access_as_external',
|
||||
target_tenant='*', tenant_id=net_data['tenant_id']))
|
||||
net_data[external_net.EXTERNAL] = external
|
||||
net_data[extnet_apidef.EXTERNAL] = external
|
||||
|
||||
def _process_l3_update(self, context, net_data, req_data, allow_all=True):
|
||||
new_value = req_data.get(external_net.EXTERNAL)
|
||||
new_value = req_data.get(extnet_apidef.EXTERNAL)
|
||||
net_id = net_data['id']
|
||||
if not validators.is_attr_set(new_value):
|
||||
return
|
||||
|
||||
if net_data.get(external_net.EXTERNAL) == new_value:
|
||||
if net_data.get(extnet_apidef.EXTERNAL) == new_value:
|
||||
return
|
||||
|
||||
if new_value:
|
||||
net_obj.ExternalNetwork(
|
||||
context, network_id=net_id).create()
|
||||
net_data[external_net.EXTERNAL] = True
|
||||
net_data[extnet_apidef.EXTERNAL] = True
|
||||
if allow_all:
|
||||
context.session.add(rbac_db.NetworkRBAC(
|
||||
object_id=net_id, action='access_as_external',
|
||||
@ -130,14 +131,14 @@ class External_net_db_mixin(object):
|
||||
device_owner=DEVICE_OWNER_ROUTER_GW,
|
||||
network_id=net_data['id']).first()
|
||||
if port:
|
||||
raise external_net.ExternalNetworkInUse(net_id=net_id)
|
||||
raise extnet_exc.ExternalNetworkInUse(net_id=net_id)
|
||||
|
||||
net_obj.ExternalNetwork.delete_objects(
|
||||
context, network_id=net_id)
|
||||
for rbdb in (context.session.query(rbac_db.NetworkRBAC).filter_by(
|
||||
object_id=net_id, action='access_as_external')):
|
||||
context.session.delete(rbdb)
|
||||
net_data[external_net.EXTERNAL] = False
|
||||
net_data[extnet_apidef.EXTERNAL] = False
|
||||
|
||||
def _process_l3_delete(self, context, network_id):
|
||||
l3plugin = directory.get_plugin(plugin_constants.L3)
|
||||
@ -145,7 +146,7 @@ class External_net_db_mixin(object):
|
||||
l3plugin.delete_disassociated_floatingips(context, network_id)
|
||||
|
||||
def get_external_network_id(self, context):
|
||||
nets = self.get_networks(context, {external_net.EXTERNAL: [True]})
|
||||
nets = self.get_networks(context, {extnet_apidef.EXTERNAL: [True]})
|
||||
if len(nets) > 1:
|
||||
raise n_exc.TooManyExternalNetworks()
|
||||
else:
|
||||
@ -165,7 +166,7 @@ class External_net_db_mixin(object):
|
||||
if not self._network_is_external(context, policy['object_id']):
|
||||
# we automatically convert the network into an external network
|
||||
self._process_l3_update(context, net,
|
||||
{external_net.EXTERNAL: True},
|
||||
{extnet_apidef.EXTERNAL: True},
|
||||
allow_all=False)
|
||||
|
||||
@registry.receives('rbac-policy', (events.BEFORE_UPDATE,
|
||||
|
@ -17,6 +17,7 @@ import itertools
|
||||
import random
|
||||
|
||||
import netaddr
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api import validators
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import exceptions
|
||||
@ -48,7 +49,6 @@ from neutron.db import common_db_mixin
|
||||
from neutron.db.models import l3 as l3_models
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import standardattrdescription_db as st_attr
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.objects import ports as port_obj
|
||||
from neutron.objects import router as l3_obj
|
||||
@ -305,7 +305,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
return
|
||||
|
||||
nets = self._core_plugin.get_networks(
|
||||
context, {external_net.EXTERNAL: [True]})
|
||||
context, {extnet_apidef.EXTERNAL: [True]})
|
||||
# nothing to do if there is only one external network
|
||||
if len(nets) <= 1:
|
||||
return
|
||||
|
@ -13,50 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.api import converters
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib import exceptions as nexception
|
||||
|
||||
from neutron._i18n import _
|
||||
|
||||
|
||||
class ExternalNetworkInUse(nexception.InUse):
|
||||
message = _("External network %(net_id)s cannot be updated to be made "
|
||||
"non-external, since it has existing gateway ports")
|
||||
|
||||
|
||||
# For backward compatibility the 'router' prefix is kept.
|
||||
EXTERNAL = 'router:external'
|
||||
EXTENDED_ATTRIBUTES_2_0 = {
|
||||
'networks': {EXTERNAL: {'allow_post': True,
|
||||
'allow_put': True,
|
||||
'default': False,
|
||||
'is_visible': True,
|
||||
'convert_to': converters.convert_to_boolean,
|
||||
'enforce_policy': True,
|
||||
'required_by_policy': True}}}
|
||||
|
||||
|
||||
class External_net(extensions.ExtensionDescriptor):
|
||||
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
return "Neutron external network"
|
||||
|
||||
@classmethod
|
||||
def get_alias(cls):
|
||||
return "external-net"
|
||||
|
||||
@classmethod
|
||||
def get_description(cls):
|
||||
return _("Adds external network attribute to network resource.")
|
||||
|
||||
@classmethod
|
||||
def get_updated(cls):
|
||||
return "2013-01-14T10:00:00-00:00"
|
||||
|
||||
def get_extended_resources(self, version):
|
||||
if version == "2.0":
|
||||
return EXTENDED_ATTRIBUTES_2_0
|
||||
else:
|
||||
return {}
|
||||
class External_net(extensions.APIExtensionDescriptor):
|
||||
api_definition = extnet_apidef
|
||||
|
@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
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 provider
|
||||
from neutron_lib.api import validators
|
||||
@ -28,7 +29,6 @@ from neutron._i18n import _
|
||||
from neutron.conf.plugins.ml2 import config
|
||||
from neutron.db import api as db_api
|
||||
from neutron.db import segments_db
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.extensions import vlantransparent
|
||||
from neutron.plugins.ml2.common import exceptions as ml2_exc
|
||||
@ -203,7 +203,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
|
||||
self._add_network_segment(context, network_id, segment,
|
||||
segment_index)
|
||||
elif (cfg.CONF.ml2.external_network_type and
|
||||
self._get_attribute(network, external_net.EXTERNAL)):
|
||||
self._get_attribute(network, extnet_apidef.EXTERNAL)):
|
||||
segment = self._allocate_ext_net_segment(context)
|
||||
self._add_network_segment(context, network_id, segment)
|
||||
else:
|
||||
|
@ -13,11 +13,11 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib import constants
|
||||
|
||||
from neutron.common import topics
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.tests.common import helpers
|
||||
from neutron.tests.functional.services.l3_router import \
|
||||
@ -147,7 +147,7 @@ class L3DvrHATestCase(test_l3_dvr_router_plugin.L3DvrTestCase):
|
||||
# make net external
|
||||
ext_net_id = ext_subnet['subnet']['network_id']
|
||||
self._update('networks', ext_net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
with mock.patch.object(self.l3_plugin.l3_rpc_notifier.client,
|
||||
'prepare') as mock_prepare:
|
||||
# add external gateway to router
|
||||
@ -227,8 +227,8 @@ class L3DvrHATestCase(test_l3_dvr_router_plugin.L3DvrTestCase):
|
||||
on router interface removal
|
||||
"""
|
||||
router = self._create_router(distributed=True, ha=True)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.subnet() as subnet, \
|
||||
self.network(**kwargs) as ext_net, \
|
||||
self.subnet(network=ext_net, cidr='20.0.0.0/24'):
|
||||
@ -253,8 +253,8 @@ class L3DvrHATestCase(test_l3_dvr_router_plugin.L3DvrTestCase):
|
||||
SNAT for it on DHCP port removal
|
||||
"""
|
||||
router = self._create_router(distributed=True, ha=True)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.network(**kwargs) as ext_net, \
|
||||
self.subnet(network=ext_net), \
|
||||
self.subnet(cidr='20.0.0.0/24') as subnet, \
|
||||
@ -297,8 +297,8 @@ class L3DvrHATestCase(test_l3_dvr_router_plugin.L3DvrTestCase):
|
||||
len(self._get_ha_interface_list_for_router(rtr)))
|
||||
|
||||
def _create_external_network(self):
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, 'ext_net', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.0.0.1', '10.0.0.0/24',
|
||||
|
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import registry
|
||||
@ -24,7 +25,6 @@ from neutron_lib import context
|
||||
from neutron.api.rpc.handlers import l3_rpc
|
||||
from neutron.common import constants as n_const
|
||||
from neutron.common import topics
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.tests.common import helpers
|
||||
from neutron.tests.unit.plugins.ml2 import base as ml2_test_base
|
||||
@ -86,8 +86,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
self.context, 'network_id', 'host', 'agent_id'))
|
||||
|
||||
def test_csnat_ports_are_created_and_deleted_based_on_router_subnet(self):
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
net1 = self._make_network(self.fmt, 'net1', True)
|
||||
subnet1 = self._make_subnet(
|
||||
self.fmt, net1, '10.1.0.1', '10.1.0.0/24', enable_dhcp=True)
|
||||
@ -145,8 +145,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
def _test_remove_router_interface_leaves_snat_intact(self, by_subnet):
|
||||
with self.subnet() as subnet1, \
|
||||
self.subnet(cidr='20.0.0.0/24') as subnet2:
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.network(**kwargs) as ext_net, \
|
||||
self.subnet(network=ext_net,
|
||||
cidr='30.0.0.0/24'):
|
||||
@ -255,8 +255,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
self.context, [router['id']])
|
||||
|
||||
def test_agent_gw_port_delete_when_last_gateway_for_ext_net_removed(self):
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
net1 = self._make_network(self.fmt, 'net1', True)
|
||||
net2 = self._make_network(self.fmt, 'net2', True)
|
||||
subnet1 = self._make_subnet(
|
||||
@ -321,7 +321,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
# make net external
|
||||
ext_net_id = ext_subnet['subnet']['network_id']
|
||||
self._update('networks', ext_net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
|
||||
router = self._create_router(distributed=dvr)
|
||||
self.l3_plugin.update_router(
|
||||
@ -405,7 +405,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
# make net external
|
||||
ext_net_id = ext_subnet['subnet']['network_id']
|
||||
self._update('networks', ext_net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
|
||||
router1 = self._create_router(distributed=dvr)
|
||||
router2 = self._create_router(distributed=dvr)
|
||||
@ -513,7 +513,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
# make net external
|
||||
ext_net_id = ext_subnet['subnet']['network_id']
|
||||
self._update('networks', ext_net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
|
||||
router = self._create_router(distributed=dvr)
|
||||
self.l3_plugin.update_router(
|
||||
@ -576,8 +576,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
self._test_delete_floating_ip_agent_notification(dvr=False)
|
||||
|
||||
def test_router_with_ipv4_and_multiple_ipv6_on_same_network(self):
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.0.0.1', '10.0.0.0/24',
|
||||
@ -647,8 +647,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
test_allocation_pools = [{'start': '10.1.0.2',
|
||||
'end': '10.1.0.20'}]
|
||||
fixed_vrrp_ip = [{'ip_address': '10.1.0.201'}]
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||
@ -754,8 +754,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
host=HOST1, agent_mode=constants.L3_AGENT_MODE_DVR)
|
||||
router = self._create_router(ha=False)
|
||||
private_net1 = self._make_network(self.fmt, 'net1', True)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||
@ -835,8 +835,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
host=HOST1, agent_mode=constants.L3_AGENT_MODE_DVR)
|
||||
router = self._create_router(ha=False)
|
||||
private_net1 = self._make_network(self.fmt, 'net1', True)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||
@ -910,8 +910,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
host=HOST1, agent_mode=n_const.L3_AGENT_MODE_DVR_NO_EXTERNAL)
|
||||
router = self._create_router(ha=False)
|
||||
private_net1 = self._make_network(self.fmt, 'net1', True)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||
@ -982,8 +982,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
test_allocation_pools = [{'start': '10.1.0.2',
|
||||
'end': '10.1.0.20'}]
|
||||
fixed_vrrp_ip = [{'ip_address': '10.1.0.201'}]
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||
@ -1112,8 +1112,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
def test_dvr_gateway_host_binding_is_set(self):
|
||||
router = self._create_router(ha=False)
|
||||
private_net1 = self._make_network(self.fmt, 'net1', True)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||
@ -1152,8 +1152,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
test_allocation_pools = [{'start': '10.1.0.2',
|
||||
'end': '10.1.0.20'}]
|
||||
fixed_vrrp_ip = [{'ip_address': '10.1.0.201'}]
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
ext_net = self._make_network(self.fmt, '', True, **kwargs)
|
||||
self._make_subnet(
|
||||
self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
|
||||
@ -1288,8 +1288,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
|
||||
def test_dvr_router_manual_rescheduling_removes_router(self):
|
||||
router = self._create_router()
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.network(**kwargs) as ext_net,\
|
||||
self.subnet(network=ext_net),\
|
||||
self.subnet(cidr='20.0.0.0/24') as subnet,\
|
||||
@ -1315,8 +1315,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
|
||||
def test_dvr_router_manual_rescheduling_updates_router(self):
|
||||
router = self._create_router()
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.network(**kwargs) as ext_net,\
|
||||
self.subnet(network=ext_net),\
|
||||
self.subnet(cidr='20.0.0.0/24') as subnet,\
|
||||
@ -1409,7 +1409,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
# make net external
|
||||
ext_net_id = ext_subnet['subnet']['network_id']
|
||||
self._update('networks', ext_net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
# add external gateway to router
|
||||
self.l3_plugin.update_router(
|
||||
self.context, router['id'],
|
||||
@ -1492,7 +1492,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
# make net external
|
||||
ext_net_id = ext_subnet['subnet']['network_id']
|
||||
self._update('networks', ext_net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
|
||||
with mock.patch.object(self.l3_plugin.l3_rpc_notifier.client,
|
||||
'prepare') as mock_prepare:
|
||||
@ -1560,8 +1560,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
SNAT for it on router interface removal
|
||||
"""
|
||||
router = self._create_router()
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.subnet() as subnet,\
|
||||
self.network(**kwargs) as ext_net,\
|
||||
self.subnet(network=ext_net, cidr='20.0.0.0/24'):
|
||||
@ -1590,8 +1590,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
SNAT for it on DHCP port removal
|
||||
"""
|
||||
router = self._create_router()
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.network(**kwargs) as ext_net,\
|
||||
self.subnet(network=ext_net),\
|
||||
self.subnet(cidr='20.0.0.0/24') as subnet,\
|
||||
@ -1790,7 +1790,7 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
# make net external
|
||||
ext_net_id = ext_subnet['subnet']['network_id']
|
||||
self._update('networks', ext_net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
# add external gateway to router
|
||||
self.l3_plugin.update_router(
|
||||
self.context, router3['id'],
|
||||
@ -1929,8 +1929,8 @@ class L3DvrTestCase(L3DvrTestCaseBase):
|
||||
class L3DvrTestCaseMigration(L3DvrTestCaseBase):
|
||||
def test_update_router_db_centralized_to_distributed_with_ports(self):
|
||||
with self.subnet() as subnet1:
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.network(**kwargs) as ext_net, \
|
||||
self.subnet(network=ext_net,
|
||||
cidr='30.0.0.0/24'):
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
import mock
|
||||
|
||||
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 providernet
|
||||
from neutron_lib.callbacks import events
|
||||
@ -41,7 +42,6 @@ from neutron.db import common_db_mixin
|
||||
from neutron.db import l3_agentschedulers_db
|
||||
from neutron.db import l3_hamode_db
|
||||
from neutron.db.models import l3ha as l3ha_model
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.extensions import l3_ext_ha_mode
|
||||
from neutron.objects import l3_hamode
|
||||
@ -962,7 +962,7 @@ class L3HAModeDbTestCase(L3HATestFramework):
|
||||
'shared': False,
|
||||
'admin_state_up': True,
|
||||
'tenant_id': tenant_id,
|
||||
external_net.EXTERNAL: external}}
|
||||
extnet_apidef.EXTERNAL: external}}
|
||||
return plugin.create_network(ctx, network)['id']
|
||||
|
||||
def _create_subnet(self, plugin, ctx, network_id, cidr='10.0.0.0/8',
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib import constants
|
||||
from neutron_lib import context
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
@ -24,7 +25,6 @@ from webob import exc
|
||||
|
||||
from neutron.db import external_net_db
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import external_net
|
||||
from neutron.tests.unit.api.v2 import test_base
|
||||
from neutron.tests.unit.db import test_db_base_plugin_v2
|
||||
|
||||
@ -53,7 +53,7 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||
# a double underscore
|
||||
new_args = dict(zip(map(lambda x: x.replace('__', ':'), kwargs),
|
||||
kwargs.values()))
|
||||
arg_list = new_args.pop('arg_list', ()) + (external_net.EXTERNAL,)
|
||||
arg_list = new_args.pop('arg_list', ()) + (extnet_apidef.EXTERNAL,)
|
||||
return super(ExtNetDBTestCase, self)._create_network(
|
||||
fmt, name, admin_state_up, arg_list=arg_list, **new_args)
|
||||
|
||||
@ -64,7 +64,7 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||
|
||||
def _set_net_external(self, net_id):
|
||||
self._update('networks', net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
|
||||
def test_list_nets_external(self):
|
||||
with self.network() as n1:
|
||||
@ -75,12 +75,12 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||
|
||||
body = self._list('networks',
|
||||
query_params="%s=True" %
|
||||
external_net.EXTERNAL)
|
||||
extnet_apidef.EXTERNAL)
|
||||
self.assertEqual(1, len(body['networks']))
|
||||
|
||||
body = self._list('networks',
|
||||
query_params="%s=False" %
|
||||
external_net.EXTERNAL)
|
||||
extnet_apidef.EXTERNAL)
|
||||
self.assertEqual(1, len(body['networks']))
|
||||
|
||||
def test_list_nets_external_pagination(self):
|
||||
@ -182,7 +182,7 @@ class ExtNetDBTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase):
|
||||
|
||||
def test_create_external_network_admin_succeeds(self):
|
||||
with self.network(router__external=True) as ext_net:
|
||||
self.assertTrue(ext_net['network'][external_net.EXTERNAL])
|
||||
self.assertTrue(ext_net['network'][extnet_apidef.EXTERNAL])
|
||||
|
||||
def test_delete_network_check_disassociated_floatingips(self):
|
||||
l3_mock = mock.Mock()
|
||||
|
@ -20,6 +20,7 @@ import copy
|
||||
import mock
|
||||
import netaddr
|
||||
from neutron_lib.api.definitions import dns as dns_apidef
|
||||
from neutron_lib.api.definitions import external_net as extnet_apidef
|
||||
from neutron_lib.api.definitions import portbindings
|
||||
from neutron_lib.callbacks import events
|
||||
from neutron_lib.callbacks import exceptions
|
||||
@ -52,7 +53,6 @@ from neutron.db import l3_dvrscheduler_db
|
||||
from neutron.db import l3_hamode_db
|
||||
from neutron.db.models import l3 as l3_models
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import l3
|
||||
from neutron.services.revisions import revision_plugin
|
||||
from neutron.tests import base
|
||||
@ -431,7 +431,7 @@ class L3NatTestCaseMixin(object):
|
||||
|
||||
def _set_net_external(self, net_id):
|
||||
self._update('networks', net_id,
|
||||
{'network': {external_net.EXTERNAL: True}})
|
||||
{'network': {extnet_apidef.EXTERNAL: True}})
|
||||
|
||||
def _create_floatingip(self, fmt, network_id, port_id=None,
|
||||
fixed_ip=None, set_context=False,
|
||||
@ -2054,7 +2054,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
||||
r['router']['id'],
|
||||
s1['subnet']['network_id'])
|
||||
self._update('networks', s1['subnet']['network_id'],
|
||||
{'network': {external_net.EXTERNAL: False}},
|
||||
{'network': {extnet_apidef.EXTERNAL: False}},
|
||||
expected_code=exc.HTTPConflict.code)
|
||||
|
||||
def test_network_update_external(self):
|
||||
@ -2067,7 +2067,7 @@ class L3NatTestCaseBase(L3NatTestCaseMixin):
|
||||
r['router']['id'],
|
||||
s1['subnet']['network_id'])
|
||||
self._update('networks', testnet['network']['id'],
|
||||
{'network': {external_net.EXTERNAL: False}})
|
||||
{'network': {extnet_apidef.EXTERNAL: False}})
|
||||
|
||||
def test_floatingip_crd_ops(self):
|
||||
with self.floatingip_with_assoc() as fip:
|
||||
|
@ -18,6 +18,7 @@ import functools
|
||||
import fixtures
|
||||
import mock
|
||||
from neutron_lib.api.definitions import availability_zone as az_def
|
||||
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.callbacks import events
|
||||
@ -43,7 +44,6 @@ from neutron.db import api as db_api
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import provisioning_blocks
|
||||
from neutron.db import segments_db
|
||||
from neutron.extensions import external_net
|
||||
from neutron.extensions import multiprovidernet as mpnet
|
||||
from neutron.objects import base as base_obj
|
||||
from neutron.objects import router as l3_obj
|
||||
@ -938,8 +938,8 @@ class TestMl2PortsV2(test_plugin.TestPortsV2, Ml2PluginV2TestCase):
|
||||
|
||||
def test_l3_cleanup_on_net_delete(self):
|
||||
l3plugin = directory.get_plugin(plugin_constants.L3)
|
||||
kwargs = {'arg_list': (external_net.EXTERNAL,),
|
||||
external_net.EXTERNAL: True}
|
||||
kwargs = {'arg_list': (extnet_apidef.EXTERNAL,),
|
||||
extnet_apidef.EXTERNAL: True}
|
||||
with self.network(**kwargs) as n:
|
||||
with self.subnet(network=n, cidr='200.0.0.0/22'):
|
||||
l3plugin.create_floatingip(
|
||||
|
Loading…
Reference in New Issue
Block a user