Adding DSCP marking changes to neutronclient
The following patch implements the DSCP QoS support in neutronclient. This patch also removes some hardcoded values from bandwidth limit rule. Supporting CLI/Network guide docs are located here: I881b8f5bc9024c20275bc56062de72a1c70c8321 Co-Authored-By: Margaret Frances <margaret_frances@cable.comcast.com> Change-Id: I25ad60c1b9a66e568276a772b8c496987d9f8299 Depends-On: Ic3baefe176df05f049a2e06529c58fd65fe6b419 Partial-Bug: #1468353
This commit is contained in:
@@ -56,7 +56,7 @@ class CreateQoSBandwidthLimitRule(qos_rule.QosRuleMixin,
|
|||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
body = {}
|
body = {}
|
||||||
update_bandwidth_limit_args2body(parsed_args, body)
|
update_bandwidth_limit_args2body(parsed_args, body)
|
||||||
return {'bandwidth_limit_rule': body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
class ListQoSBandwidthLimitRules(qos_rule.QosRuleMixin,
|
class ListQoSBandwidthLimitRules(qos_rule.QosRuleMixin,
|
||||||
@@ -64,16 +64,10 @@ class ListQoSBandwidthLimitRules(qos_rule.QosRuleMixin,
|
|||||||
"""List all qos bandwidth limit rules belonging to the specified policy."""
|
"""List all qos bandwidth limit rules belonging to the specified policy."""
|
||||||
|
|
||||||
resource = BANDWIDTH_LIMIT_RULE_RESOURCE
|
resource = BANDWIDTH_LIMIT_RULE_RESOURCE
|
||||||
|
|
||||||
_formatters = {}
|
_formatters = {}
|
||||||
pagination_support = True
|
pagination_support = True
|
||||||
sorting_support = True
|
sorting_support = True
|
||||||
|
|
||||||
def args2body(self, parsed_args):
|
|
||||||
body = {}
|
|
||||||
qos_rule.update_policy_args2body(parsed_args, body)
|
|
||||||
return {'qos_rule': body}
|
|
||||||
|
|
||||||
|
|
||||||
class ShowQoSBandwidthLimitRule(qos_rule.QosRuleMixin, neutronv20.ShowCommand):
|
class ShowQoSBandwidthLimitRule(qos_rule.QosRuleMixin, neutronv20.ShowCommand):
|
||||||
"""Show information about the given qos bandwidth limit rule."""
|
"""Show information about the given qos bandwidth limit rule."""
|
||||||
@@ -96,7 +90,7 @@ class UpdateQoSBandwidthLimitRule(qos_rule.QosRuleMixin,
|
|||||||
def args2body(self, parsed_args):
|
def args2body(self, parsed_args):
|
||||||
body = {}
|
body = {}
|
||||||
update_bandwidth_limit_args2body(parsed_args, body)
|
update_bandwidth_limit_args2body(parsed_args, body)
|
||||||
return {'bandwidth_limit_rule': body}
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
class DeleteQoSBandwidthLimitRule(qos_rule.QosRuleMixin,
|
class DeleteQoSBandwidthLimitRule(qos_rule.QosRuleMixin,
|
||||||
|
112
neutronclient/neutron/v2_0/qos/dscp_marking_rule.py
Normal file
112
neutronclient/neutron/v2_0/qos/dscp_marking_rule.py
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
# Copyright 2016 Comcast, Inc.
|
||||||
|
# All Rights Reserved
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
from neutronclient._i18n import _
|
||||||
|
from neutronclient.common import exceptions
|
||||||
|
from neutronclient.neutron import v2_0 as neutronv20
|
||||||
|
from neutronclient.neutron.v2_0.qos import rule as qos_rule
|
||||||
|
|
||||||
|
|
||||||
|
DSCP_MARKING_RESOURCE = 'dscp_marking_rule'
|
||||||
|
# DSCP DETAILS
|
||||||
|
# 0 - none | 8 - cs1 | 10 - af11 | 12 - af12 | 14 - af13 |
|
||||||
|
# 16 - cs2 | 18 - af21 | 20 - af22 | 22 - af23 | 24 - cs3 |
|
||||||
|
# 26 - af31 | 28 - af32 | 30 - af33 | 32 - cs4 | 34 - af41 |
|
||||||
|
# 36 - af42 | 38 - af43 | 40 - cs5 | 46 - ef | 48 - cs6 |
|
||||||
|
# 56 - cs7
|
||||||
|
|
||||||
|
DSCP_VALID_MARKS = [0, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32,
|
||||||
|
34, 36, 38, 40, 46, 48, 56]
|
||||||
|
|
||||||
|
|
||||||
|
def add_dscp_marking_arguments(parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'--dscp-mark',
|
||||||
|
required=True,
|
||||||
|
type=str,
|
||||||
|
help=_('DSCP mark: value can be 0, even numbers from 8-56, \
|
||||||
|
excluding 42, 44, 50, 52, and 54.'))
|
||||||
|
|
||||||
|
|
||||||
|
def update_dscp_args2body(parsed_args, body):
|
||||||
|
dscp_mark = parsed_args.dscp_mark
|
||||||
|
if int(dscp_mark) not in DSCP_VALID_MARKS:
|
||||||
|
raise exceptions.CommandError(_("DSCP mark: %s not supported. "
|
||||||
|
"Please note value can either be 0 "
|
||||||
|
"or any even number from 8-56 "
|
||||||
|
"excluding 42, 44, 50, 52 and "
|
||||||
|
"54.") % dscp_mark)
|
||||||
|
neutronv20.update_dict(parsed_args, body,
|
||||||
|
['dscp_mark'])
|
||||||
|
|
||||||
|
|
||||||
|
class CreateQoSDscpMarkingRule(qos_rule.QosRuleMixin,
|
||||||
|
neutronv20.CreateCommand):
|
||||||
|
"""Create a QoS DSCP marking rule."""
|
||||||
|
|
||||||
|
resource = DSCP_MARKING_RESOURCE
|
||||||
|
|
||||||
|
def add_known_arguments(self, parser):
|
||||||
|
super(CreateQoSDscpMarkingRule, self).add_known_arguments(parser)
|
||||||
|
add_dscp_marking_arguments(parser)
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
body = {}
|
||||||
|
update_dscp_args2body(parsed_args, body)
|
||||||
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
|
class ListQoSDscpMarkingRules(qos_rule.QosRuleMixin,
|
||||||
|
neutronv20.ListCommand):
|
||||||
|
"""List all QoS DSCP marking rules belonging to the specified policy."""
|
||||||
|
|
||||||
|
_formatters = {}
|
||||||
|
pagination_support = True
|
||||||
|
sorting_support = True
|
||||||
|
resource = DSCP_MARKING_RESOURCE
|
||||||
|
|
||||||
|
|
||||||
|
class ShowQoSDscpMarkingRule(qos_rule.QosRuleMixin,
|
||||||
|
neutronv20.ShowCommand):
|
||||||
|
"""Show information about the given qos dscp marking rule."""
|
||||||
|
|
||||||
|
resource = DSCP_MARKING_RESOURCE
|
||||||
|
allow_names = False
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateQoSDscpMarkingRule(qos_rule.QosRuleMixin,
|
||||||
|
neutronv20.UpdateCommand):
|
||||||
|
"""Update the given QoS DSCP marking rule."""
|
||||||
|
|
||||||
|
allow_names = False
|
||||||
|
resource = DSCP_MARKING_RESOURCE
|
||||||
|
|
||||||
|
def add_known_arguments(self, parser):
|
||||||
|
super(UpdateQoSDscpMarkingRule, self).add_known_arguments(parser)
|
||||||
|
add_dscp_marking_arguments(parser)
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
body = {}
|
||||||
|
update_dscp_args2body(parsed_args, body)
|
||||||
|
return {self.resource: body}
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteQoSDscpMarkingRule(qos_rule.QosRuleMixin,
|
||||||
|
neutronv20.DeleteCommand):
|
||||||
|
"""Delete a given qos dscp marking rule."""
|
||||||
|
|
||||||
|
allow_names = False
|
||||||
|
resource = DSCP_MARKING_RESOURCE
|
@@ -48,6 +48,11 @@ class QosRuleMixin(object):
|
|||||||
self.parent_id = qos_policy.get_qos_policy_id(self.get_client(),
|
self.parent_id = qos_policy.get_qos_policy_id(self.get_client(),
|
||||||
parsed_args.policy)
|
parsed_args.policy)
|
||||||
|
|
||||||
|
def args2body(self, parsed_args):
|
||||||
|
body = {}
|
||||||
|
update_policy_args2body(parsed_args, body)
|
||||||
|
return {'qos_rule': body}
|
||||||
|
|
||||||
|
|
||||||
class ListQoSRuleTypes(neutronv20.ListCommand):
|
class ListQoSRuleTypes(neutronv20.ListCommand):
|
||||||
"""List available qos rule types."""
|
"""List available qos rule types."""
|
||||||
|
@@ -72,6 +72,7 @@ from neutronclient.neutron.v2_0.nsx import networkgateway
|
|||||||
from neutronclient.neutron.v2_0.nsx import qos_queue
|
from neutronclient.neutron.v2_0.nsx import qos_queue
|
||||||
from neutronclient.neutron.v2_0 import port
|
from neutronclient.neutron.v2_0 import port
|
||||||
from neutronclient.neutron.v2_0.qos import bandwidth_limit_rule
|
from neutronclient.neutron.v2_0.qos import bandwidth_limit_rule
|
||||||
|
from neutronclient.neutron.v2_0.qos import dscp_marking_rule
|
||||||
from neutronclient.neutron.v2_0.qos import policy as qos_policy
|
from neutronclient.neutron.v2_0.qos import policy as qos_policy
|
||||||
from neutronclient.neutron.v2_0.qos import rule as qos_rule
|
from neutronclient.neutron.v2_0.qos import rule as qos_rule
|
||||||
from neutronclient.neutron.v2_0 import quota
|
from neutronclient.neutron.v2_0 import quota
|
||||||
@@ -394,6 +395,21 @@ COMMAND_V2 = {
|
|||||||
'qos-bandwidth-limit-rule-delete': (
|
'qos-bandwidth-limit-rule-delete': (
|
||||||
bandwidth_limit_rule.DeleteQoSBandwidthLimitRule
|
bandwidth_limit_rule.DeleteQoSBandwidthLimitRule
|
||||||
),
|
),
|
||||||
|
'qos-dscp-marking-rule-create': (
|
||||||
|
dscp_marking_rule.CreateQoSDscpMarkingRule
|
||||||
|
),
|
||||||
|
'qos-dscp-marking-rule-show': (
|
||||||
|
dscp_marking_rule.ShowQoSDscpMarkingRule
|
||||||
|
),
|
||||||
|
'qos-dscp-marking-rule-list': (
|
||||||
|
dscp_marking_rule.ListQoSDscpMarkingRules
|
||||||
|
),
|
||||||
|
'qos-dscp-marking-rule-update': (
|
||||||
|
dscp_marking_rule.UpdateQoSDscpMarkingRule
|
||||||
|
),
|
||||||
|
'qos-dscp-marking-rule-delete': (
|
||||||
|
dscp_marking_rule.DeleteQoSDscpMarkingRule
|
||||||
|
),
|
||||||
'qos-available-rule-types': qos_rule.ListQoSRuleTypes,
|
'qos-available-rule-types': qos_rule.ListQoSRuleTypes,
|
||||||
'flavor-list': flavor.ListFlavor,
|
'flavor-list': flavor.ListFlavor,
|
||||||
'flavor-show': flavor.ShowFlavor,
|
'flavor-show': flavor.ShowFlavor,
|
||||||
|
137
neutronclient/tests/unit/qos/test_cli20_bandwidth_limit_rule.py
Normal file
137
neutronclient/tests/unit/qos/test_cli20_bandwidth_limit_rule.py
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
# Copyright 2015 Huawei Technologies India Pvt Ltd.
|
||||||
|
# All Rights Reserved
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from neutronclient.neutron.v2_0.qos import bandwidth_limit_rule as bw_rule
|
||||||
|
from neutronclient.tests.unit import test_cli20
|
||||||
|
|
||||||
|
|
||||||
|
class CLITestV20QoSBandwidthLimitRuleJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['bandwidth_limit_rule']
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(CLITestV20QoSBandwidthLimitRuleJSON, self).setUp()
|
||||||
|
self.res = 'bandwidth_limit_rule'
|
||||||
|
self.cmd_res = 'qos_bandwidth_limit_rule'
|
||||||
|
self.ress = self.res + 's'
|
||||||
|
self.cmd_ress = self.cmd_res + 's'
|
||||||
|
|
||||||
|
def test_create_bandwidth_limit_rule_with_max_kbps(self):
|
||||||
|
cmd = bw_rule.CreateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
max_kbps = '1337'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = ['--max-kbps', max_kbps, policy_id]
|
||||||
|
position_names = ['max_kbps']
|
||||||
|
position_values = [max_kbps]
|
||||||
|
self._test_create_resource(self.res, cmd, '', my_id, args,
|
||||||
|
position_names, position_values,
|
||||||
|
cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_create_bandwidth_limit_rule_with_max_burst_kbps(self):
|
||||||
|
cmd = bw_rule.CreateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
max_burst_kbps = '1337'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = ['--max-burst-kbps', max_burst_kbps, policy_id]
|
||||||
|
position_names = ['max_burst_kbps']
|
||||||
|
position_values = [max_burst_kbps]
|
||||||
|
self._test_create_resource(self.res, cmd, '', my_id, args,
|
||||||
|
position_names, position_values,
|
||||||
|
cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_create_bandwidth_limit_rule_with_all_params(self):
|
||||||
|
cmd = bw_rule.CreateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
max_kbps = '1337'
|
||||||
|
max_burst_kbps = '1337'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = ['--max-kbps', max_kbps,
|
||||||
|
'--max-burst-kbps', max_burst_kbps,
|
||||||
|
policy_id]
|
||||||
|
position_names = ['max_kbps', 'max_burst_kbps']
|
||||||
|
position_values = [max_kbps, max_burst_kbps]
|
||||||
|
self._test_create_resource(self.res, cmd, '', my_id, args,
|
||||||
|
position_names, position_values,
|
||||||
|
cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_update_bandwidth_limit_rule_with_max_kbps(self):
|
||||||
|
cmd = bw_rule.UpdateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
max_kbps = '1337'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = ['--max-kbps', max_kbps, my_id, policy_id]
|
||||||
|
self._test_update_resource(self.res, cmd, my_id, args,
|
||||||
|
{'max_kbps': max_kbps, },
|
||||||
|
cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_update_bandwidth_limit_rule_with_max_burst_kbps(self):
|
||||||
|
cmd = bw_rule.UpdateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
max_burst_kbps = '1337'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = ['--max-burst-kbps', max_burst_kbps,
|
||||||
|
my_id, policy_id]
|
||||||
|
self._test_update_resource(self.res, cmd, my_id, args,
|
||||||
|
{'max_burst_kbps': max_burst_kbps},
|
||||||
|
cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_update_bandwidth_limit_rule_with_all_params(self):
|
||||||
|
cmd = bw_rule.UpdateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
max_kbps = '1337'
|
||||||
|
max_burst_kbps = '1337'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = ['--max-kbps', max_kbps,
|
||||||
|
'--max-burst-kbps', max_burst_kbps,
|
||||||
|
my_id, policy_id]
|
||||||
|
self._test_update_resource(self.res, cmd, my_id, args,
|
||||||
|
{'max_kbps': max_kbps,
|
||||||
|
'max_burst_kbps': max_burst_kbps},
|
||||||
|
cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_delete_bandwidth_limit_rule(self):
|
||||||
|
cmd = bw_rule.DeleteQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = [my_id, policy_id]
|
||||||
|
self._test_delete_resource(self.res, cmd, my_id, args,
|
||||||
|
cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_show_bandwidth_limit_rule(self):
|
||||||
|
cmd = bw_rule.ShowQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = [self.test_id, policy_id]
|
||||||
|
self._test_show_resource(self.res, cmd, self.test_id, args,
|
||||||
|
[], cmd_resource=self.cmd_res,
|
||||||
|
parent_id=policy_id)
|
91
neutronclient/tests/unit/qos/test_cli20_dscp_marking_rule.py
Normal file
91
neutronclient/tests/unit/qos/test_cli20_dscp_marking_rule.py
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
# Copyright 2016 Comcast Inc.
|
||||||
|
# All Rights Reserved
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from neutronclient.common import exceptions
|
||||||
|
from neutronclient.neutron.v2_0.qos import dscp_marking_rule as dscp_rule
|
||||||
|
from neutronclient.tests.unit import test_cli20
|
||||||
|
|
||||||
|
|
||||||
|
class CLITestV20QoSDscpMarkingRuleJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
|
non_admin_status_resources = ['dscp_marking_rule']
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(CLITestV20QoSDscpMarkingRuleJSON, self).setUp()
|
||||||
|
self.dscp_res = 'dscp_marking_rule'
|
||||||
|
self.dscp_cmd_res = 'qos_dscp_marking_rule'
|
||||||
|
self.dscp_ress = self.dscp_res + 's'
|
||||||
|
self.dscp_cmd_ress = self.dscp_cmd_res + 's'
|
||||||
|
|
||||||
|
def test_create_dscp_marking_rule_with_dscp_mark(self):
|
||||||
|
cmd = dscp_rule.CreateQoSDscpMarkingRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
position_names = ['dscp_mark']
|
||||||
|
valid_dscp_marks = ['0', '56']
|
||||||
|
invalid_dscp_marks = ['-1', '19', '42', '44', '57', '58']
|
||||||
|
for dscp_mark in valid_dscp_marks:
|
||||||
|
args = ['--dscp-mark', dscp_mark, policy_id]
|
||||||
|
position_values = [dscp_mark]
|
||||||
|
self._test_create_resource(self.dscp_res, cmd, '', my_id, args,
|
||||||
|
position_names, position_values,
|
||||||
|
cmd_resource=self.dscp_cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
for dscp_mark in invalid_dscp_marks:
|
||||||
|
args = ['--dscp-mark', dscp_mark, policy_id]
|
||||||
|
position_values = [dscp_mark]
|
||||||
|
self._test_create_resource(
|
||||||
|
self.dscp_res, cmd, '', my_id, args,
|
||||||
|
position_names, position_values,
|
||||||
|
cmd_resource=self.dscp_cmd_res,
|
||||||
|
parent_id=policy_id,
|
||||||
|
no_api_call=True,
|
||||||
|
expected_exception=exceptions.CommandError)
|
||||||
|
|
||||||
|
def test_update_dscp_marking_rule_with_dscp_mark(self):
|
||||||
|
cmd = dscp_rule.UpdateQoSDscpMarkingRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
dscp_mark = '56'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = ['--dscp-mark', dscp_mark,
|
||||||
|
my_id, policy_id]
|
||||||
|
self._test_update_resource(self.dscp_res, cmd, my_id, args,
|
||||||
|
{'dscp_mark': dscp_mark},
|
||||||
|
cmd_resource=self.dscp_cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_delete_dscp_marking_rule(self):
|
||||||
|
cmd = dscp_rule.DeleteQoSDscpMarkingRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
my_id = 'my-id'
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = [my_id, policy_id]
|
||||||
|
self._test_delete_resource(self.dscp_res, cmd, my_id, args,
|
||||||
|
cmd_resource=self.dscp_cmd_res,
|
||||||
|
parent_id=policy_id)
|
||||||
|
|
||||||
|
def test_show_dscp_marking_rule(self):
|
||||||
|
cmd = dscp_rule.ShowQoSDscpMarkingRule(test_cli20.MyApp(sys.stdout),
|
||||||
|
None)
|
||||||
|
policy_id = 'policy_id'
|
||||||
|
args = [self.test_id, policy_id]
|
||||||
|
self._test_show_resource(self.dscp_res, cmd, self.test_id, args,
|
||||||
|
[], cmd_resource=self.dscp_cmd_res,
|
||||||
|
parent_id=policy_id)
|
@@ -16,132 +16,24 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from neutronclient.neutron.v2_0.qos import bandwidth_limit_rule as bw_rule
|
|
||||||
from neutronclient.neutron.v2_0.qos import rule as qos_rule
|
from neutronclient.neutron.v2_0.qos import rule as qos_rule
|
||||||
from neutronclient.tests.unit import test_cli20
|
from neutronclient.tests.unit import test_cli20
|
||||||
|
|
||||||
|
|
||||||
class CLITestV20QoSRuleJSON(test_cli20.CLITestV20Base):
|
class CLITestV20QoSRuleJSON(test_cli20.CLITestV20Base):
|
||||||
|
|
||||||
non_admin_status_resources = ['bandwidth_limit_rule']
|
non_admin_status_resources = ['bandwidth_limit_rule', 'dscp_marking_rule']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(CLITestV20QoSRuleJSON, self).setUp()
|
super(CLITestV20QoSRuleJSON, self).setUp()
|
||||||
self.res = 'bandwidth_limit_rule'
|
|
||||||
self.cmd_res = 'qos_bandwidth_limit_rule'
|
|
||||||
self.ress = 'bandwidth_limit_rules'
|
|
||||||
self.cmd_ress = 'qos_bandwidth_limit_rules'
|
|
||||||
|
|
||||||
def test_create_bandwidth_limit_rule_with_max_kbps(self):
|
|
||||||
cmd = bw_rule.CreateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
my_id = 'my-id'
|
|
||||||
max_kbps = '1337'
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = ['--max-kbps', max_kbps, policy_id]
|
|
||||||
position_names = ['max_kbps']
|
|
||||||
position_values = [max_kbps]
|
|
||||||
self._test_create_resource(self.res, cmd, '', my_id, args,
|
|
||||||
position_names, position_values,
|
|
||||||
cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_create_bandwidth_limit_rule_with_max_burst_kbps(self):
|
|
||||||
cmd = bw_rule.CreateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
my_id = 'my-id'
|
|
||||||
max_burst_kbps = '1337'
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = ['--max-burst-kbps', max_burst_kbps, policy_id]
|
|
||||||
position_names = ['max_burst_kbps']
|
|
||||||
position_values = [max_burst_kbps]
|
|
||||||
self._test_create_resource(self.res, cmd, '', my_id, args,
|
|
||||||
position_names, position_values,
|
|
||||||
cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_create_bandwidth_limit_rule_with_all_params(self):
|
|
||||||
cmd = bw_rule.CreateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
my_id = 'my-id'
|
|
||||||
max_kbps = '1337'
|
|
||||||
max_burst_kbps = '1337'
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = ['--max-kbps', max_kbps,
|
|
||||||
'--max-burst-kbps', max_burst_kbps,
|
|
||||||
policy_id]
|
|
||||||
position_names = ['max_kbps', 'max_burst_kbps']
|
|
||||||
position_values = [max_kbps, max_burst_kbps]
|
|
||||||
self._test_create_resource(self.res, cmd, '', my_id, args,
|
|
||||||
position_names, position_values,
|
|
||||||
cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_update_bandwidth_limit_rule_with_max_kbps(self):
|
|
||||||
cmd = bw_rule.UpdateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
my_id = 'my-id'
|
|
||||||
max_kbps = '1337'
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = ['--max-kbps', max_kbps, my_id, policy_id]
|
|
||||||
self._test_update_resource(self.res, cmd, my_id, args,
|
|
||||||
{'max_kbps': max_kbps, },
|
|
||||||
cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_update_bandwidth_limit_rule_with_max_burst_kbps(self):
|
|
||||||
cmd = bw_rule.UpdateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
my_id = 'my-id'
|
|
||||||
max_burst_kbps = '1337'
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = ['--max-burst-kbps', max_burst_kbps,
|
|
||||||
my_id, policy_id]
|
|
||||||
self._test_update_resource(self.res, cmd, my_id, args,
|
|
||||||
{'max_burst_kbps': max_burst_kbps},
|
|
||||||
cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_update_bandwidth_limit_rule_with_all_params(self):
|
|
||||||
cmd = bw_rule.UpdateQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
my_id = 'my-id'
|
|
||||||
max_kbps = '1337'
|
|
||||||
max_burst_kbps = '1337'
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = ['--max-kbps', max_kbps,
|
|
||||||
'--max-burst-kbps', max_burst_kbps,
|
|
||||||
my_id, policy_id]
|
|
||||||
self._test_update_resource(self.res, cmd, my_id, args,
|
|
||||||
{'max_kbps': max_kbps,
|
|
||||||
'max_burst_kbps': max_burst_kbps},
|
|
||||||
cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_delete_bandwidth_limit_rule(self):
|
|
||||||
cmd = bw_rule.DeleteQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
my_id = 'my-id'
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = [my_id, policy_id]
|
|
||||||
self._test_delete_resource(self.res, cmd, my_id, args,
|
|
||||||
cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_show_bandwidth_limit_rule(self):
|
|
||||||
cmd = bw_rule.ShowQoSBandwidthLimitRule(test_cli20.MyApp(sys.stdout),
|
|
||||||
None)
|
|
||||||
policy_id = 'policy_id'
|
|
||||||
args = [self.test_id, policy_id]
|
|
||||||
self._test_show_resource(self.res, cmd, self.test_id, args,
|
|
||||||
[], cmd_resource=self.cmd_res,
|
|
||||||
parent_id=policy_id)
|
|
||||||
|
|
||||||
def test_list_qos_rule_types(self):
|
def test_list_qos_rule_types(self):
|
||||||
# qos_rule_types.
|
# qos_rule_types.
|
||||||
resources = 'rule_types'
|
resources = 'rule_types'
|
||||||
cmd_resources = 'qos_rule_types'
|
cmd_resources = 'qos_rule_types'
|
||||||
response_contents = [{'type': 'bandwidth_limit'}]
|
response_contents = [{'type': 'bandwidth_limit',
|
||||||
|
'type': 'dscp_marking'}]
|
||||||
|
|
||||||
cmd = qos_rule.ListQoSRuleTypes(test_cli20.MyApp(sys.stdout),
|
cmd = qos_rule.ListQoSRuleTypes(test_cli20.MyApp(sys.stdout),
|
||||||
None)
|
None)
|
||||||
self._test_list_resources(resources, cmd, True,
|
self._test_list_resources(resources, cmd, True,
|
||||||
|
@@ -508,6 +508,8 @@ class Client(ClientBase):
|
|||||||
qos_policy_path = "/qos/policies/%s"
|
qos_policy_path = "/qos/policies/%s"
|
||||||
qos_bandwidth_limit_rules_path = "/qos/policies/%s/bandwidth_limit_rules"
|
qos_bandwidth_limit_rules_path = "/qos/policies/%s/bandwidth_limit_rules"
|
||||||
qos_bandwidth_limit_rule_path = "/qos/policies/%s/bandwidth_limit_rules/%s"
|
qos_bandwidth_limit_rule_path = "/qos/policies/%s/bandwidth_limit_rules/%s"
|
||||||
|
qos_dscp_marking_rules_path = "/qos/policies/%s/dscp_marking_rules"
|
||||||
|
qos_dscp_marking_rule_path = "/qos/policies/%s/dscp_marking_rules/%s"
|
||||||
qos_rule_types_path = "/qos/rule-types"
|
qos_rule_types_path = "/qos/rule-types"
|
||||||
qos_rule_type_path = "/qos/rule-types/%s"
|
qos_rule_type_path = "/qos/rule-types/%s"
|
||||||
flavors_path = "/flavors"
|
flavors_path = "/flavors"
|
||||||
@@ -565,6 +567,7 @@ class Client(ClientBase):
|
|||||||
'policies': 'policy',
|
'policies': 'policy',
|
||||||
'bandwidth_limit_rules': 'bandwidth_limit_rule',
|
'bandwidth_limit_rules': 'bandwidth_limit_rule',
|
||||||
'rules': 'rule',
|
'rules': 'rule',
|
||||||
|
'dscp_marking_rules': 'dscp_marking_rule',
|
||||||
'rule_types': 'rule_type',
|
'rule_types': 'rule_type',
|
||||||
'flavors': 'flavor',
|
'flavors': 'flavor',
|
||||||
'bgp_speakers': 'bgp_speaker',
|
'bgp_speakers': 'bgp_speaker',
|
||||||
@@ -1795,7 +1798,7 @@ class Client(ClientBase):
|
|||||||
@APIParamsCall
|
@APIParamsCall
|
||||||
def list_bandwidth_limit_rules(self, policy_id,
|
def list_bandwidth_limit_rules(self, policy_id,
|
||||||
retrieve_all=True, **_params):
|
retrieve_all=True, **_params):
|
||||||
"""Fetches a list of all qos rules for the given policy."""
|
"""Fetches a list of all bandwidth limit rules for the given policy."""
|
||||||
return self.list('bandwidth_limit_rules',
|
return self.list('bandwidth_limit_rules',
|
||||||
self.qos_bandwidth_limit_rules_path % policy_id,
|
self.qos_bandwidth_limit_rules_path % policy_id,
|
||||||
retrieve_all, **_params)
|
retrieve_all, **_params)
|
||||||
@@ -1824,6 +1827,38 @@ class Client(ClientBase):
|
|||||||
return self.delete(self.qos_bandwidth_limit_rule_path %
|
return self.delete(self.qos_bandwidth_limit_rule_path %
|
||||||
(policy, rule))
|
(policy, rule))
|
||||||
|
|
||||||
|
@APIParamsCall
|
||||||
|
def list_dscp_marking_rules(self, policy_id,
|
||||||
|
retrieve_all=True, **_params):
|
||||||
|
"""Fetches a list of all DSCP marking rules for the given policy."""
|
||||||
|
return self.list('dscp_marking_rules',
|
||||||
|
self.qos_dscp_marking_rules_path % policy_id,
|
||||||
|
retrieve_all, **_params)
|
||||||
|
|
||||||
|
@APIParamsCall
|
||||||
|
def show_dscp_marking_rule(self, rule, policy, body=None):
|
||||||
|
"""Shows information of a certain DSCP marking rule."""
|
||||||
|
return self.get(self.qos_dscp_marking_rule_path %
|
||||||
|
(policy, rule), body=body)
|
||||||
|
|
||||||
|
@APIParamsCall
|
||||||
|
def create_dscp_marking_rule(self, policy, body=None):
|
||||||
|
"""Creates a new DSCP marking rule."""
|
||||||
|
return self.post(self.qos_dscp_marking_rules_path % policy,
|
||||||
|
body=body)
|
||||||
|
|
||||||
|
@APIParamsCall
|
||||||
|
def update_dscp_marking_rule(self, rule, policy, body=None):
|
||||||
|
"""Updates a DSCP marking rule."""
|
||||||
|
return self.put(self.qos_dscp_marking_rule_path %
|
||||||
|
(policy, rule), body=body)
|
||||||
|
|
||||||
|
@APIParamsCall
|
||||||
|
def delete_dscp_marking_rule(self, rule, policy):
|
||||||
|
"""Deletes a DSCP marking rule."""
|
||||||
|
return self.delete(self.qos_dscp_marking_rule_path %
|
||||||
|
(policy, rule))
|
||||||
|
|
||||||
@APIParamsCall
|
@APIParamsCall
|
||||||
def create_flavor(self, body=None):
|
def create_flavor(self, body=None):
|
||||||
"""Creates a new Neutron service flavor."""
|
"""Creates a new Neutron service flavor."""
|
||||||
|
6
releasenotes/notes/dscp_qos-4a26d3c0363624b0.yaml
Normal file
6
releasenotes/notes/dscp_qos-4a26d3c0363624b0.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
prelude: >
|
||||||
|
Adding new QoS DSCP marking rule commands.
|
||||||
|
features:
|
||||||
|
- New create, update, list, show, and delete commands are added for QoS
|
||||||
|
DSCP marking rule functionality.
|
Reference in New Issue
Block a user