Skip to content

Commit c3aad41

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add the ability to extend volumes in osc volume set"
2 parents 2c03f6f + 4ff0200 commit c3aad41

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

doc/source/command-objects/volume.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Set volume properties
134134
os volume set
135135
[--name <name>]
136136
[--description <description>]
137+
[--size <size>]
137138
[--property <key=value> [...] ]
138139
<volume>
139140
@@ -145,6 +146,10 @@ Set volume properties
145146

146147
New volume description
147148

149+
.. option:: --size <size>
150+
151+
Extend volume size in GB
152+
148153
.. option:: --property <key=value>
149154

150155
Property to add or modify for this volume (repeat option to set multiple properties)

openstackclient/volume/v1/volume.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ def get_parser(self, prog_name):
327327
metavar='<description>',
328328
help='New volume description',
329329
)
330+
parser.add_argument(
331+
'--size',
332+
metavar='<size>',
333+
type=int,
334+
help='Extend volume size in GB',
335+
)
330336
parser.add_argument(
331337
'--property',
332338
metavar='<key=value>',
@@ -341,6 +347,13 @@ def take_action(self, parsed_args):
341347
volume_client = self.app.client_manager.volume
342348
volume = utils.find_resource(volume_client.volumes, parsed_args.volume)
343349

350+
if parsed_args.size:
351+
if parsed_args.size <= volume.size:
352+
self.app.log.error("New size must be greater than %s GB" %
353+
volume.size)
354+
return
355+
volume_client.volumes.extend(volume.id, parsed_args.size)
356+
344357
if parsed_args.property:
345358
volume_client.volumes.set_metadata(volume.id, parsed_args.property)
346359

@@ -352,7 +365,7 @@ def take_action(self, parsed_args):
352365
if kwargs:
353366
volume_client.volumes.update(volume.id, **kwargs)
354367

355-
if not kwargs and not parsed_args.property:
368+
if not kwargs and not parsed_args.property and not parsed_args.size:
356369
self.app.log.error("No changes requested\n")
357370

358371
return

0 commit comments

Comments
 (0)