summaryrefslogtreecommitdiff
path: root/openstackclient/volume
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2021-07-13 20:29:43 +0100
committerStephen Finucane <sfinucan@redhat.com>2021-07-13 20:33:35 +0100
commita821d6b7c57c7684a990ee39b6b93d5085f25a70 (patch)
tree7f161f2b6140920938cb48f8aac7e68ace55991b /openstackclient/volume
parent4891bb38208fdcd1a2ae60e47b056841e14fbdf7 (diff)
downloadpython-openstackclient-a821d6b7c57c7684a990ee39b6b93d5085f25a70.tar.gz
volume: Add 'volume transfer request create --(no-)snapshots' option
This closes a gap with cinderclient's 'transfer-create' command. Change-Id: I7386a7be15c0e3ee87abbcfc2275ba8524c10ff8 Signed-off-by: Stephen Finucane <sfinucan@redhat.com> Story: 2009054 Task: 42831
Diffstat (limited to 'openstackclient/volume')
-rw-r--r--openstackclient/volume/v2/volume_transfer_request.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/openstackclient/volume/v2/volume_transfer_request.py b/openstackclient/volume/v2/volume_transfer_request.py
index 2a1ace1f..89199336 100644
--- a/openstackclient/volume/v2/volume_transfer_request.py
+++ b/openstackclient/volume/v2/volume_transfer_request.py
@@ -16,6 +16,7 @@
import logging
+from cinderclient import api_versions
from osc_lib.command import command
from osc_lib import exceptions
from osc_lib import utils
@@ -77,6 +78,25 @@ class CreateTransferRequest(command.ShowOne):
help=_('New transfer request name (default to None)'),
)
parser.add_argument(
+ '--snapshots',
+ action='store_true',
+ dest='snapshots',
+ help=_(
+ 'Allow transfer volumes without snapshots (default) '
+ '(supported by --os-volume-api-version 3.55 or later)'
+ ),
+ default=None,
+ )
+ parser.add_argument(
+ '--no-snapshots',
+ action='store_false',
+ dest='snapshots',
+ help=_(
+ 'Disallow transfer volumes without snapshots '
+ '(supported by --os-volume-api-version 3.55 or later)'
+ ),
+ )
+ parser.add_argument(
'volume',
metavar="<volume>",
help=_('Volume to transfer (name or ID)'),
@@ -85,6 +105,21 @@ class CreateTransferRequest(command.ShowOne):
def take_action(self, parsed_args):
volume_client = self.app.client_manager.volume
+
+ kwargs = {}
+
+ if parsed_args.snapshots is not None:
+ if volume_client.api_version < api_versions.APIVersion('3.55'):
+ msg = _(
+ "--os-volume-api-version 3.55 or greater is required to "
+ "support the '--(no-)snapshots' option"
+ )
+ raise exceptions.CommandError(msg)
+
+ # unfortunately this option is negative so we have to reverse
+ # things
+ kwargs['no_snapshots'] = not parsed_args.snapshots
+
volume_id = utils.find_resource(
volume_client.volumes,
parsed_args.volume,
@@ -92,6 +127,7 @@ class CreateTransferRequest(command.ShowOne):
volume_transfer_request = volume_client.transfers.create(
volume_id,
parsed_args.name,
+ **kwargs,
)
volume_transfer_request._info.pop("links", None)