Add support for QoS rule type commands
Added following commands: - network qos rule type list Closes-Bug: 1612194 Depends-On: Iecf7bc7acd244a842aae963993f37a64a26b43b9 Change-Id: I38af823c726ceaba9d0b45488fa48e2d93971c92
This commit is contained in:
parent
5084ce14b0
commit
9e1e7e1c9f
18
doc/source/command-objects/network-qos-rule-type.rst
Normal file
18
doc/source/command-objects/network-qos-rule-type.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
=====================
|
||||||
|
network qos rule type
|
||||||
|
=====================
|
||||||
|
|
||||||
|
A **Network QoS rule type** is a specific Network QoS rule type available to be
|
||||||
|
used.
|
||||||
|
|
||||||
|
Network v2
|
||||||
|
|
||||||
|
network qos rule type list
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
List Network QoS rule types
|
||||||
|
|
||||||
|
.. program:: network qos rule type list
|
||||||
|
.. code:: bash
|
||||||
|
|
||||||
|
os network qos rule type list
|
@ -113,6 +113,7 @@ referring to both Compute and Volume quotas.
|
|||||||
* ``network agent``: (**Network**) - A network agent is an agent that handles various tasks used to implement virtual networks
|
* ``network agent``: (**Network**) - A network agent is an agent that handles various tasks used to implement virtual networks
|
||||||
* ``network rbac``: (**Network**) - an RBAC policy for network resources
|
* ``network rbac``: (**Network**) - an RBAC policy for network resources
|
||||||
* ``network qos policy``: (**Network**) - a QoS policy for network resources
|
* ``network qos policy``: (**Network**) - a QoS policy for network resources
|
||||||
|
* ``network qos rule type``: (**Network**) - list of QoS available rule types
|
||||||
* ``network segment``: (**Network**) - a segment of a virtual network
|
* ``network segment``: (**Network**) - a segment of a virtual network
|
||||||
* ``network service provider``: (**Network**) - a driver providing a network service
|
* ``network service provider``: (**Network**) - a driver providing a network service
|
||||||
* ``object``: (**Object Storage**) a single file in the Object Storage
|
* ``object``: (**Object Storage**) a single file in the Object Storage
|
||||||
|
41
openstackclient/network/v2/network_qos_rule_type.py
Normal file
41
openstackclient/network/v2/network_qos_rule_type.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
# Copyright (c) 2016, Intel Corporation.
|
||||||
|
# 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 logging
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
from osc_lib import utils
|
||||||
|
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ListNetworkQosRuleType(command.Lister):
|
||||||
|
"""List QoS rule types"""
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
client = self.app.client_manager.network
|
||||||
|
columns = (
|
||||||
|
'type',
|
||||||
|
)
|
||||||
|
column_headers = (
|
||||||
|
'Type',
|
||||||
|
)
|
||||||
|
data = client.qos_rule_types()
|
||||||
|
|
||||||
|
return (column_headers,
|
||||||
|
(utils.get_item_properties(
|
||||||
|
s, columns, formatters={},
|
||||||
|
) for s in data))
|
@ -0,0 +1,29 @@
|
|||||||
|
# Copyright (c) 2016, Intel Corporation.
|
||||||
|
# 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 openstackclient.tests.functional import base
|
||||||
|
|
||||||
|
|
||||||
|
class NetworkQosRuleTypeTests(base.TestCase):
|
||||||
|
"""Functional tests for Network QoS rule type. """
|
||||||
|
|
||||||
|
AVAILABLE_RULE_TYPES = ['dscp_marking',
|
||||||
|
'bandwidth_limit',
|
||||||
|
'minimum_bandwidth']
|
||||||
|
|
||||||
|
def test_qos_rule_type_list(self):
|
||||||
|
raw_output = self.openstack('network qos rule type list')
|
||||||
|
for rule_type in self.AVAILABLE_RULE_TYPES:
|
||||||
|
self.assertIn(rule_type, raw_output)
|
@ -813,6 +813,51 @@ class FakeNetworkQosPolicy(object):
|
|||||||
return mock.Mock(side_effect=qos_policies)
|
return mock.Mock(side_effect=qos_policies)
|
||||||
|
|
||||||
|
|
||||||
|
class FakeNetworkQosRuleType(object):
|
||||||
|
"""Fake one or more Network QoS rule types."""
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_one_qos_rule_type(attrs=None):
|
||||||
|
"""Create a fake Network QoS rule type.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:return:
|
||||||
|
A FakeResource object with name, id, etc.
|
||||||
|
"""
|
||||||
|
attrs = attrs or {}
|
||||||
|
|
||||||
|
# Set default attributes.
|
||||||
|
qos_rule_type_attrs = {
|
||||||
|
'type': 'rule-type-' + uuid.uuid4().hex,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Overwrite default attributes.
|
||||||
|
qos_rule_type_attrs.update(attrs)
|
||||||
|
|
||||||
|
return fakes.FakeResource(
|
||||||
|
info=copy.deepcopy(qos_rule_type_attrs),
|
||||||
|
loaded=True)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def create_qos_rule_types(attrs=None, count=2):
|
||||||
|
"""Create multiple fake Network QoS rule types.
|
||||||
|
|
||||||
|
:param Dictionary attrs:
|
||||||
|
A dictionary with all attributes
|
||||||
|
:param int count:
|
||||||
|
The number of QoS rule types to fake
|
||||||
|
:return:
|
||||||
|
A list of FakeResource objects faking the QoS rule types
|
||||||
|
"""
|
||||||
|
qos_rule_types = []
|
||||||
|
for i in range(0, count):
|
||||||
|
qos_rule_types.append(
|
||||||
|
FakeNetworkQosRuleType.create_one_qos_rule_type(attrs))
|
||||||
|
|
||||||
|
return qos_rule_types
|
||||||
|
|
||||||
|
|
||||||
class FakeRouter(object):
|
class FakeRouter(object):
|
||||||
"""Fake one or more routers."""
|
"""Fake one or more routers."""
|
||||||
|
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
# Copyright (c) 2016, Intel Corporation.
|
||||||
|
# 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 mock
|
||||||
|
|
||||||
|
from openstackclient.network.v2 import network_qos_rule_type as _qos_rule_type
|
||||||
|
from openstackclient.tests.unit.network.v2 import fakes as network_fakes
|
||||||
|
|
||||||
|
|
||||||
|
class TestNetworkQosRuleType(network_fakes.TestNetworkV2):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestNetworkQosRuleType, self).setUp()
|
||||||
|
# Get a shortcut to the network client
|
||||||
|
self.network = self.app.client_manager.network
|
||||||
|
|
||||||
|
|
||||||
|
class TestListNetworkQosRuleType(TestNetworkQosRuleType):
|
||||||
|
|
||||||
|
# The QoS policies to list up.
|
||||||
|
qos_rule_types = (
|
||||||
|
network_fakes.FakeNetworkQosRuleType.create_qos_rule_types(count=3))
|
||||||
|
columns = (
|
||||||
|
'Type',
|
||||||
|
)
|
||||||
|
data = []
|
||||||
|
for qos_rule_type in qos_rule_types:
|
||||||
|
data.append((
|
||||||
|
qos_rule_type.type,
|
||||||
|
))
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestListNetworkQosRuleType, self).setUp()
|
||||||
|
self.network.qos_rule_types = mock.Mock(
|
||||||
|
return_value=self.qos_rule_types)
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = _qos_rule_type.ListNetworkQosRuleType(self.app,
|
||||||
|
self.namespace)
|
||||||
|
|
||||||
|
def test_qos_rule_type_list(self):
|
||||||
|
arglist = []
|
||||||
|
verifylist = []
|
||||||
|
|
||||||
|
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(**{})
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, list(data))
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add support for Network QoS rule type commands:
|
||||||
|
``network qos rule type list``,
|
||||||
|
[Bug `1612194 <https://bugs.launchpad.net/bugs/1612194>`_]
|
@ -372,6 +372,8 @@ openstack.network.v2 =
|
|||||||
network_qos_policy_set = openstackclient.network.v2.network_qos_policy:SetNetworkQosPolicy
|
network_qos_policy_set = openstackclient.network.v2.network_qos_policy:SetNetworkQosPolicy
|
||||||
network_qos_policy_show = openstackclient.network.v2.network_qos_policy:ShowNetworkQosPolicy
|
network_qos_policy_show = openstackclient.network.v2.network_qos_policy:ShowNetworkQosPolicy
|
||||||
|
|
||||||
|
network_qos_rule_type_list = openstackclient.network.v2.network_qos_rule_type:ListNetworkQosRuleType
|
||||||
|
|
||||||
network_rbac_create = openstackclient.network.v2.network_rbac:CreateNetworkRBAC
|
network_rbac_create = openstackclient.network.v2.network_rbac:CreateNetworkRBAC
|
||||||
network_rbac_delete = openstackclient.network.v2.network_rbac:DeleteNetworkRBAC
|
network_rbac_delete = openstackclient.network.v2.network_rbac:DeleteNetworkRBAC
|
||||||
network_rbac_list = openstackclient.network.v2.network_rbac:ListNetworkRBAC
|
network_rbac_list = openstackclient.network.v2.network_rbac:ListNetworkRBAC
|
||||||
|
Loading…
Reference in New Issue
Block a user