Add qos rule validation for network

Minimum bandwidth QoS rule is only applicable for the network
which is backed by physical networks.
When updating network policy on network without port
will raise exception.

Partial-Bug: #1913180
Change-Id: I6b57f7ce6d411be388c63b87f2c75f2de703cc97
This commit is contained in:
Nurmatov Mamatisa 2021-02-04 15:27:27 +03:00
parent 4632e29a41
commit 2dabcc5cf7
2 changed files with 16 additions and 0 deletions

View File

@ -69,6 +69,11 @@ class QosRuleNotSupported(e.Conflict):
message = _("Rule %(rule_type)s is not supported by port %(port_id)s")
class QosRuleNotSupportedByNetwork(e.Conflict):
message = _("Rule %(rule_type)s is not supported "
"by network %(network_id)s")
class QoSRuleParameterConflict(e.Conflict):
message = _("Unable to add the rule with value %(rule_value)s to the "
"policy %(policy_id)s as the existing rule of type "

View File

@ -109,6 +109,17 @@ class DriverBase(object):
"""
return True
def validate_rule_for_network(self, context, rule, network_id):
"""Return True/False for valid/invalid.
This is only meant to be used when a rule is compatible
with some networks but not with others (depending on
network properties).
Returns True by default for backwards compatibility.
"""
return True
def create_policy(self, context, policy):
"""Create policy invocation.