Merge "Need to check MTU setting for the ethernet type subinterface"
This commit is contained in:
commit
409cd1d40c
|
@ -1287,7 +1287,8 @@ def _check_interface_data(op, interface, ihost, existing_interface,
|
|||
|
||||
# check MTU
|
||||
if interface['iftype'] in [constants.INTERFACE_TYPE_VLAN,
|
||||
constants.INTERFACE_TYPE_VF]:
|
||||
constants.INTERFACE_TYPE_VF,
|
||||
constants.INTERFACE_TYPE_ETHERNET]:
|
||||
interface_mtu = interface['imtu']
|
||||
for name in interface['uses']:
|
||||
parent = pecan.request.dbapi.iinterface_get(name, ihost_uuid)
|
||||
|
@ -1295,7 +1296,7 @@ def _check_interface_data(op, interface, ihost, existing_interface,
|
|||
msg = _("Interface MTU (%s) cannot be larger than MTU of "
|
||||
"underlying interface (%s)" % (interface_mtu, parent['imtu']))
|
||||
raise wsme.exc.ClientSideError(msg)
|
||||
elif interface['used_by']:
|
||||
if interface['used_by']:
|
||||
mtus = _get_interface_mtus(ihost_uuid, interface)
|
||||
for mtu in mtus:
|
||||
if int(interface['imtu']) < int(mtu):
|
||||
|
|
|
@ -1400,6 +1400,27 @@ class TestPatchMixin(object):
|
|||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
# Expected error: Interface MTU ___ cannot be larger than MTU of underlying
|
||||
# interface ___
|
||||
def test_ethernet_mtu_smaller_than_users(self):
|
||||
port, lower_iface = self._create_sriov(
|
||||
'sriov', host=self.worker, sriov_numvfs=4)
|
||||
upper = dbutils.create_test_interface(
|
||||
forihostid='2',
|
||||
ihost_uuid=self.worker.uuid,
|
||||
ifname='pxeboot0',
|
||||
networktype=constants.NETWORK_TYPE_PXEBOOT,
|
||||
ifclass=constants.INTERFACE_CLASS_PLATFORM,
|
||||
iftype=constants.INTERFACE_TYPE_ETHERNET,
|
||||
uses=['sriov'],
|
||||
imtu=1500)
|
||||
response = self.patch_dict_json(
|
||||
'%s' % self._get_path(upper['uuid']), imtu=1800,
|
||||
expect_errors=True)
|
||||
self.assertEqual(http_client.BAD_REQUEST, response.status_int)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def _create_sriov_vf_driver_valid(self, vf_driver, expect_errors=False):
|
||||
interface = dbutils.create_test_interface(forihostid=self.worker.id,
|
||||
datanetworks='group0-data0')
|
||||
|
|
Loading…
Reference in New Issue