Skip to content

Commit 2005a1e

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Allow to resize in-use volumes"
2 parents 24edeb2 + 4c0bfb0 commit 2005a1e

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

openstackclient/volume/client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"1": "cinderclient.v1.client.Client",
3030
"2": "cinderclient.v2.client.Client",
3131
"3": "cinderclient.v3.client.Client",
32+
"3.42": "cinderclient.v3.client.Client",
3233
}
3334

3435

@@ -47,14 +48,19 @@ def make_client(instance):
4748
except Exception:
4849
del API_VERSIONS['1']
4950

50-
if instance._api_version[API_NAME] == '1':
51+
version = instance._api_version[API_NAME]
52+
from cinderclient import api_versions
53+
# convert to APIVersion object
54+
version = api_versions.get_api_version(version)
55+
56+
if version.ver_major == '1':
5157
# Monkey patch for v1 cinderclient
5258
volumes.Volume.NAME_ATTR = 'display_name'
5359
volume_snapshots.Snapshot.NAME_ATTR = 'display_name'
5460

5561
volume_client = utils.get_client_class(
5662
API_NAME,
57-
instance._api_version[API_NAME],
63+
version.ver_major,
5864
API_VERSIONS
5965
)
6066
LOG.debug('Instantiating volume client: %s', volume_client)
@@ -76,6 +82,7 @@ def make_client(instance):
7682
http_log_debug=http_log_debug,
7783
region_name=instance.region_name,
7884
endpoint_override=endpoint_override,
85+
api_version=version,
7986
**kwargs
8087
)
8188

openstackclient/volume/v2/volume.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,16 @@ def take_action(self, parsed_args):
605605
result = 0
606606
if parsed_args.size:
607607
try:
608-
if volume.status != 'available':
609-
msg = (_("Volume is in %s state, it must be available "
610-
"before size can be extended") % volume.status)
611-
raise exceptions.CommandError(msg)
612608
if parsed_args.size <= volume.size:
613609
msg = (_("New size must be greater than %s GB")
614610
% volume.size)
615611
raise exceptions.CommandError(msg)
612+
if volume.status != 'available' and \
613+
not volume_client.api_version.matches('3.42'):
614+
615+
msg = (_("Volume is in %s state, it must be available "
616+
"before size can be extended") % volume.status)
617+
raise exceptions.CommandError(msg)
616618
volume_client.volumes.extend(volume.id, parsed_args.size)
617619
except Exception as e:
618620
LOG.error(_("Failed to set volume size: %s"), e)

0 commit comments

Comments
 (0)