From 55cbb84e60fe3fec275da605c4d7a4ddc171777d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 7 May 2024 15:46:35 +0100 Subject: [PATCH] volume: Migrate 'volume list' to compute SDK Change-Id: Iae662aa6b391ba6ae5f569184c7d19fb3654be35 Signed-off-by: Stephen Finucane --- openstackclient/volume/v1/volume.py | 4 ++-- openstackclient/volume/v2/volume.py | 7 ++++--- openstackclient/volume/v3/volume.py | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/openstackclient/volume/v1/volume.py b/openstackclient/volume/v1/volume.py index 3f1eea16b8..c60625ee91 100644 --- a/openstackclient/volume/v1/volume.py +++ b/openstackclient/volume/v1/volume.py @@ -378,7 +378,6 @@ class ListVolume(command.Lister): def take_action(self, parsed_args): volume_client = self.app.client_manager.volume - compute_client = self.app.client_manager.compute if parsed_args.long: columns = ( @@ -420,7 +419,8 @@ class ListVolume(command.Lister): # Cache the server list server_cache = {} try: - for s in compute_client.servers.list(): + compute_client = self.app.client_manager.sdk_connection.compute + for s in compute_client.servers(): server_cache[s.id] = s except Exception: # Just forget it if there's any trouble diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index 53a19d4297..b5a4a1ffc9 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -20,6 +20,7 @@ import functools import logging from cliff import columns as cliff_columns +from openstack import exceptions as sdk_exceptions from osc_lib.cli import format_columns from osc_lib.cli import parseractions from osc_lib.command import command @@ -507,10 +508,10 @@ class ListVolume(command.Lister): server_cache = {} if do_server_list: try: - compute_client = self.app.client_manager.compute - for s in compute_client.servers.list(): + compute_client = self.app.client_manager.sdk_connection.compute + for s in compute_client.servers(): server_cache[s.id] = s - except Exception: + except sdk_exceptions.SDKException: # Just forget it if there's any trouble pass # nosec: B110 AttachmentsColumnWithCache = functools.partial( diff --git a/openstackclient/volume/v3/volume.py b/openstackclient/volume/v3/volume.py index e1f025c75a..3bb3cdaed5 100644 --- a/openstackclient/volume/v3/volume.py +++ b/openstackclient/volume/v3/volume.py @@ -20,6 +20,7 @@ import functools import logging from cliff import columns as cliff_columns +from openstack import exceptions as sdk_exceptions from openstack import utils as sdk_utils from osc_lib.cli import format_columns from osc_lib.cli import parseractions @@ -522,10 +523,10 @@ class ListVolume(command.Lister): server_cache = {} if do_server_list: try: - compute_client = self.app.client_manager.compute - for s in compute_client.servers.list(): + compute_client = self.app.client_manager.sdk_connection.compute + for s in compute_client.servers(): server_cache[s.id] = s - except Exception: + except sdk_exceptions.SDKException: # Just forget it if there's any trouble pass # nosec: B110 AttachmentsColumnWithCache = functools.partial(