Browse Source

Check mtu on network update

When creating a network the mtu of the network is
checked against the maximum mtu value.
This should also be done on network update.

Change-Id: Ie7ea79cb753f360bb0bca7df8484710b5d32ccf7
Closes-Bug: #1848152
changes/56/688656/5
Tom Stappaerts 2 years ago
parent
commit
f711090ed3
  1. 3
      neutron/plugins/ml2/plugin.py
  2. 14
      neutron/tests/fullstack/test_mtu.py

3
neutron/plugins/ml2/plugin.py

@ -1097,8 +1097,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
# removed in Queens when we populate all mtu attributes and
# enforce it's not nullable on database level
db_network.mtu is None):
db_network.mtu = self._get_network_mtu(db_network,
validate=False)
db_network.mtu = self._get_network_mtu(db_network)
# agents should now update all ports to reflect new MTU
need_network_update_notify = True

14
neutron/tests/fullstack/test_mtu.py

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
# from neutronclient.common import exceptions
from neutronclient.common import exceptions
from oslo_utils import uuidutils
from neutron.tests.fullstack import base
@ -44,11 +44,19 @@ class MTUNetworkTestSetup(base.BaseFullStackTestCase):
class TestMTUScenarios(MTUNetworkTestSetup):
def test_mtu_update_delete_network(self):
def test_mtu_update_network_neg(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)
self.assertRaises(exceptions.BadRequest,
self.safe_client.update_network,
network['id'], mtu=9000)
def test_mtu_update_delete_network(self):
network = self.safe_client.create_network(self.tenant_id,
name='mtu-test-network',
mtu=1200)
self.safe_client.update_network(network['id'], mtu=1450)
res = self.safe_client.delete_network(network['id'])
self.assertEqual((), res)

Loading…
Cancel
Save