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:
parent
71e0e5332a
commit
4ff020006e
@ -134,6 +134,7 @@ Set volume properties
|
|||||||
os volume set
|
os volume set
|
||||||
[--name <name>]
|
[--name <name>]
|
||||||
[--description <description>]
|
[--description <description>]
|
||||||
|
[--size <size>]
|
||||||
[--property <key=value> [...] ]
|
[--property <key=value> [...] ]
|
||||||
<volume>
|
<volume>
|
||||||
|
|
||||||
@ -145,6 +146,10 @@ Set volume properties
|
|||||||
|
|
||||||
New volume description
|
New volume description
|
||||||
|
|
||||||
|
.. option:: --size <size>
|
||||||
|
|
||||||
|
Extend volume size in GB
|
||||||
|
|
||||||
.. option:: --property <key=value>
|
.. option:: --property <key=value>
|
||||||
|
|
||||||
Property to add or modify for this volume (repeat option to set multiple properties)
|
Property to add or modify for this volume (repeat option to set multiple properties)
|
||||||
|
@ -327,6 +327,12 @@ class SetVolume(command.Command):
|
|||||||
metavar='<description>',
|
metavar='<description>',
|
||||||
help='New volume description',
|
help='New volume description',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--size',
|
||||||
|
metavar='<size>',
|
||||||
|
type=int,
|
||||||
|
help='Extend volume size in GB',
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--property',
|
'--property',
|
||||||
metavar='<key=value>',
|
metavar='<key=value>',
|
||||||
@ -341,6 +347,13 @@ class SetVolume(command.Command):
|
|||||||
volume_client = self.app.client_manager.volume
|
volume_client = self.app.client_manager.volume
|
||||||
volume = utils.find_resource(volume_client.volumes, parsed_args.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:
|
if parsed_args.property:
|
||||||
volume_client.volumes.set_metadata(volume.id, parsed_args.property)
|
volume_client.volumes.set_metadata(volume.id, parsed_args.property)
|
||||||
|
|
||||||
@ -352,7 +365,7 @@ class SetVolume(command.Command):
|
|||||||
if kwargs:
|
if kwargs:
|
||||||
volume_client.volumes.update(volume.id, **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")
|
self.app.log.error("No changes requested\n")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user