Fix Network QoS rule CLI attrs parsing
Allows to set zero values in the CLI parameters for Network QoS rule. Change-Id: Ie0e045ff4888615d68804fd739d5b995ca11e9a1 Closes-Bug: #1655947
This commit is contained in:
parent
c8c29e8c2e
commit
4b2355b3e3
@ -85,16 +85,16 @@ def _get_attrs(network_client, parsed_args, is_create=False):
|
||||
msg = _('"Create" rule command requires argument "type"')
|
||||
raise exceptions.CommandError(msg)
|
||||
rule_type = parsed_args.type
|
||||
if parsed_args.max_kbps:
|
||||
if parsed_args.max_kbps is not None:
|
||||
attrs['max_kbps'] = parsed_args.max_kbps
|
||||
if parsed_args.max_burst_kbits:
|
||||
if parsed_args.max_burst_kbits is not None:
|
||||
# NOTE(ralonsoh): this parameter must be changed in SDK and then in
|
||||
# Neutron API, from 'max_burst_kbps' to
|
||||
# 'max_burst_kbits'
|
||||
attrs['max_burst_kbps'] = parsed_args.max_burst_kbits
|
||||
if parsed_args.dscp_mark:
|
||||
if parsed_args.dscp_mark is not None:
|
||||
attrs['dscp_mark'] = parsed_args.dscp_mark
|
||||
if parsed_args.min_kbps:
|
||||
if parsed_args.min_kbps is not None:
|
||||
attrs['min_kbps'] = parsed_args.min_kbps
|
||||
if parsed_args.ingress:
|
||||
attrs['direction'] = 'ingress'
|
||||
|
@ -523,6 +523,16 @@ class TestSetNetworkQosRuleMinimumBandwidth(TestNetworkQosRule):
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_set_min_kbps(self):
|
||||
self._set_min_kbps()
|
||||
|
||||
def test_set_min_kbps_to_zero(self):
|
||||
self._set_min_kbps(min_kbps=0)
|
||||
|
||||
def _set_min_kbps(self, min_kbps=None):
|
||||
if min_kbps:
|
||||
previous_min_kbps = self.new_rule.min_kbps
|
||||
self.new_rule.min_kbps = min_kbps
|
||||
|
||||
arglist = [
|
||||
'--min-kbps', str(self.new_rule.min_kbps),
|
||||
self.new_rule.qos_policy_id,
|
||||
@ -544,6 +554,9 @@ class TestSetNetworkQosRuleMinimumBandwidth(TestNetworkQosRule):
|
||||
self.new_rule, self.qos_policy.id, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
if min_kbps:
|
||||
self.new_rule.min_kbps = previous_min_kbps
|
||||
|
||||
def test_set_wrong_options(self):
|
||||
arglist = [
|
||||
'--max-kbps', str(10000),
|
||||
@ -604,6 +617,16 @@ class TestSetNetworkQosRuleDSCPMarking(TestNetworkQosRule):
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_set_dscp_mark(self):
|
||||
self._set_dscp_mark()
|
||||
|
||||
def test_set_dscp_mark_to_zero(self):
|
||||
self._set_dscp_mark(dscp_mark=0)
|
||||
|
||||
def _set_dscp_mark(self, dscp_mark=None):
|
||||
if dscp_mark:
|
||||
previous_dscp_mark = self.new_rule.dscp_mark
|
||||
self.new_rule.dscp_mark = dscp_mark
|
||||
|
||||
arglist = [
|
||||
'--dscp-mark', str(self.new_rule.dscp_mark),
|
||||
self.new_rule.qos_policy_id,
|
||||
@ -625,6 +648,9 @@ class TestSetNetworkQosRuleDSCPMarking(TestNetworkQosRule):
|
||||
self.new_rule, self.qos_policy.id, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
if dscp_mark:
|
||||
self.new_rule.dscp_mark = previous_dscp_mark
|
||||
|
||||
def test_set_wrong_options(self):
|
||||
arglist = [
|
||||
'--max-kbps', str(10000),
|
||||
@ -685,6 +711,16 @@ class TestSetNetworkQosRuleBandwidthLimit(TestNetworkQosRule):
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_set_max_kbps(self):
|
||||
self._set_max_kbps()
|
||||
|
||||
def test_set_max_kbps_to_zero(self):
|
||||
self._set_max_kbps(max_kbps=0)
|
||||
|
||||
def _set_max_kbps(self, max_kbps=None):
|
||||
if max_kbps:
|
||||
previous_max_kbps = self.new_rule.max_kbps
|
||||
self.new_rule.max_kbps = max_kbps
|
||||
|
||||
arglist = [
|
||||
'--max-kbps', str(self.new_rule.max_kbps),
|
||||
self.new_rule.qos_policy_id,
|
||||
@ -706,7 +742,20 @@ class TestSetNetworkQosRuleBandwidthLimit(TestNetworkQosRule):
|
||||
self.new_rule, self.qos_policy.id, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
if max_kbps:
|
||||
self.new_rule.max_kbps = previous_max_kbps
|
||||
|
||||
def test_set_max_burst_kbits(self):
|
||||
self._set_max_burst_kbits()
|
||||
|
||||
def test_set_max_burst_kbits_to_zero(self):
|
||||
self._set_max_burst_kbits(max_burst_kbits=0)
|
||||
|
||||
def _set_max_burst_kbits(self, max_burst_kbits=None):
|
||||
if max_burst_kbits:
|
||||
previous_max_burst_kbits = self.new_rule.max_burst_kbits
|
||||
self.new_rule.max_burst_kbits = max_burst_kbits
|
||||
|
||||
arglist = [
|
||||
'--max-burst-kbits', str(self.new_rule.max_burst_kbits),
|
||||
self.new_rule.qos_policy_id,
|
||||
@ -728,6 +777,9 @@ class TestSetNetworkQosRuleBandwidthLimit(TestNetworkQosRule):
|
||||
self.new_rule, self.qos_policy.id, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
if max_burst_kbits:
|
||||
self.new_rule.max_burst_kbits = previous_max_burst_kbits
|
||||
|
||||
def test_set_wrong_options(self):
|
||||
arglist = [
|
||||
'--min-kbps', str(10000),
|
||||
|
Loading…
x
Reference in New Issue
Block a user