NSX|V3: Fail on unsupported QoS rules
The NSX plugin does not support minimum BW rules. This patch fails validation to prevent the creation of such rules. Change-Id: I293dd5b6c659855bb939912370d72cdfd228a338
This commit is contained in:
parent
04bd9c0b55
commit
5a52317eac
@ -175,8 +175,11 @@ class QosNotificationsHandler(object):
|
|||||||
egress_bw_rule = rule
|
egress_bw_rule = rule
|
||||||
else:
|
else:
|
||||||
ingress_bw_rule = rule
|
ingress_bw_rule = rule
|
||||||
else:
|
elif rule.rule_type == qos_consts.RULE_TYPE_DSCP_MARKING:
|
||||||
dscp_rule = rule
|
dscp_rule = rule
|
||||||
|
else:
|
||||||
|
LOG.warning("The NSX-V3 plugin does not support QoS rule of "
|
||||||
|
"type %s", rule.rule_type)
|
||||||
|
|
||||||
# the NSX direction is opposite to the neutron direction
|
# the NSX direction is opposite to the neutron direction
|
||||||
(ingress_bw_enabled, ingress_burst_size, ingress_peak_bw,
|
(ingress_bw_enabled, ingress_burst_size, ingress_peak_bw,
|
||||||
@ -203,3 +206,10 @@ class QosNotificationsHandler(object):
|
|||||||
"""Raise an exception if the rule values are not supported"""
|
"""Raise an exception if the rule values are not supported"""
|
||||||
if rule.rule_type == qos_consts.RULE_TYPE_BANDWIDTH_LIMIT:
|
if rule.rule_type == qos_consts.RULE_TYPE_BANDWIDTH_LIMIT:
|
||||||
self._validate_bw_values(rule)
|
self._validate_bw_values(rule)
|
||||||
|
elif rule.rule_type == qos_consts.RULE_TYPE_DSCP_MARKING:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
msg = (_("The NSX-V3 plugin does not support QoS rule of type "
|
||||||
|
"%s") % rule.rule_type)
|
||||||
|
LOG.error(msg)
|
||||||
|
raise n_exc.InvalidInput(error_message=msg)
|
||||||
|
@ -305,6 +305,7 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
|
|||||||
dscp_mark = rule_dict['dscp_mark']
|
dscp_mark = rule_dict['dscp_mark']
|
||||||
update_profile.assert_called_once_with(
|
update_profile.assert_called_once_with(
|
||||||
self.fake_profile_id,
|
self.fake_profile_id,
|
||||||
|
|
||||||
ingress_bw_enabled=False,
|
ingress_bw_enabled=False,
|
||||||
ingress_burst_size=None,
|
ingress_burst_size=None,
|
||||||
ingress_peak_bandwidth=None,
|
ingress_peak_bandwidth=None,
|
||||||
@ -317,6 +318,30 @@ class TestQosNsxV3Notification(base.BaseQosTestCase,
|
|||||||
qos_marking='untrusted'
|
qos_marking='untrusted'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch.object(QoSPolicyObject, '_reload_rules')
|
||||||
|
def test_minimum_bw_rule_create_profile(self, *mocks):
|
||||||
|
# Minimum BW rules are not supported
|
||||||
|
policy = QoSPolicyObject(
|
||||||
|
self.ctxt, **self.policy_data['policy'])
|
||||||
|
min_bw_rule_data = {
|
||||||
|
'minimum_bandwidth_rule': {'id': uuidutils.generate_uuid(),
|
||||||
|
'min_kbps': 10,
|
||||||
|
'direction': 'egress'}}
|
||||||
|
min_bw_rule = obj_reg.new_instance(
|
||||||
|
'QosMinimumBandwidthRule', self.ctxt,
|
||||||
|
**min_bw_rule_data['minimum_bandwidth_rule'])
|
||||||
|
# add a rule to the policy
|
||||||
|
setattr(policy, "rules", [min_bw_rule])
|
||||||
|
with mock.patch('neutron.objects.qos.policy.QosPolicy.get_object',
|
||||||
|
return_value=policy),\
|
||||||
|
mock.patch('neutron.objects.db.api.'
|
||||||
|
'update_object', return_value=self.dscp_rule_data):
|
||||||
|
self.assertRaises(
|
||||||
|
exceptions.DriverCallError,
|
||||||
|
self.qos_plugin.update_policy_minimum_bandwidth_rule,
|
||||||
|
self.ctxt, min_bw_rule.id,
|
||||||
|
policy.id, min_bw_rule_data)
|
||||||
|
|
||||||
def test_rule_delete_profile(self):
|
def test_rule_delete_profile(self):
|
||||||
# test the switch profile update when a QoS rule is deleted
|
# test the switch profile update when a QoS rule is deleted
|
||||||
_policy = QoSPolicyObject(
|
_policy = QoSPolicyObject(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user