diff options
| author | Dmitriy Rabotyagov <noonedeadpunk@ya.ru> | 2020-11-05 17:51:27 +0200 |
|---|---|---|
| committer | Dmitriy Rabotyagov (noonedeadpunk) <noonedeadpunk@ya.ru> | 2020-11-11 09:18:49 +0000 |
| commit | 4c0bfb03fc688575fa93667bb59d399fd1c6b41d (patch) | |
| tree | 91f905fa8b13af7a90728ef690941480212d227f /openstackclient/volume/v2/volume.py | |
| parent | e2bd1530cf1fc5a84af4dc88829f3c73cdf694f2 (diff) | |
| download | python-openstackclient-4c0bfb03fc688575fa93667bb59d399fd1c6b41d.tar.gz | |
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
Diffstat (limited to 'openstackclient/volume/v2/volume.py')
| -rw-r--r-- | openstackclient/volume/v2/volume.py | 10 |
1 files changed, 6 insertions, 4 deletions
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) |
