Add network support for Network QoS policies

Added following commands:
  - network qos policy create
  - network qos policy delete
  - network qos policy set
  - network qos policy show
  - network qos policy list

Closes-Bug: 1609037
Depends-On: I33bafeca979410d329ae10a82772ccdb48c10daa

Change-Id: I63a8f63702514ff5814481bb021e2aa9d5f3d4b1
This commit is contained in:
Rodolfo Alonso Hernandez 2016-08-02 09:42:21 +01:00 committed by Dean Troyer
parent 762f2f2c34
commit 3205dad161
8 changed files with 953 additions and 0 deletions

View File

@ -0,0 +1,122 @@
==================
network qos policy
==================
A **Network QoS policy** groups a number of Network QoS rules, applied to a
network or a port.
Network v2
network qos policy create
-------------------------
Create new Network QoS policy
.. program:: network qos policy create
.. code:: bash
os network qos policy create
[--description <description>]
[--share | --no-share]
[--project <project>]
[--project-domain <project-domain>]
<name>
.. option:: --description <description>
Description of the QoS policy
.. option:: --share
Make the QoS policy accessible by other projects
.. option:: --no-share
Make the QoS policy not accessible by other projects (default)
.. option:: --project <project>
Owner's project (name or ID)
.. option:: --project-domain <project-domain>]
Domain the project belongs to (name or ID).
This can be used in case collisions between project names exist.
.. describe:: <name>
New QoS policy specification name
network qos policy delete
-------------------------
Delete Network QoS policy
.. program:: network qos policy delete
.. code:: bash
os network qos policy delete
<qos-policy> [<qos-policy> ...]
.. describe:: <qos-policy>
Network QoS policy(s) to delete (name or ID)
network qos policy list
-----------------------
List Network QoS policies
.. program:: network qos policy list
.. code:: bash
os network qos policy list
network qos policy set
----------------------
Set Network QoS policy properties
.. program:: network qos policy set
.. code:: bash
os network qos policy set
[--name <name>]
[--description <description>]
[--share | --no-share]
<qos-policy>
.. option:: --name <name>
Name of the QoS policy
.. option:: --description <description>
Description of the QoS policy
.. option:: --share
Make the QoS policy accessible by other projects
.. option:: --no-share
Make the QoS policy not accessible by other projects
.. describe:: <qos-policy>
Network QoS policy(s) to delete (name or ID)
network qos policy show
-----------------------
Display Network QoS policy details
.. program:: network qos policy show
.. code:: bash
os network qos policy show
<qos-policy>
.. describe:: <qos-policy>
Network QoS policy(s) to show (name or ID)

View File

@ -112,6 +112,7 @@ referring to both Compute and Volume quotas.
* ``network``: (**Compute**, **Network**) - a virtual network for connecting servers and other resources
* ``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 qos policy``: (**Network**) - a QoS policy for network resources
* ``network segment``: (**Network**) - a segment of a virtual network
* ``object``: (**Object Storage**) a single file in the Object Storage
* ``object store account``: (**Object Storage**) owns a group of Object Storage resources

View File

@ -0,0 +1,231 @@
# 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 exceptions
from osc_lib import utils
from openstackclient.i18n import _
from openstackclient.identity import common as identity_common
LOG = logging.getLogger(__name__)
def _get_columns(item):
columns = list(item.keys())
if 'tenant_id' in columns:
columns.remove('tenant_id')
columns.append('project_id')
return tuple(sorted(columns))
def _get_attrs(client_manager, parsed_args):
attrs = {}
if parsed_args.name is not None:
attrs['name'] = str(parsed_args.name)
if parsed_args.description is not None:
attrs['description'] = parsed_args.description
if parsed_args.share:
attrs['shared'] = True
if parsed_args.no_share:
attrs['shared'] = False
if parsed_args.project is not None:
identity_client = client_manager.identity
project_id = identity_common.find_project(
identity_client,
parsed_args.project,
parsed_args.project_domain,
).id
attrs['tenant_id'] = project_id
return attrs
class CreateNetworkQosPolicy(command.ShowOne):
"""Create a QoS policy"""
def get_parser(self, prog_name):
parser = super(CreateNetworkQosPolicy, self).get_parser(prog_name)
parser.add_argument(
'name',
metavar='<name>',
help=_("Name of QoS policy to create")
)
parser.add_argument(
'--description',
metavar='<description>',
help=_("Description of the QoS policy")
)
share_group = parser.add_mutually_exclusive_group()
share_group.add_argument(
'--share',
action='store_true',
default=None,
help=_("Make the QoS policy accessible by other projects")
)
share_group.add_argument(
'--no-share',
action='store_true',
help=_("Make the QoS policy not accessible by other projects "
"(default)")
)
parser.add_argument(
'--project',
metavar='<project>',
help=_("Owner's project (name or ID)")
)
identity_common.add_project_domain_option_to_parser(parser)
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.network
attrs = _get_attrs(self.app.client_manager, parsed_args)
obj = client.create_qos_policy(**attrs)
columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns, formatters={})
return columns, data
class DeleteNetworkQosPolicy(command.Command):
"""Delete Qos Policy(s)"""
def get_parser(self, prog_name):
parser = super(DeleteNetworkQosPolicy, self).get_parser(prog_name)
parser.add_argument(
'policy',
metavar="<qos-policy>",
nargs="+",
help=_("QoS policy(s) to delete (name or ID)")
)
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.network
result = 0
for policy in parsed_args.policy:
try:
obj = client.find_qos_policy(policy, ignore_missing=False)
client.delete_qos_policy(obj)
except Exception as e:
result += 1
LOG.error(_("Failed to delete QoS policy "
"name or ID '%(qos_policy)s': %(e)s"),
{'qos_policy': policy, 'e': e})
if result > 0:
total = len(parsed_args.policy)
msg = (_("%(result)s of %(total)s QoS policies failed "
"to delete.") % {'result': result, 'total': total})
raise exceptions.CommandError(msg)
class ListNetworkQosPolicy(command.Lister):
"""List QoS policies"""
def take_action(self, parsed_args):
client = self.app.client_manager.network
columns = (
'id',
'name',
'shared',
'tenant_id',
)
column_headers = (
'ID',
'Name',
'Shared',
'Project',
)
data = client.qos_policies()
return (column_headers,
(utils.get_item_properties(
s, columns, formatters={},
) for s in data))
class SetNetworkQosPolicy(command.Command):
"""Set QoS policy properties"""
def get_parser(self, prog_name):
parser = super(SetNetworkQosPolicy, self).get_parser(prog_name)
parser.add_argument(
'policy',
metavar="<qos-policy>",
help=_("QoS policy to modify (name or ID)")
)
parser.add_argument(
'--name',
metavar="<name>",
help=_('Set QoS policy name')
)
parser.add_argument(
'--description',
metavar='<description>',
help=_("Description of the QoS policy")
)
enable_group = parser.add_mutually_exclusive_group()
enable_group.add_argument(
'--share',
action='store_true',
help=_('Make the QoS policy accessible by other projects'),
)
enable_group.add_argument(
'--no-share',
action='store_true',
help=_('Make the QoS policy not accessible by other projects'),
)
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.network
obj = client.find_qos_policy(
parsed_args.policy,
ignore_missing=False)
attrs = {}
if parsed_args.name is not None:
attrs['name'] = parsed_args.name
if parsed_args.share:
attrs['shared'] = True
if parsed_args.no_share:
attrs['shared'] = False
if parsed_args.description is not None:
attrs['description'] = parsed_args.description
client.update_qos_policy(obj, **attrs)
class ShowNetworkQosPolicy(command.ShowOne):
"""Display QoS policy details"""
def get_parser(self, prog_name):
parser = super(ShowNetworkQosPolicy, self).get_parser(prog_name)
parser.add_argument(
'policy',
metavar="<qos-policy>",
help=_("QoS policy to display (name or ID)")
)
return parser
def take_action(self, parsed_args):
client = self.app.client_manager.network
obj = client.find_qos_policy(parsed_args.policy,
ignore_missing=False)
columns = _get_columns(obj)
data = utils.get_item_properties(obj, columns)
return columns, data

View File

@ -0,0 +1,55 @@
# 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 uuid
from openstackclient.tests.functional import base
class QosPolicyTests(base.TestCase):
"""Functional tests for QoS policy. """
NAME = uuid.uuid4().hex
HEADERS = ['Name']
FIELDS = ['name']
@classmethod
def setUpClass(cls):
opts = cls.get_opts(cls.FIELDS)
raw_output = cls.openstack('network qos policy create ' + cls.NAME +
opts)
cls.assertOutput(cls.NAME + "\n", raw_output)
@classmethod
def tearDownClass(cls):
raw_output = cls.openstack('network qos policy delete ' + cls.NAME)
cls.assertOutput('', raw_output)
def test_qos_policy_list(self):
opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('network qos policy list' + opts)
self.assertIn(self.NAME, raw_output)
def test_qos_policy_show(self):
opts = self.get_opts(self.FIELDS)
raw_output = self.openstack('network qos policy show ' + self.NAME +
opts)
self.assertEqual(self.NAME + "\n", raw_output)
def test_qos_policy_set(self):
self.openstack('network qos policy set --share ' + self.NAME)
opts = self.get_opts(['shared'])
raw_output = self.openstack('network qos policy show ' + self.NAME +
opts)
self.assertEqual("True\n", raw_output)

View File

@ -633,6 +633,156 @@ class FakeNetworkRBAC(object):
return mock.Mock(side_effect=rbac_policies)
class FakeNetworkQosBandwidthLimitRule(object):
"""Fake one or more QoS bandwidth limit rules."""
@staticmethod
def create_one_qos_bandwidth_limit_rule(attrs=None):
"""Create a fake QoS bandwidth limit rule.
:param Dictionary attrs:
A dictionary with all attributes
:return:
A FakeResource object with id, qos_policy_id, max_kbps and
max_burst_kbps attributes.
"""
attrs = attrs or {}
# Set default attributes.
qos_bandwidth_limit_rule_attrs = {
'id': 'qos-bandwidth-limit-rule-id-' + uuid.uuid4().hex,
'qos_policy_id': 'qos-policy-id-' + uuid.uuid4().hex,
'max_kbps': 1500,
'max_burst_kbps': 1200,
}
# Overwrite default attributes.
qos_bandwidth_limit_rule_attrs.update(attrs)
qos_bandwidth_limit_rule = fakes.FakeResource(
info=copy.deepcopy(qos_bandwidth_limit_rule_attrs),
loaded=True)
return qos_bandwidth_limit_rule
@staticmethod
def create_qos_bandwidth_limit_rules(attrs=None, count=2):
"""Create multiple fake QoS bandwidth limit rules.
:param Dictionary attrs:
A dictionary with all attributes
:param int count:
The number of QoS bandwidth limit rules to fake
:return:
A list of FakeResource objects faking the QoS bandwidth limit rules
"""
qos_policies = []
for i in range(0, count):
qos_policies.append(FakeNetworkQosBandwidthLimitRule.
create_one_qos_bandwidth_limit_rule(attrs))
return qos_policies
@staticmethod
def get_qos_bandwidth_limit_rules(qos_rules=None, count=2):
"""Get a list of faked QoS bandwidth limit rules.
If QoS bandwidth limit rules list is provided, then initialize the
Mock object with the list. Otherwise create one.
:param List address scopes:
A list of FakeResource objects faking QoS bandwidth limit rules
:param int count:
The number of QoS bandwidth limit rules to fake
:return:
An iterable Mock object with side_effect set to a list of faked
qos bandwidth limit rules
"""
if qos_rules is None:
qos_rules = (FakeNetworkQosBandwidthLimitRule.
create_qos_bandwidth_limit_rules(count))
return mock.Mock(side_effect=qos_rules)
class FakeNetworkQosPolicy(object):
"""Fake one or more QoS policies."""
@staticmethod
def create_one_qos_policy(attrs=None):
"""Create a fake QoS policy.
:param Dictionary attrs:
A dictionary with all attributes
:return:
A FakeResource object with name, id, etc.
"""
attrs = attrs or {}
qos_id = attrs.get('id') or 'qos-policy-id-' + uuid.uuid4().hex
rule_attrs = {'qos_policy_id': qos_id}
rules = [
FakeNetworkQosBandwidthLimitRule.
create_one_qos_bandwidth_limit_rule(rule_attrs)]
# Set default attributes.
qos_policy_attrs = {
'name': 'qos-policy-name-' + uuid.uuid4().hex,
'id': qos_id,
'tenant_id': 'project-id-' + uuid.uuid4().hex,
'shared': False,
'description': 'qos-policy-description-' + uuid.uuid4().hex,
'rules': rules,
}
# Overwrite default attributes.
qos_policy_attrs.update(attrs)
qos_policy = fakes.FakeResource(
info=copy.deepcopy(qos_policy_attrs),
loaded=True)
# Set attributes with special mapping in OpenStack SDK.
qos_policy.project_id = qos_policy_attrs['tenant_id']
return qos_policy
@staticmethod
def create_qos_policies(attrs=None, count=2):
"""Create multiple fake QoS policies.
:param Dictionary attrs:
A dictionary with all attributes
:param int count:
The number of QoS policies to fake
:return:
A list of FakeResource objects faking the QoS policies
"""
qos_policies = []
for i in range(0, count):
qos_policies.append(
FakeNetworkQosPolicy.create_one_qos_policy(attrs))
return qos_policies
@staticmethod
def get_qos_policies(qos_policies=None, count=2):
"""Get an iterable MagicMock object with a list of faked QoS policies.
If qos policies list is provided, then initialize the Mock object
with the list. Otherwise create one.
:param List address scopes:
A list of FakeResource objects faking qos policies
:param int count:
The number of QoS policies to fake
:return:
An iterable Mock object with side_effect set to a list of faked
QoS policies
"""
if qos_policies is None:
qos_policies = FakeNetworkQosPolicy.create_qos_policies(count)
return mock.Mock(side_effect=qos_policies)
class FakeRouter(object):
"""Fake one or more routers."""

View File

@ -0,0 +1,380 @@
# 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 mock import call
from osc_lib import exceptions
from openstackclient.network.v2 import network_qos_policy
from openstackclient.tests.unit.identity.v3 import fakes as identity_fakes_v3
from openstackclient.tests.unit.network.v2 import fakes as network_fakes
from openstackclient.tests.unit import utils as tests_utils
class TestQosPolicy(network_fakes.TestNetworkV2):
def setUp(self):
super(TestQosPolicy, self).setUp()
# Get a shortcut to the network client
self.network = self.app.client_manager.network
# Get a shortcut to the ProjectManager Mock
self.projects_mock = self.app.client_manager.identity.projects
class TestCreateNetworkQosPolicy(TestQosPolicy):
project = identity_fakes_v3.FakeProject.create_one_project()
# The new qos policy created.
new_qos_policy = (
network_fakes.FakeNetworkQosPolicy.create_one_qos_policy(
attrs={
'tenant_id': project.id,
}
))
columns = (
'description',
'id',
'name',
'project_id',
'rules',
'shared',
)
data = (
new_qos_policy.description,
new_qos_policy.id,
new_qos_policy.name,
new_qos_policy.project_id,
new_qos_policy.rules,
new_qos_policy.shared,
)
def setUp(self):
super(TestCreateNetworkQosPolicy, self).setUp()
self.network.create_qos_policy = mock.Mock(
return_value=self.new_qos_policy)
# Get the command object to test
self.cmd = network_qos_policy.CreateNetworkQosPolicy(
self.app, self.namespace)
self.projects_mock.get.return_value = self.project
def test_create_no_options(self):
arglist = []
verifylist = []
# Missing required args should bail here
self.assertRaises(tests_utils.ParserException, self.check_parser,
self.cmd, arglist, verifylist)
def test_create_default_options(self):
arglist = [
self.new_qos_policy.name,
]
verifylist = [
('project', None),
('name', self.new_qos_policy.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = (self.cmd.take_action(parsed_args))
self.network.create_qos_policy.assert_called_once_with(**{
'name': self.new_qos_policy.name
})
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_create_all_options(self):
arglist = [
'--share',
'--project', self.project.name,
self.new_qos_policy.name,
'--description', 'QoS policy description',
]
verifylist = [
('share', True),
('project', self.project.name),
('name', self.new_qos_policy.name),
('description', 'QoS policy description'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.network.create_qos_policy.assert_called_once_with(**{
'shared': True,
'tenant_id': self.project.id,
'name': self.new_qos_policy.name,
'description': 'QoS policy description',
})
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
class TestDeleteNetworkQosPolicy(TestQosPolicy):
# The address scope to delete.
_qos_policies = (
network_fakes.FakeNetworkQosPolicy.create_qos_policies(count=2))
def setUp(self):
super(TestDeleteNetworkQosPolicy, self).setUp()
self.network.delete_qos_policy = mock.Mock(return_value=None)
self.network.find_qos_policy = (
network_fakes.FakeNetworkQosPolicy.get_qos_policies(
qos_policies=self._qos_policies)
)
# Get the command object to test
self.cmd = network_qos_policy.DeleteNetworkQosPolicy(
self.app, self.namespace)
def test_qos_policy_delete(self):
arglist = [
self._qos_policies[0].name,
]
verifylist = [
('policy', [self._qos_policies[0].name]),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.network.find_qos_policy.assert_called_once_with(
self._qos_policies[0].name, ignore_missing=False)
self.network.delete_qos_policy.assert_called_once_with(
self._qos_policies[0])
self.assertIsNone(result)
def test_multi_qos_policies_delete(self):
arglist = []
for a in self._qos_policies:
arglist.append(a.name)
verifylist = [
('policy', arglist),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
calls = []
for a in self._qos_policies:
calls.append(call(a))
self.network.delete_qos_policy.assert_has_calls(calls)
self.assertIsNone(result)
def test_multi_qos_policies_delete_with_exception(self):
arglist = [
self._qos_policies[0].name,
'unexist_qos_policy',
]
verifylist = [
('policy',
[self._qos_policies[0].name, 'unexist_qos_policy']),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [self._qos_policies[0], exceptions.CommandError]
self.network.find_qos_policy = (
mock.MagicMock(side_effect=find_mock_result)
)
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
self.assertEqual('1 of 2 QoS policies failed to delete.', str(e))
self.network.find_qos_policy.assert_any_call(
self._qos_policies[0].name, ignore_missing=False)
self.network.find_qos_policy.assert_any_call(
'unexist_qos_policy', ignore_missing=False)
self.network.delete_qos_policy.assert_called_once_with(
self._qos_policies[0]
)
class TestListNetworkQosPolicy(TestQosPolicy):
# The QoS policies to list up.
qos_policies = (
network_fakes.FakeNetworkQosPolicy.create_qos_policies(count=3))
columns = (
'ID',
'Name',
'Shared',
'Project',
)
data = []
for qos_policy in qos_policies:
data.append((
qos_policy.id,
qos_policy.name,
qos_policy.shared,
qos_policy.project_id,
))
def setUp(self):
super(TestListNetworkQosPolicy, self).setUp()
self.network.qos_policies = mock.Mock(return_value=self.qos_policies)
# Get the command object to test
self.cmd = network_qos_policy.ListNetworkQosPolicy(self.app,
self.namespace)
def test_qos_policy_list(self):
arglist = []
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.network.qos_policies.assert_called_once_with(**{})
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
class TestSetNetworkQosPolicy(TestQosPolicy):
# The QoS policy to set.
_qos_policy = network_fakes.FakeNetworkQosPolicy.create_one_qos_policy()
def setUp(self):
super(TestSetNetworkQosPolicy, self).setUp()
self.network.update_qos_policy = mock.Mock(return_value=None)
self.network.find_qos_policy = mock.Mock(
return_value=self._qos_policy)
# Get the command object to test
self.cmd = network_qos_policy.SetNetworkQosPolicy(self.app,
self.namespace)
def test_set_nothing(self):
arglist = [self._qos_policy.name, ]
verifylist = [
('policy', self._qos_policy.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
attrs = {}
self.network.update_qos_policy.assert_called_with(
self._qos_policy, **attrs)
self.assertIsNone(result)
def test_set_name_share_description(self):
arglist = [
'--name', 'new_qos_policy',
'--share',
'--description', 'QoS policy description',
self._qos_policy.name,
]
verifylist = [
('name', 'new_qos_policy'),
('share', True),
('description', 'QoS policy description'),
('policy', self._qos_policy.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
attrs = {
'name': 'new_qos_policy',
'description': 'QoS policy description',
'shared': True,
}
self.network.update_qos_policy.assert_called_with(
self._qos_policy, **attrs)
self.assertIsNone(result)
def test_set_no_share(self):
arglist = [
'--no-share',
self._qos_policy.name,
]
verifylist = [
('no_share', True),
('policy', self._qos_policy.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
attrs = {
'shared': False
}
self.network.update_qos_policy.assert_called_with(
self._qos_policy, **attrs)
self.assertIsNone(result)
class TestShowNetworkQosPolicy(TestQosPolicy):
# The QoS policy to show.
_qos_policy = (
network_fakes.FakeNetworkQosPolicy.create_one_qos_policy())
columns = (
'description',
'id',
'name',
'project_id',
'rules',
'shared',
)
data = (
_qos_policy.description,
_qos_policy.id,
_qos_policy.name,
_qos_policy.project_id,
_qos_policy.rules,
_qos_policy.shared,
)
def setUp(self):
super(TestShowNetworkQosPolicy, self).setUp()
self.network.find_qos_policy = mock.Mock(return_value=self._qos_policy)
# Get the command object to test
self.cmd = network_qos_policy.ShowNetworkQosPolicy(self.app,
self.namespace)
def test_show_no_options(self):
arglist = []
verifylist = []
# Missing required args should bail here
self.assertRaises(tests_utils.ParserException, self.check_parser,
self.cmd, arglist, verifylist)
def test_show_all_options(self):
arglist = [
self._qos_policy.name,
]
verifylist = [
('policy', self._qos_policy.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.network.find_qos_policy.assert_called_once_with(
self._qos_policy.name, ignore_missing=False)
self.assertEqual(self.columns, columns)
self.assertEqual(list(self.data), list(data))

View File

@ -0,0 +1,8 @@
---
features:
- |
Add support for Network QoS policies commands:
``network qos policy create``, ``network qos policy delete``,
``network qos policy list``, ``network qos policy show`` and
``network qos policy set``
[Bug `1609037 <https://bugs.launchpad.net/bugs/1609037>`_]

View File

@ -366,6 +366,12 @@ openstack.network.v2 =
network_set = openstackclient.network.v2.network:SetNetwork
network_show = openstackclient.network.v2.network:ShowNetwork
network_qos_policy_create = openstackclient.network.v2.network_qos_policy:CreateNetworkQosPolicy
network_qos_policy_delete = openstackclient.network.v2.network_qos_policy:DeleteNetworkQosPolicy
network_qos_policy_list = openstackclient.network.v2.network_qos_policy:ListNetworkQosPolicy
network_qos_policy_set = openstackclient.network.v2.network_qos_policy:SetNetworkQosPolicy
network_qos_policy_show = openstackclient.network.v2.network_qos_policy:ShowNetworkQosPolicy
network_rbac_create = openstackclient.network.v2.network_rbac:CreateNetworkRBAC
network_rbac_delete = openstackclient.network.v2.network_rbac:DeleteNetworkRBAC
network_rbac_list = openstackclient.network.v2.network_rbac:ListNetworkRBAC