Skip to content

Commit f3207bd

Browse files
committed
Fix availability zone list command
there are two problems currently: - SDK's `availability_zones()` returns a generator that raises errors only when actually accessing its items - the error raised is the sdk exception, not nova one, and thus is not being handled correctly As a result, currently nova AZs can not be listed by non-admins. Story: 2010989 Task: 49220 Change-Id: Ia299faea85857d3fc3a9b539800f3483f84ccbc0
1 parent 2642b07 commit f3207bd

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

openstackclient/common/availability_zone.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import copy
1717
import logging
1818

19-
from novaclient import exceptions as nova_exceptions
19+
from openstack import exceptions as sdk_exceptions
2020
from osc_lib.command import command
2121
from osc_lib import utils
2222

@@ -119,8 +119,8 @@ def get_parser(self, prog_name):
119119
def _get_compute_availability_zones(self, parsed_args):
120120
compute_client = self.app.client_manager.sdk_connection.compute
121121
try:
122-
data = compute_client.availability_zones(details=True)
123-
except nova_exceptions.Forbidden: # policy doesn't allow
122+
data = list(compute_client.availability_zones(details=True))
123+
except sdk_exceptions.ForbiddenException: # policy doesn't allow
124124
try:
125125
data = compute_client.availability_zones(details=False)
126126
except Exception:
@@ -135,7 +135,7 @@ def _get_volume_availability_zones(self, parsed_args):
135135
volume_client = self.app.client_manager.sdk_connection.volume
136136
data = []
137137
try:
138-
data = volume_client.availability_zones()
138+
data = list(volume_client.availability_zones())
139139
except Exception as e:
140140
LOG.debug('Volume availability zone exception: %s', e)
141141
if parsed_args.volume:

0 commit comments

Comments
 (0)