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
This commit is contained in:
parent
2642b070db
commit
f3207bdf3f
@ -16,7 +16,7 @@
|
||||
import copy
|
||||
import logging
|
||||
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from openstack import exceptions as sdk_exceptions
|
||||
from osc_lib.command import command
|
||||
from osc_lib import utils
|
||||
|
||||
@ -119,8 +119,8 @@ class ListAvailabilityZone(command.Lister):
|
||||
def _get_compute_availability_zones(self, parsed_args):
|
||||
compute_client = self.app.client_manager.sdk_connection.compute
|
||||
try:
|
||||
data = compute_client.availability_zones(details=True)
|
||||
except nova_exceptions.Forbidden: # policy doesn't allow
|
||||
data = list(compute_client.availability_zones(details=True))
|
||||
except sdk_exceptions.ForbiddenException: # policy doesn't allow
|
||||
try:
|
||||
data = compute_client.availability_zones(details=False)
|
||||
except Exception:
|
||||
@ -135,7 +135,7 @@ class ListAvailabilityZone(command.Lister):
|
||||
volume_client = self.app.client_manager.sdk_connection.volume
|
||||
data = []
|
||||
try:
|
||||
data = volume_client.availability_zones()
|
||||
data = list(volume_client.availability_zones())
|
||||
except Exception as e:
|
||||
LOG.debug('Volume availability zone exception: %s', e)
|
||||
if parsed_args.volume:
|
||||
|
Loading…
Reference in New Issue
Block a user