diff options
| author | Brian Rosmaita <rosmaita.fossdev@gmail.com> | 2022-11-08 11:58:38 -0500 |
|---|---|---|
| committer | Brian Rosmaita <rosmaita.fossdev@gmail.com> | 2022-11-08 18:48:18 -0500 |
| commit | 9df653571d4da06c25222189be27e87a6da75628 (patch) | |
| tree | 86a222edebb9fc3a763a7ef1fd71507fef4d1715 /cinderclient/v3 | |
| parent | 6f67187b8255ae231f82a9deaaf9156c868153a0 (diff) | |
| download | python-cinderclient-9.2.0.tar.gz | |
Handle downgraded client for snapshot-create9.2.0
When a CLI user specifies --os-volume api-version 3.66, the shell
will execute the appropriate shell code, but if the server only
supports < 3.66, the client is automatically downgraded and correctly
uses the pre-3.66 SnapshotManager.create() method.
In that case, the 'force' parameter, which is technically not allowed
in mv 3.66 (but which silently accepts a True value for backward
compatibility), will have a value of None, which the pre-3.66 code
happily passes to cinder as '"force": null' in the request body, and
which then fails the Block Storage API request-schema check.
Handle this situation by detecting a None 'force' value and setting
it to its pre-3.66 default value of False.
Change-Id: I3ad8283c2a9aaac58c8d2b50fa7ac86b617e5dd3
Closes-bug: #1995883
Diffstat (limited to 'cinderclient/v3')
| -rw-r--r-- | cinderclient/v3/shell.py | 2 | ||||
| -rw-r--r-- | cinderclient/v3/volume_snapshots.py | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index 60239c7..2ea1848 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -2213,6 +2213,7 @@ def do_snapshot_list(cs, args): 'than forcing it to be available. From microversion 3.66, ' 'all snapshots are "forced" and this option is invalid. ' 'Default=False.') +# FIXME: is this second declaration of --force really necessary? @utils.arg('--force', metavar='<True>', nargs='?', @@ -2253,6 +2254,7 @@ def do_snapshot_create(cs, args): snapshot_metadata = shell_utils.extract_metadata(args) volume = utils.find_volume(cs, args.volume) + snapshot = cs.volume_snapshots.create(volume.id, args.force, args.name, diff --git a/cinderclient/v3/volume_snapshots.py b/cinderclient/v3/volume_snapshots.py index 9a94422..cb1c3ba 100644 --- a/cinderclient/v3/volume_snapshots.py +++ b/cinderclient/v3/volume_snapshots.py @@ -108,6 +108,20 @@ class SnapshotManager(base.ManagerWithFind): else: snapshot_metadata = metadata + # Bug #1995883: it's possible for the shell to use the user- + # specified 3.66 do_snapshot_create function, but if the server + # only supports < 3.66, the client will have been downgraded and + # will use this function. In that case, the 'force' parameter will + # be None, which means that the user didn't specify a value for it, + # so we set it to the pre-3.66 default value of False. + # + # NOTE: we know this isn't a problem for current client consumers + # because a null value for 'force' has never been allowed by the + # Block Storage API v3, so there's no reason for anyone to directly + # call this method passing force=None. + if force is None: + force = False + body = {'snapshot': {'volume_id': volume_id, 'force': force, 'name': name, |
