Add no-shared option to qos-policy-update command

QoS policy can now be updated to be not shared with
other tenants if it was shared before.
To set QoS policy as not shared option "--no-shared"
should be passed to qos-policy-update command.
Option '--shared' works still like it was before so
this change is backward compatible.

Change-Id: I18d32813b3c59cbadfe1f4a1b9ba06725a1d7bb8
Closes-Bug: #1590942
This commit is contained in:
Sławek Kapłoński 2016-06-09 20:39:03 +00:00 committed by Akihiro Motoki
parent 7099f6e0ba
commit 521ff7cee5
3 changed files with 47 additions and 2 deletions

View File

@ -126,11 +126,17 @@ class UpdateQoSPolicy(neutronv20.UpdateCommand):
parser.add_argument(
'--description',
help=_('Description of the QoS policy.'))
parser.add_argument(
shared_group = parser.add_mutually_exclusive_group()
shared_group.add_argument(
'--shared',
action='store_true',
help=_('Accessible by other tenants. '
'Set shared to True (default is False).'))
shared_group.add_argument(
'--no-shared',
action='store_true',
help=_('Not accessible by other tenants. '
'Set shared to False.'))
def args2body(self, parsed_args):
body = {}
@ -139,7 +145,10 @@ class UpdateQoSPolicy(neutronv20.UpdateCommand):
if parsed_args.description:
body['description'] = parsed_args.description
if parsed_args.shared:
body['shared'] = parsed_args.shared
body['shared'] = True
if parsed_args.no_shared:
body['shared'] = False
return {self.resource: body}

View File

@ -104,6 +104,36 @@ class CLITestV20QoSPolicyJSON(test_cli20.CLITestV20Base):
{'description': 'newdesc', },
cmd_resource=self.cmd_res)
def test_update_policy_to_shared(self):
# policy-update myid --shared
cmd = policy.UpdateQoSPolicy(test_cli20.MyApp(sys.stdout),
None)
self._test_update_resource(self.res, cmd, 'myid',
['myid', '--shared'],
{'shared': True, },
cmd_resource=self.cmd_res)
def test_update_policy_to_no_shared(self):
# policy-update myid --no-shared
cmd = policy.UpdateQoSPolicy(test_cli20.MyApp(sys.stdout),
None)
self._test_update_resource(self.res, cmd, 'myid',
['myid', '--no-shared'],
{'shared': False, },
cmd_resource=self.cmd_res)
def test_update_policy_to_shared_no_shared_together(self):
# policy-update myid --shared --no-shared
cmd = policy.UpdateQoSPolicy(test_cli20.MyApp(sys.stdout),
None)
self.assertRaises(
SystemExit,
self._test_update_resource,
self.res, cmd, 'myid',
['myid', '--shared', '--no-shared'], {},
cmd_resource=self.cmd_res
)
def test_list_policies(self):
# qos-policy-list.
cmd = policy.ListQoSPolicy(test_cli20.MyApp(sys.stdout),

View File

@ -0,0 +1,6 @@
---
fixes:
- |
CLI support to set QoS policy as not shared if it was shared before.
The ``qos-policy-update`` command include a ``--no-shared`` option.
Closes `bug 1590942 <https://bugs.launchpad.net/python-neutronclient/+bug/1590942>`_.