Merge "Add qos rule type filtering"
This commit is contained in:
commit
a8d1ee709e
@ -32,6 +32,23 @@ def _get_columns(item):
|
||||
class ListNetworkQosRuleType(command.Lister):
|
||||
_description = _("List QoS rule types")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
supported = parser.add_mutually_exclusive_group()
|
||||
supported.add_argument(
|
||||
'--all-supported',
|
||||
action='store_true',
|
||||
help=_("List all the QoS rule types supported by any loaded "
|
||||
"mechanism drivers (the union of all sets of supported "
|
||||
"rules)")
|
||||
)
|
||||
supported.add_argument(
|
||||
'--all-rules',
|
||||
action='store_true',
|
||||
help=_("List all QoS rule types implemented in Neutron QoS driver")
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
client = self.app.client_manager.network
|
||||
columns = (
|
||||
@ -40,7 +57,13 @@ class ListNetworkQosRuleType(command.Lister):
|
||||
column_headers = (
|
||||
'Type',
|
||||
)
|
||||
data = client.qos_rule_types()
|
||||
|
||||
args = {}
|
||||
if parsed_args.all_supported:
|
||||
args['all_supported'] = True
|
||||
elif parsed_args.all_rules:
|
||||
args['all_rules'] = True
|
||||
data = client.qos_rule_types(**args)
|
||||
|
||||
return (column_headers,
|
||||
(utils.get_item_properties(
|
||||
|
@ -21,6 +21,13 @@ class NetworkQosRuleTypeTests(common.NetworkTests):
|
||||
|
||||
AVAILABLE_RULE_TYPES = ['dscp_marking',
|
||||
'bandwidth_limit']
|
||||
# NOTE(ralonsoh): this list was updated in Yoga (February 2022)
|
||||
ALL_AVAILABLE_RULE_TYPES = ['dscp_marking',
|
||||
'bandwidth_limit',
|
||||
'minimum_bandwidth',
|
||||
'packet_rate_limit',
|
||||
'minimum_packet_rate',
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkQosRuleTypeTests, self).setUp()
|
||||
@ -36,6 +43,28 @@ class NetworkQosRuleTypeTests(common.NetworkTests):
|
||||
for rule_type in self.AVAILABLE_RULE_TYPES:
|
||||
self.assertIn(rule_type, [x['Type'] for x in cmd_output])
|
||||
|
||||
def test_qos_rule_type_list_all_supported(self):
|
||||
if not self.is_extension_enabled('qos-rule-type-filter'):
|
||||
self.skipTest('No "qos-rule-type-filter" extension present')
|
||||
|
||||
cmd_output = self.openstack(
|
||||
'network qos rule type list --all-supported -f json',
|
||||
parse_output=True
|
||||
)
|
||||
for rule_type in self.AVAILABLE_RULE_TYPES:
|
||||
self.assertIn(rule_type, [x['Type'] for x in cmd_output])
|
||||
|
||||
def test_qos_rule_type_list_all_rules(self):
|
||||
if not self.is_extension_enabled('qos-rule-type-filter'):
|
||||
self.skipTest('No "qos-rule-type-filter" extension present')
|
||||
|
||||
cmd_output = self.openstack(
|
||||
'network qos rule type list --all-rules -f json',
|
||||
parse_output=True
|
||||
)
|
||||
for rule_type in self.ALL_AVAILABLE_RULE_TYPES:
|
||||
self.assertIn(rule_type, [x['Type'] for x in cmd_output])
|
||||
|
||||
def test_qos_rule_type_details(self):
|
||||
for rule_type in self.AVAILABLE_RULE_TYPES:
|
||||
cmd_output = self.openstack(
|
||||
|
@ -115,3 +115,37 @@ class TestListNetworkQosRuleType(TestNetworkQosRuleType):
|
||||
self.network.qos_rule_types.assert_called_once_with(**{})
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_qos_rule_type_list_all_supported(self):
|
||||
arglist = [
|
||||
'--all-supported'
|
||||
]
|
||||
verifylist = [
|
||||
('all_supported', True),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network.qos_rule_types.assert_called_once_with(
|
||||
**{'all_supported': True}
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
||||
def test_qos_rule_type_list_all_rules(self):
|
||||
arglist = [
|
||||
'--all-rules'
|
||||
]
|
||||
verifylist = [
|
||||
('all_rules', True),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.network.qos_rule_types.assert_called_once_with(
|
||||
**{'all_rules': True}
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.data, list(data))
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added two new filter flags to ``openstack network qos rule type list``:
|
||||
``--all-supported``, to return any QoS rule type supported by at least
|
||||
one loaded driver; ``--all-rules``, to return all QoS rule types
|
||||
supported by the current version of Neutron server, regardless of the
|
||||
loaded drivers.
|
Loading…
Reference in New Issue
Block a user