Skip to content

Commit 55cbb84

Browse files
committed
volume: Migrate 'volume list' to compute SDK
Change-Id: Iae662aa6b391ba6ae5f569184c7d19fb3654be35 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 9f30ee9 commit 55cbb84

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

openstackclient/volume/v1/volume.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ def get_parser(self, prog_name):
378378

379379
def take_action(self, parsed_args):
380380
volume_client = self.app.client_manager.volume
381-
compute_client = self.app.client_manager.compute
382381

383382
if parsed_args.long:
384383
columns = (
@@ -420,7 +419,8 @@ def take_action(self, parsed_args):
420419
# Cache the server list
421420
server_cache = {}
422421
try:
423-
for s in compute_client.servers.list():
422+
compute_client = self.app.client_manager.sdk_connection.compute
423+
for s in compute_client.servers():
424424
server_cache[s.id] = s
425425
except Exception:
426426
# Just forget it if there's any trouble

openstackclient/volume/v2/volume.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import logging
2121

2222
from cliff import columns as cliff_columns
23+
from openstack import exceptions as sdk_exceptions
2324
from osc_lib.cli import format_columns
2425
from osc_lib.cli import parseractions
2526
from osc_lib.command import command
@@ -507,10 +508,10 @@ def take_action(self, parsed_args):
507508
server_cache = {}
508509
if do_server_list:
509510
try:
510-
compute_client = self.app.client_manager.compute
511-
for s in compute_client.servers.list():
511+
compute_client = self.app.client_manager.sdk_connection.compute
512+
for s in compute_client.servers():
512513
server_cache[s.id] = s
513-
except Exception:
514+
except sdk_exceptions.SDKException:
514515
# Just forget it if there's any trouble
515516
pass # nosec: B110
516517
AttachmentsColumnWithCache = functools.partial(

openstackclient/volume/v3/volume.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import logging
2121

2222
from cliff import columns as cliff_columns
23+
from openstack import exceptions as sdk_exceptions
2324
from openstack import utils as sdk_utils
2425
from osc_lib.cli import format_columns
2526
from osc_lib.cli import parseractions
@@ -522,10 +523,10 @@ def take_action(self, parsed_args):
522523
server_cache = {}
523524
if do_server_list:
524525
try:
525-
compute_client = self.app.client_manager.compute
526-
for s in compute_client.servers.list():
526+
compute_client = self.app.client_manager.sdk_connection.compute
527+
for s in compute_client.servers():
527528
server_cache[s.id] = s
528-
except Exception:
529+
except sdk_exceptions.SDKException:
529530
# Just forget it if there's any trouble
530531
pass # nosec: B110
531532
AttachmentsColumnWithCache = functools.partial(

0 commit comments

Comments
 (0)