NSX|V3+P: Support QoS on ENS networks
Depending on the backend version Change-Id: I33af8879a519a896b1d19e3dbbc0f007e3110235
This commit is contained in:
parent
f58b71ce73
commit
48821d139c
@ -545,6 +545,9 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
raise n_exc.InvalidInput(error_message=err_msg)
|
raise n_exc.InvalidInput(error_message=err_msg)
|
||||||
|
|
||||||
def _validate_ens_create_port(self, context, port_data):
|
def _validate_ens_create_port(self, context, port_data):
|
||||||
|
if self._ens_qos_supported():
|
||||||
|
return
|
||||||
|
|
||||||
qos_selected = validators.is_attr_set(port_data.get(
|
qos_selected = validators.is_attr_set(port_data.get(
|
||||||
qos_consts.QOS_POLICY_ID))
|
qos_consts.QOS_POLICY_ID))
|
||||||
if qos_selected:
|
if qos_selected:
|
||||||
@ -716,7 +719,7 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
raise nsx_exc.QoSOnExternalNet()
|
raise nsx_exc.QoSOnExternalNet()
|
||||||
self._assert_on_illegal_port_with_qos(device_owner)
|
self._assert_on_illegal_port_with_qos(device_owner)
|
||||||
is_ens_tz_port = self._is_ens_tz_port(context, original_port)
|
is_ens_tz_port = self._is_ens_tz_port(context, original_port)
|
||||||
if is_ens_tz_port:
|
if is_ens_tz_port and not self._ens_qos_supported():
|
||||||
err_msg = _("Cannot configure QOS on ENS networks")
|
err_msg = _("Cannot configure QOS on ENS networks")
|
||||||
raise n_exc.InvalidInput(error_message=err_msg)
|
raise n_exc.InvalidInput(error_message=err_msg)
|
||||||
|
|
||||||
@ -833,6 +836,8 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
fields) for network in networks])
|
fields) for network in networks])
|
||||||
|
|
||||||
def _assert_on_ens_with_qos(self, net_data):
|
def _assert_on_ens_with_qos(self, net_data):
|
||||||
|
if self._ens_qos_supported():
|
||||||
|
return
|
||||||
qos_id = net_data.get(qos_consts.QOS_POLICY_ID)
|
qos_id = net_data.get(qos_consts.QOS_POLICY_ID)
|
||||||
if validators.is_attr_set(qos_id):
|
if validators.is_attr_set(qos_id):
|
||||||
err_msg = _("Cannot configure QOS on ENS networks")
|
err_msg = _("Cannot configure QOS on ENS networks")
|
||||||
@ -880,6 +885,10 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
|||||||
"""Should be implemented by each plugin"""
|
"""Should be implemented by each plugin"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _ens_qos_supported(self):
|
||||||
|
"""Should be implemented by each plugin"""
|
||||||
|
pass
|
||||||
|
|
||||||
def _has_native_dhcp_metadata(self):
|
def _has_native_dhcp_metadata(self):
|
||||||
"""Should be implemented by each plugin"""
|
"""Should be implemented by each plugin"""
|
||||||
pass
|
pass
|
||||||
|
@ -598,6 +598,10 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||||||
"""
|
"""
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _ens_qos_supported(self):
|
||||||
|
return self.nsxpolicy.feature_supported(
|
||||||
|
nsxlib_consts.FEATURE_ENS_WITH_QOS)
|
||||||
|
|
||||||
def _validate_ens_net_portsecurity(self, net_data):
|
def _validate_ens_net_portsecurity(self, net_data):
|
||||||
"""ENS security features are always enabled on NSX versions which
|
"""ENS security features are always enabled on NSX versions which
|
||||||
the policy plugin supports.
|
the policy plugin supports.
|
||||||
|
@ -1021,6 +1021,10 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
|||||||
return self.nsxlib.feature_supported(
|
return self.nsxlib.feature_supported(
|
||||||
nsxlib_consts.FEATURE_ENS_WITH_SEC)
|
nsxlib_consts.FEATURE_ENS_WITH_SEC)
|
||||||
|
|
||||||
|
def _ens_qos_supported(self):
|
||||||
|
return self.nsxlib.feature_supported(
|
||||||
|
nsxlib_consts.FEATURE_ENS_WITH_QOS)
|
||||||
|
|
||||||
def _validate_ens_net_portsecurity(self, net_data):
|
def _validate_ens_net_portsecurity(self, net_data):
|
||||||
"""Validate/Update the port security of the new network for ENS TZ"""
|
"""Validate/Update the port security of the new network for ENS TZ"""
|
||||||
if not self._ens_psec_supported():
|
if not self._ens_psec_supported():
|
||||||
|
@ -550,13 +550,14 @@ class NsxPTestNetworks(test_db_base_plugin_v2.TestNetworksV2,
|
|||||||
'tenant_id': 'some_tenant',
|
'tenant_id': 'some_tenant',
|
||||||
'provider:network_type': 'flat',
|
'provider:network_type': 'flat',
|
||||||
'provider:physical_network': 'xxx',
|
'provider:physical_network': 'xxx',
|
||||||
|
'admin_state_up': True,
|
||||||
|
'shared': False,
|
||||||
'qos_policy_id': policy_id,
|
'qos_policy_id': policy_id,
|
||||||
'port_security_enabled': False}}
|
'port_security_enabled': False}}
|
||||||
with mock_ens, mock_tz, mock_tt, mock.patch.object(
|
with mock_ens, mock_tz, mock_tt, mock.patch.object(
|
||||||
self.plugin, '_validate_qos_policy_id'):
|
self.plugin, '_validate_qos_policy_id'):
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
res = self.plugin.create_network(context.get_admin_context(), data)
|
||||||
self.plugin.create_network,
|
self.assertEqual(policy_id, res['qos_policy_id'])
|
||||||
context.get_admin_context(), data)
|
|
||||||
|
|
||||||
def test_update_ens_network_with_qos(self):
|
def test_update_ens_network_with_qos(self):
|
||||||
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
cfg.CONF.set_override('ens_support', True, 'nsx_v3')
|
||||||
@ -589,10 +590,10 @@ class NsxPTestNetworks(test_db_base_plugin_v2.TestNetworksV2,
|
|||||||
'port_security_enabled': False,
|
'port_security_enabled': False,
|
||||||
'tenant_id': 'some_tenant',
|
'tenant_id': 'some_tenant',
|
||||||
'qos_policy_id': policy_id}}
|
'qos_policy_id': policy_id}}
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
res = self.plugin.update_network(
|
||||||
self.plugin.update_network,
|
|
||||||
context.get_admin_context(),
|
context.get_admin_context(),
|
||||||
network['id'], data)
|
network['id'], data)
|
||||||
|
self.assertEqual(policy_id, res['qos_policy_id'])
|
||||||
|
|
||||||
|
|
||||||
class NsxPTestPorts(common_v3.NsxV3TestPorts,
|
class NsxPTestPorts(common_v3.NsxV3TestPorts,
|
||||||
@ -787,8 +788,8 @@ class NsxPTestPorts(common_v3.NsxV3TestPorts,
|
|||||||
# Cannot add qos policy to this type of port
|
# Cannot add qos policy to this type of port
|
||||||
with mock_ens, mock_tz, mock_tt, \
|
with mock_ens, mock_tz, mock_tt, \
|
||||||
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
res = self.plugin.create_port(self.ctx, data)
|
||||||
self.plugin.create_port, self.ctx, data)
|
self.assertEqual(policy_id, res['qos_policy_id'])
|
||||||
|
|
||||||
def test_create_port_with_mac_learning_true(self):
|
def test_create_port_with_mac_learning_true(self):
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
|
@ -582,6 +582,8 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
mock_tt = mock.patch('vmware_nsxlib.v3'
|
mock_tt = mock.patch('vmware_nsxlib.v3'
|
||||||
'.core_resources.NsxLibTransportZone'
|
'.core_resources.NsxLibTransportZone'
|
||||||
'.get_transport_type', return_value='VLAN')
|
'.get_transport_type', return_value='VLAN')
|
||||||
|
mock_ver = mock.patch("vmware_nsxlib.v3.NsxLib.get_version",
|
||||||
|
return_value='2.4.0')
|
||||||
policy_id = uuidutils.generate_uuid()
|
policy_id = uuidutils.generate_uuid()
|
||||||
data = {'network': {
|
data = {'network': {
|
||||||
'name': 'qos_net',
|
'name': 'qos_net',
|
||||||
@ -590,7 +592,7 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
'provider:physical_network': 'xxx',
|
'provider:physical_network': 'xxx',
|
||||||
'qos_policy_id': policy_id,
|
'qos_policy_id': policy_id,
|
||||||
'port_security_enabled': False}}
|
'port_security_enabled': False}}
|
||||||
with mock_ens, mock_tz, mock_tt, mock.patch.object(
|
with mock_ens, mock_tz, mock_tt, mock_ver, mock.patch.object(
|
||||||
self.plugin, '_validate_qos_policy_id'):
|
self.plugin, '_validate_qos_policy_id'):
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
self.assertRaises(n_exc.InvalidInput,
|
||||||
self.plugin.create_network,
|
self.plugin.create_network,
|
||||||
@ -607,6 +609,8 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
mock_tt = mock.patch('vmware_nsxlib.v3'
|
mock_tt = mock.patch('vmware_nsxlib.v3'
|
||||||
'.core_resources.NsxLibTransportZone'
|
'.core_resources.NsxLibTransportZone'
|
||||||
'.get_transport_type', return_value='VLAN')
|
'.get_transport_type', return_value='VLAN')
|
||||||
|
mock_ver = mock.patch("vmware_nsxlib.v3.NsxLib.get_version",
|
||||||
|
return_value='2.4.0')
|
||||||
data = {'network': {
|
data = {'network': {
|
||||||
'name': 'qos_net',
|
'name': 'qos_net',
|
||||||
'tenant_id': 'some_tenant',
|
'tenant_id': 'some_tenant',
|
||||||
@ -615,7 +619,7 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
|
|||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'shared': False,
|
'shared': False,
|
||||||
'port_security_enabled': False}}
|
'port_security_enabled': False}}
|
||||||
with mock_ens, mock_tz, mock_tt,\
|
with mock_ens, mock_tz, mock_tt, mock_ver,\
|
||||||
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
||||||
network = self.plugin.create_network(context.get_admin_context(),
|
network = self.plugin.create_network(context.get_admin_context(),
|
||||||
data)
|
data)
|
||||||
@ -1207,6 +1211,8 @@ class TestPortsV2(common_v3.NsxV3SubnetMixin,
|
|||||||
'.core_resources.NsxLibTransportZone'
|
'.core_resources.NsxLibTransportZone'
|
||||||
'.get_transport_type',
|
'.get_transport_type',
|
||||||
return_value='VLAN')
|
return_value='VLAN')
|
||||||
|
mock_ver = mock.patch("vmware_nsxlib.v3.NsxLib.get_version",
|
||||||
|
return_value='2.4.0')
|
||||||
data = {'port': {
|
data = {'port': {
|
||||||
'network_id': network['network']['id'],
|
'network_id': network['network']['id'],
|
||||||
'tenant_id': self._tenant_id,
|
'tenant_id': self._tenant_id,
|
||||||
@ -1220,7 +1226,7 @@ class TestPortsV2(common_v3.NsxV3SubnetMixin,
|
|||||||
'qos_policy_id': policy_id}
|
'qos_policy_id': policy_id}
|
||||||
}
|
}
|
||||||
# Cannot add qos policy to this type of port
|
# Cannot add qos policy to this type of port
|
||||||
with mock_ens, mock_tz, mock_tt,\
|
with mock_ens, mock_tz, mock_tt, mock_ver,\
|
||||||
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
||||||
self.assertRaises(n_exc.InvalidInput,
|
self.assertRaises(n_exc.InvalidInput,
|
||||||
self.plugin.create_port, self.ctx, data)
|
self.plugin.create_port, self.ctx, data)
|
||||||
@ -1273,6 +1279,8 @@ class TestPortsV2(common_v3.NsxV3SubnetMixin,
|
|||||||
'.core_resources.NsxLibTransportZone'
|
'.core_resources.NsxLibTransportZone'
|
||||||
'.get_transport_type',
|
'.get_transport_type',
|
||||||
return_value='VLAN')
|
return_value='VLAN')
|
||||||
|
mock_ver = mock.patch("vmware_nsxlib.v3.NsxLib.get_version",
|
||||||
|
return_value='2.4.0')
|
||||||
data = {'port': {
|
data = {'port': {
|
||||||
'network_id': network['network']['id'],
|
'network_id': network['network']['id'],
|
||||||
'tenant_id': self._tenant_id,
|
'tenant_id': self._tenant_id,
|
||||||
@ -1284,7 +1292,7 @@ class TestPortsV2(common_v3.NsxV3SubnetMixin,
|
|||||||
'port_security_enabled': False,
|
'port_security_enabled': False,
|
||||||
'mac_address': '00:00:00:00:00:01'}
|
'mac_address': '00:00:00:00:00:01'}
|
||||||
}
|
}
|
||||||
with mock_ens, mock_tz, mock_tt,\
|
with mock_ens, mock_tz, mock_tt, mock_ver,\
|
||||||
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
mock.patch.object(self.plugin, '_validate_qos_policy_id'):
|
||||||
port = self.plugin.create_port(self.ctx, data)
|
port = self.plugin.create_port(self.ctx, data)
|
||||||
data['port'] = {'qos_policy_id': policy_id}
|
data['port'] = {'qos_policy_id': policy_id}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user