summaryrefslogtreecommitdiff
path: root/openstackclient/volume
diff options
context:
space:
mode:
authorwhoami-rajat <rajatdhasmana@gmail.com>2023-05-16 17:34:20 +0530
committerwhoami-rajat <rajatdhasmana@gmail.com>2023-05-16 17:38:10 +0530
commitaaeda25e28ba27c7e5d1870eba448e94e4a8aa1b (patch)
treecedcc69e07217706dd5dee2facfd60ff0a08c2b2 /openstackclient/volume
parent3c9afe69bbb249b30e586fd0f8b3dd095d2cab48 (diff)
downloadpython-openstackclient-aaeda25e28ba27c7e5d1870eba448e94e4a8aa1b.tar.gz
Migrate 'volume revert' command to SDK
This patch modifies the existing revert volume to snapshot call from cinderclient to SDK. Change-Id: Iaa9708ebae5d6ab3dfc73e4e2376af32ed098688
Diffstat (limited to 'openstackclient/volume')
-rw-r--r--openstackclient/volume/v3/volume.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/openstackclient/volume/v3/volume.py b/openstackclient/volume/v3/volume.py
index f02053f0..0f2d3c1d 100644
--- a/openstackclient/volume/v3/volume.py
+++ b/openstackclient/volume/v3/volume.py
@@ -17,6 +17,7 @@
import logging
from cinderclient import api_versions
+from openstack import utils as sdk_utils
from osc_lib.cli import format_columns
from osc_lib.command import command
from osc_lib import exceptions
@@ -96,20 +97,22 @@ class VolumeRevertToSnapshot(command.Command):
return parser
def take_action(self, parsed_args):
- volume_client = self.app.client_manager.volume
+ volume_client = self.app.client_manager.sdk_connection.volume
- if volume_client.api_version < api_versions.APIVersion('3.40'):
+ if not sdk_utils.supports_microversion(volume_client, '3.40'):
msg = _(
"--os-volume-api-version 3.40 or greater is required to "
"support the 'volume revert snapshot' command"
)
raise exceptions.CommandError(msg)
- snapshot = utils.find_resource(
- volume_client.volume_snapshots, parsed_args.snapshot
+ snapshot = volume_client.find_snapshot(
+ parsed_args.snapshot,
+ ignore_missing=False,
)
- volume = utils.find_resource(volume_client.volumes, snapshot.volume_id)
-
- volume_client.volumes.revert_to_snapshot(
- volume=volume, snapshot=snapshot
+ volume = volume_client.find_volume(
+ snapshot.volume_id,
+ ignore_missing=False,
)
+
+ volume_client.revert_volume_to_snapshot(volume, snapshot)