summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTerryHowe <terrylhowe@gmail.com>2015-07-06 11:22:05 -0600
committerTerry Howe <terrylhowe@gmail.com>2015-07-17 14:14:56 +0000
commitabfb0115277471dd584daed18e09eeecf768b527 (patch)
tree10d2add86c8a1932a9067724108c78a51b79fe1e
parentbbe71eb9a310c67f6c8a1b8da1b2fb2ec37fd3ab (diff)
downloadpython-openstackclient-abfb0115277471dd584daed18e09eeecf768b527.tar.gz
Support multiple volume qos delete
Also make sure that we are using the singular qos_spec when we should and the plural qos_specs otherwise. Change-Id: If4bbeb6fc245d7d80dc3d7dccfe9f949e802653c
-rw-r--r--doc/source/command-objects/volume_qos.rst26
-rw-r--r--openstackclient/tests/volume/v1/test_qos_specs.py16
-rw-r--r--openstackclient/tests/volume/v2/test_qos_specs.py16
-rw-r--r--openstackclient/volume/v1/qos_specs.py75
-rw-r--r--openstackclient/volume/v2/qos_specs.py75
5 files changed, 103 insertions, 105 deletions
diff --git a/doc/source/command-objects/volume_qos.rst b/doc/source/command-objects/volume_qos.rst
index 287059f1..d0fe36f9 100644
--- a/doc/source/command-objects/volume_qos.rst
+++ b/doc/source/command-objects/volume_qos.rst
@@ -13,10 +13,10 @@ Associate a QoS specification to a volume type
.. code:: bash
os volume qos associate
- <qos-specs>
+ <qos-spec>
<volume-type>
-.. describe:: <qos-specs>
+.. describe:: <qos-spec>
QoS specification to modify (name or ID)
@@ -58,11 +58,11 @@ Delete QoS specification
.. code:: bash
os volume qos delete
- <qos-specs>
+ <qos-spec> [<qos-spec> ...]
-.. describe:: <qos-specs>
+.. describe:: <qos-spec>
- QoS specification to delete (name or ID)
+ QoS specification(s) to delete (name or ID)
volume qos disassociate
-----------------------
@@ -74,7 +74,7 @@ Disassociate a QoS specification from a volume type
os volume qos disassociate
--volume-type <volume-type> | --all
- <qos-specs>
+ <qos-spec>
.. option:: --volume-type <volume-type>
@@ -84,7 +84,7 @@ Disassociate a QoS specification from a volume type
Disassociate the QoS from every volume type
-.. describe:: <qos-specs>
+.. describe:: <qos-spec>
QoS specification to modify (name or ID)
@@ -108,13 +108,13 @@ Set QoS specification properties
os volume qos set
[--property <key=value> [...] ]
- <qos-specs>
+ <qos-spec>
.. option:: --property <key=value>
Property to add or modify for this QoS specification (repeat option to set multiple properties)
-.. describe:: <qos-specs>
+.. describe:: <qos-spec>
QoS specification to modify (name or ID)
@@ -127,9 +127,9 @@ Display QoS specification details
.. code:: bash
os volume qos show
- <qos-specs>
+ <qos-spec>
-.. describe:: <qos-specs>
+.. describe:: <qos-spec>
QoS specification to display (name or ID)
@@ -143,12 +143,12 @@ Unset QoS specification properties
os volume qos unset
[--property <key>]
- <qos-specs>
+ <qos-spec>
.. option:: --property <key>
Property to remove from QoS specification (repeat option to remove multiple properties)
-.. describe:: <qos-specs>
+.. describe:: <qos-spec>
QoS specification to modify (name or ID)
diff --git a/openstackclient/tests/volume/v1/test_qos_specs.py b/openstackclient/tests/volume/v1/test_qos_specs.py
index 226fe673..c2e6c0af 100644
--- a/openstackclient/tests/volume/v1/test_qos_specs.py
+++ b/openstackclient/tests/volume/v1/test_qos_specs.py
@@ -56,7 +56,7 @@ class TestQosAssociate(TestQos):
volume_fakes.type_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('volume_type', volume_fakes.type_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -210,7 +210,7 @@ class TestQosDelete(TestQos):
volume_fakes.qos_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id)
+ ('qos_specs', [volume_fakes.qos_id])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -223,7 +223,7 @@ class TestQosDelete(TestQos):
volume_fakes.qos_name
]
verifylist = [
- ('qos_specs', volume_fakes.qos_name)
+ ('qos_specs', [volume_fakes.qos_name])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -255,7 +255,7 @@ class TestQosDisassociate(TestQos):
'--volume-type', volume_fakes.type_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('volume_type', volume_fakes.type_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -278,7 +278,7 @@ class TestQosDisassociate(TestQos):
'--all'
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id)
+ ('qos_spec', volume_fakes.qos_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -351,7 +351,7 @@ class TestQosSet(TestQos):
'--property', 'iops=9001'
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('property', volume_fakes.qos_specs)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -386,7 +386,7 @@ class TestQosShow(TestQos):
volume_fakes.qos_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id)
+ ('qos_spec', volume_fakes.qos_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -434,7 +434,7 @@ class TestQosUnset(TestQos):
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('property', ['iops', 'foo'])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
diff --git a/openstackclient/tests/volume/v2/test_qos_specs.py b/openstackclient/tests/volume/v2/test_qos_specs.py
index 6a550988..4222ed07 100644
--- a/openstackclient/tests/volume/v2/test_qos_specs.py
+++ b/openstackclient/tests/volume/v2/test_qos_specs.py
@@ -56,7 +56,7 @@ class TestQosAssociate(TestQos):
volume_fakes.type_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('volume_type', volume_fakes.type_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -210,7 +210,7 @@ class TestQosDelete(TestQos):
volume_fakes.qos_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id)
+ ('qos_specs', [volume_fakes.qos_id])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -223,7 +223,7 @@ class TestQosDelete(TestQos):
volume_fakes.qos_name
]
verifylist = [
- ('qos_specs', volume_fakes.qos_name)
+ ('qos_specs', [volume_fakes.qos_name])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -255,7 +255,7 @@ class TestQosDisassociate(TestQos):
'--volume-type', volume_fakes.type_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('volume_type', volume_fakes.type_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -278,7 +278,7 @@ class TestQosDisassociate(TestQos):
'--all'
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id)
+ ('qos_spec', volume_fakes.qos_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -351,7 +351,7 @@ class TestQosSet(TestQos):
'--property', 'iops=9001'
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('property', volume_fakes.qos_specs)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -386,7 +386,7 @@ class TestQosShow(TestQos):
volume_fakes.qos_id
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id)
+ ('qos_spec', volume_fakes.qos_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -434,7 +434,7 @@ class TestQosUnset(TestQos):
]
verifylist = [
- ('qos_specs', volume_fakes.qos_id),
+ ('qos_spec', volume_fakes.qos_id),
('property', ['iops', 'foo'])
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
diff --git a/openstackclient/volume/v1/qos_specs.py b/openstackclient/volume/v1/qos_specs.py
index eacb9706..8e909e3d 100644
--- a/openstackclient/volume/v1/qos_specs.py
+++ b/openstackclient/volume/v1/qos_specs.py
@@ -34,8 +34,8 @@ class AssociateQos(command.Command):
def get_parser(self, prog_name):
parser = super(AssociateQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
parser.add_argument(
@@ -48,12 +48,12 @@ class AssociateQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
volume_type = utils.find_resource(volume_client.volume_types,
parsed_args.volume_type)
- volume_client.qos_specs.associate(qos_specs.id, volume_type.id)
+ volume_client.qos_specs.associate(qos_spec.id, volume_type.id)
return
@@ -97,9 +97,9 @@ class CreateQos(show.ShowOne):
if parsed_args.property:
specs.update(parsed_args.property)
- qos_specs = volume_client.qos_specs.create(parsed_args.name, specs)
+ qos_spec = volume_client.qos_specs.create(parsed_args.name, specs)
- return zip(*sorted(six.iteritems(qos_specs._info)))
+ return zip(*sorted(six.iteritems(qos_spec._info)))
class DeleteQos(command.Command):
@@ -111,19 +111,18 @@ class DeleteQos(command.Command):
parser = super(DeleteQos, self).get_parser(prog_name)
parser.add_argument(
'qos_specs',
- metavar='<qos-specs>',
- help='QoS specification to delete (name or ID)',
+ metavar='<qos-spec>',
+ nargs="+",
+ help='QoS specification(s) to delete (name or ID)',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
-
- volume_client.qos_specs.delete(qos_specs.id)
-
+ for qos in parsed_args.qos_specs:
+ qos_spec = utils.find_resource(volume_client.qos_specs, qos)
+ volume_client.qos_specs.delete(qos_spec.id)
return
@@ -135,8 +134,8 @@ class DisassociateQos(command.Command):
def get_parser(self, prog_name):
parser = super(DisassociateQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
volume_type_group = parser.add_mutually_exclusive_group()
@@ -157,15 +156,15 @@ class DisassociateQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
if parsed_args.volume_type:
volume_type = utils.find_resource(volume_client.volume_types,
parsed_args.volume_type)
- volume_client.qos_specs.disassociate(qos_specs.id, volume_type.id)
+ volume_client.qos_specs.disassociate(qos_spec.id, volume_type.id)
elif parsed_args.all:
- volume_client.qos_specs.disassociate_all(qos_specs.id)
+ volume_client.qos_specs.disassociate_all(qos_spec.id)
return
@@ -206,8 +205,8 @@ class SetQos(command.Command):
def get_parser(self, prog_name):
parser = super(SetQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
parser.add_argument(
@@ -222,11 +221,11 @@ class SetQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
if parsed_args.property:
- volume_client.qos_specs.set_keys(qos_specs.id,
+ volume_client.qos_specs.set_keys(qos_spec.id,
parsed_args.property)
else:
self.app.log.error("No changes requested\n")
@@ -242,8 +241,8 @@ class ShowQos(show.ShowOne):
def get_parser(self, prog_name):
parser = super(ShowQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to display (name or ID)',
)
return parser
@@ -251,19 +250,19 @@ class ShowQos(show.ShowOne):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
- qos_associations = volume_client.qos_specs.get_associations(qos_specs)
+ qos_associations = volume_client.qos_specs.get_associations(qos_spec)
if qos_associations:
associations = [association.name
for association in qos_associations]
- qos_specs._info.update({
+ qos_spec._info.update({
'associations': utils.format_list(associations)
})
- qos_specs._info.update({'specs': utils.format_dict(qos_specs.specs)})
+ qos_spec._info.update({'specs': utils.format_dict(qos_spec.specs)})
- return zip(*sorted(six.iteritems(qos_specs._info)))
+ return zip(*sorted(six.iteritems(qos_spec._info)))
class UnsetQos(command.Command):
@@ -274,8 +273,8 @@ class UnsetQos(command.Command):
def get_parser(self, prog_name):
parser = super(UnsetQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
parser.add_argument(
@@ -291,11 +290,11 @@ class UnsetQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
if parsed_args.property:
- volume_client.qos_specs.unset_keys(qos_specs.id,
+ volume_client.qos_specs.unset_keys(qos_spec.id,
parsed_args.property)
else:
self.app.log.error("No changes requested\n")
diff --git a/openstackclient/volume/v2/qos_specs.py b/openstackclient/volume/v2/qos_specs.py
index 7f02fa4a..ac78ca15 100644
--- a/openstackclient/volume/v2/qos_specs.py
+++ b/openstackclient/volume/v2/qos_specs.py
@@ -34,8 +34,8 @@ class AssociateQos(command.Command):
def get_parser(self, prog_name):
parser = super(AssociateQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
parser.add_argument(
@@ -48,12 +48,12 @@ class AssociateQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
volume_type = utils.find_resource(volume_client.volume_types,
parsed_args.volume_type)
- volume_client.qos_specs.associate(qos_specs.id, volume_type.id)
+ volume_client.qos_specs.associate(qos_spec.id, volume_type.id)
return
@@ -97,9 +97,9 @@ class CreateQos(show.ShowOne):
if parsed_args.property:
specs.update(parsed_args.property)
- qos_specs = volume_client.qos_specs.create(parsed_args.name, specs)
+ qos_spec = volume_client.qos_specs.create(parsed_args.name, specs)
- return zip(*sorted(six.iteritems(qos_specs._info)))
+ return zip(*sorted(six.iteritems(qos_spec._info)))
class DeleteQos(command.Command):
@@ -111,19 +111,18 @@ class DeleteQos(command.Command):
parser = super(DeleteQos, self).get_parser(prog_name)
parser.add_argument(
'qos_specs',
- metavar='<qos-specs>',
- help='QoS specification to delete (name or ID)',
+ metavar='<qos-spec>',
+ nargs="+",
+ help='QoS specification(s) to delete (name or ID)',
)
return parser
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
-
- volume_client.qos_specs.delete(qos_specs.id)
-
+ for qos in parsed_args.qos_specs:
+ qos_spec = utils.find_resource(volume_client.qos_specs, qos)
+ volume_client.qos_specs.delete(qos_spec.id)
return
@@ -135,8 +134,8 @@ class DisassociateQos(command.Command):
def get_parser(self, prog_name):
parser = super(DisassociateQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
volume_type_group = parser.add_mutually_exclusive_group()
@@ -157,15 +156,15 @@ class DisassociateQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
if parsed_args.volume_type:
volume_type = utils.find_resource(volume_client.volume_types,
parsed_args.volume_type)
- volume_client.qos_specs.disassociate(qos_specs.id, volume_type.id)
+ volume_client.qos_specs.disassociate(qos_spec.id, volume_type.id)
elif parsed_args.all:
- volume_client.qos_specs.disassociate_all(qos_specs.id)
+ volume_client.qos_specs.disassociate_all(qos_spec.id)
return
@@ -206,8 +205,8 @@ class SetQos(command.Command):
def get_parser(self, prog_name):
parser = super(SetQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
parser.add_argument(
@@ -222,11 +221,11 @@ class SetQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
if parsed_args.property:
- volume_client.qos_specs.set_keys(qos_specs.id,
+ volume_client.qos_specs.set_keys(qos_spec.id,
parsed_args.property)
else:
self.app.log.error("No changes requested\n")
@@ -242,8 +241,8 @@ class ShowQos(show.ShowOne):
def get_parser(self, prog_name):
parser = super(ShowQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to display (name or ID)',
)
return parser
@@ -251,19 +250,19 @@ class ShowQos(show.ShowOne):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
- qos_associations = volume_client.qos_specs.get_associations(qos_specs)
+ qos_associations = volume_client.qos_specs.get_associations(qos_spec)
if qos_associations:
associations = [association.name
for association in qos_associations]
- qos_specs._info.update({
+ qos_spec._info.update({
'associations': utils.format_list(associations)
})
- qos_specs._info.update({'specs': utils.format_dict(qos_specs.specs)})
+ qos_spec._info.update({'specs': utils.format_dict(qos_spec.specs)})
- return zip(*sorted(six.iteritems(qos_specs._info)))
+ return zip(*sorted(six.iteritems(qos_spec._info)))
class UnsetQos(command.Command):
@@ -274,8 +273,8 @@ class UnsetQos(command.Command):
def get_parser(self, prog_name):
parser = super(UnsetQos, self).get_parser(prog_name)
parser.add_argument(
- 'qos_specs',
- metavar='<qos-specs>',
+ 'qos_spec',
+ metavar='<qos-spec>',
help='QoS specification to modify (name or ID)',
)
parser.add_argument(
@@ -291,11 +290,11 @@ class UnsetQos(command.Command):
def take_action(self, parsed_args):
self.log.debug('take_action(%s)', parsed_args)
volume_client = self.app.client_manager.volume
- qos_specs = utils.find_resource(volume_client.qos_specs,
- parsed_args.qos_specs)
+ qos_spec = utils.find_resource(volume_client.qos_specs,
+ parsed_args.qos_spec)
if parsed_args.property:
- volume_client.qos_specs.unset_keys(qos_specs.id,
+ volume_client.qos_specs.unset_keys(qos_spec.id,
parsed_args.property)
else:
self.app.log.error("No changes requested\n")