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
This commit is contained in:
Tom Stappaerts 2019-10-15 10:58:46 +02:00
parent 3e8abb9a8f
commit f711090ed3
2 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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)