Skip MTU check during deletion of Networks

MTU check can be skipped during deletion of Networks.
The MTU check doesn't provide any additional support during deletion
of the networks.

Also, if a network is created with MTU 'X' and the
global_mtu later on is decreased to 'Y', the created
network cannot be deleted due to the MTU check.

Change-Id: Ia838d2a661c5098f90b58b2cb31557f2ebf78868
Closes-Bug: #1713499
This commit is contained in:
Reedip 2017-09-01 06:20:01 +00:00 committed by Slawek Kaplonski
parent c4ea8ba82b
commit 006113e3bf
5 changed files with 79 additions and 4 deletions

View File

@ -1937,7 +1937,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# change in segments could affect resulting network mtu, so let's # change in segments could affect resulting network mtu, so let's
# recalculate it # recalculate it
network_db = self._get_network(context, network_id) network_db = self._get_network(context, network_id)
network_db.mtu = self._get_network_mtu(network_db) network_db.mtu = self._get_network_mtu(network_db,
validate=(event != events.PRECOMMIT_DELETE))
network_db.save(session=context.session) network_db.save(session=context.session)
try: try:

View File

@ -57,6 +57,11 @@ class ClientFixture(fixtures.Fixture):
resp = update(id, body=body) resp = update(id, body=body)
return resp[resource_type] return resp[resource_type]
def _delete_resource(self, resource_type, id):
delete = getattr(self.client, 'delete_%s' % resource_type)
return delete(id)
def create_router(self, tenant_id, name=None, ha=False, def create_router(self, tenant_id, name=None, ha=False,
external_network=None): external_network=None):
resource_type = 'router' resource_type = 'router'
@ -70,7 +75,7 @@ class ClientFixture(fixtures.Fixture):
def create_network(self, tenant_id, name=None, external=False, def create_network(self, tenant_id, name=None, external=False,
network_type=None, segmentation_id=None, network_type=None, segmentation_id=None,
physical_network=None): physical_network=None, mtu=None):
resource_type = 'network' resource_type = 'network'
name = name or utils.get_rand_name(prefix=resource_type) name = name or utils.get_rand_name(prefix=resource_type)
@ -83,12 +88,17 @@ class ClientFixture(fixtures.Fixture):
spec['provider:network_type'] = network_type spec['provider:network_type'] = network_type
if physical_network is not None: if physical_network is not None:
spec['provider:physical_network'] = physical_network spec['provider:physical_network'] = physical_network
if mtu is not None:
spec['mtu'] = mtu
return self._create_resource(resource_type, spec) return self._create_resource(resource_type, spec)
def update_network(self, id, **kwargs): def update_network(self, id, **kwargs):
return self._update_resource('network', id, kwargs) return self._update_resource('network', id, kwargs)
def delete_network(self, id):
return self._delete_resource('network', id)
def create_subnet(self, tenant_id, network_id, def create_subnet(self, tenant_id, network_id,
cidr, gateway_ip=None, name=None, enable_dhcp=True, cidr, gateway_ip=None, name=None, enable_dhcp=True,
ipv6_address_mode='slaac', ipv6_ra_mode='slaac'): ipv6_address_mode='slaac', ipv6_ra_mode='slaac'):

View File

@ -61,6 +61,7 @@ class NeutronConfigFixture(ConfigFixture):
'service_plugins': env_desc.service_plugins, 'service_plugins': env_desc.service_plugins,
'auth_strategy': 'noauth', 'auth_strategy': 'noauth',
'debug': 'True', 'debug': 'True',
'global_physnet_mtu': env_desc.global_mtu,
'agent_down_time': str(env_desc.agent_down_time), 'agent_down_time': str(env_desc.agent_down_time),
'transport_url': 'transport_url':
'rabbit://%(user)s:%(password)s@%(host)s:5672/%(vhost)s' % 'rabbit://%(user)s:%(password)s@%(host)s:5672/%(vhost)s' %

View File

@ -18,6 +18,7 @@ from neutronclient.common import exceptions as nc_exc
from oslo_config import cfg from oslo_config import cfg
from neutron.agent.linux import ip_lib from neutron.agent.linux import ip_lib
from neutron.common import constants as common_const
from neutron.common import utils as common_utils from neutron.common import utils as common_utils
from neutron.plugins.ml2.drivers.linuxbridge.agent import \ from neutron.plugins.ml2.drivers.linuxbridge.agent import \
linuxbridge_neutron_agent as lb_agent linuxbridge_neutron_agent as lb_agent
@ -36,7 +37,8 @@ class EnvironmentDescription(object):
def __init__(self, network_type='vxlan', l2_pop=True, qos=False, def __init__(self, network_type='vxlan', l2_pop=True, qos=False,
mech_drivers='openvswitch,linuxbridge', mech_drivers='openvswitch,linuxbridge',
service_plugins='router', arp_responder=False, service_plugins='router', arp_responder=False,
agent_down_time=75, router_scheduler=None): agent_down_time=75, router_scheduler=None,
global_mtu=common_const.DEFAULT_NETWORK_MTU):
self.network_type = network_type self.network_type = network_type
self.l2_pop = l2_pop self.l2_pop = l2_pop
self.qos = qos self.qos = qos
@ -45,7 +47,7 @@ class EnvironmentDescription(object):
self.arp_responder = arp_responder self.arp_responder = arp_responder
self.agent_down_time = agent_down_time self.agent_down_time = agent_down_time
self.router_scheduler = router_scheduler self.router_scheduler = router_scheduler
self.global_mtu = global_mtu
self.service_plugins = service_plugins self.service_plugins = service_plugins
if self.qos: if self.qos:
self.service_plugins += ',qos' self.service_plugins += ',qos'

View File

@ -0,0 +1,61 @@
# Copyright 2017 NEC India
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# from neutronclient.common import exceptions
from oslo_utils import uuidutils
from neutron.tests.fullstack import base
from neutron.tests.fullstack.resources import environment
from neutron.tests.unit import testlib_api
load_tests = testlib_api.module_load_tests
class MTUNetworkTestSetup(base.BaseFullStackTestCase):
host_desc = [] # No need to register agents for this test case
def setUp(self):
env = environment.Environment(
environment.EnvironmentDescription(),
self.host_desc)
super(MTUNetworkTestSetup, self).setUp(env)
self.tenant_id = uuidutils.generate_uuid()
def _restart_neutron_server(self, global_mtu):
env = environment.Environment(
environment.EnvironmentDescription(global_mtu=global_mtu),
self.host_desc)
env.test_name = self.get_name()
self.useFixture(env)
env.neutron_server.restart()
class TestMTUScenarios(MTUNetworkTestSetup):
def test_mtu_update_delete_network(self):
network = self.safe_client.create_network(self.tenant_id,
name='mtu-test-network',
mtu=1450)
self.safe_client.update_network(network['id'], mtu=9000)
res = self.safe_client.delete_network(network['id'])
self.assertEqual((), res)
def test_global_physnet_mtu_update_delete_network(self):
network = self.safe_client.create_network(self.tenant_id,
name='mtu-test-network',
mtu=1450)
self._restart_neutron_server(1400)
res = self.safe_client.delete_network(network['id'])
self.assertEqual((), res)