From 4c0bfb03fc688575fa93667bb59d399fd1c6b41d Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 5 Nov 2020 17:51:27 +0200 Subject: Allow to resize in-use volumes Since Pike (microversion 3.42) [1] Cinder API allows to resize in-use volumes. So no reason not to implement it in CLI. [1] https://opendev.org/openstack/cinder/src/branch/master/cinder/api/openstack/rest_api_version_history.rst#user-content-section-39 Change-Id: I22462a56d261e0a100aac3f27af7be47223edec0 --- openstackclient/volume/v2/volume.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'openstackclient/volume/v2/volume.py') diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index 1e0cb183..cab0b2f4 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -605,14 +605,16 @@ class SetVolume(command.Command): result = 0 if parsed_args.size: try: - if volume.status != 'available': - msg = (_("Volume is in %s state, it must be available " - "before size can be extended") % volume.status) - raise exceptions.CommandError(msg) if parsed_args.size <= volume.size: msg = (_("New size must be greater than %s GB") % volume.size) raise exceptions.CommandError(msg) + if volume.status != 'available' and \ + not volume_client.api_version.matches('3.42'): + + msg = (_("Volume is in %s state, it must be available " + "before size can be extended") % volume.status) + raise exceptions.CommandError(msg) volume_client.volumes.extend(volume.id, parsed_args.size) except Exception as e: LOG.error(_("Failed to set volume size: %s"), e) -- cgit v1.2.1