Add the ability to extend volumes in osc volume set

Create a --size option for volume set, so the user may extend
a volume's size.

Change-Id: Ic8d3396d788a14ea1e10bf1da73edfd7f5d85070
Closes-Bug: #1413954
This commit is contained in:
Steve Martinelli 2015-01-25 00:13:26 -05:00
parent 71e0e5332a
commit 4ff020006e
2 changed files with 19 additions and 1 deletions
doc/source/command-objects
openstackclient/volume/v1

@ -134,6 +134,7 @@ Set volume properties
os volume set
[--name <name>]
[--description <description>]
[--size <size>]
[--property <key=value> [...] ]
<volume>
@ -145,6 +146,10 @@ Set volume properties
New volume description
.. option:: --size <size>
Extend volume size in GB
.. option:: --property <key=value>
Property to add or modify for this volume (repeat option to set multiple properties)

@ -327,6 +327,12 @@ class SetVolume(command.Command):
metavar='<description>',
help='New volume description',
)
parser.add_argument(
'--size',
metavar='<size>',
type=int,
help='Extend volume size in GB',
)
parser.add_argument(
'--property',
metavar='<key=value>',
@ -341,6 +347,13 @@ class SetVolume(command.Command):
volume_client = self.app.client_manager.volume
volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
if parsed_args.size:
if parsed_args.size <= volume.size:
self.app.log.error("New size must be greater than %s GB" %
volume.size)
return
volume_client.volumes.extend(volume.id, parsed_args.size)
if parsed_args.property:
volume_client.volumes.set_metadata(volume.id, parsed_args.property)
@ -352,7 +365,7 @@ class SetVolume(command.Command):
if kwargs:
volume_client.volumes.update(volume.id, **kwargs)
if not kwargs and not parsed_args.property:
if not kwargs and not parsed_args.property and not parsed_args.size:
self.app.log.error("No changes requested\n")
return