Refactor network AZ exception handling

Exceptions that occur while getting network availability zones
should not be masked as if the extension does not exist.

Change-Id: I07213ec6c4d83e97261b58bf8d42417c1cdfae6a
Related-Bug: #1534202
This commit is contained in:
Richard Theis 2016-02-10 13:37:42 -06:00
parent 624c39ab1b
commit b3a4b8852a
1 changed files with 2 additions and 3 deletions

View File

@ -146,21 +146,20 @@ class ListAvailabilityZone(command.Lister):
def _get_network_availability_zones(self, parsed_args):
network_client = self.app.client_manager.network
data = []
try:
# Verify that the extension exists.
network_client.find_extension('Availability Zone',
ignore_missing=False)
data = network_client.availability_zones()
except Exception as e:
self.log.debug('Network availability zone exception: ' + str(e))
if parsed_args.network:
message = "Availability zones list not supported by " \
"Network API"
self.log.warning(message)
return []
result = []
for zone in data:
for zone in network_client.availability_zones():
result += _xform_network_availability_zone(zone)
return result