NSX-V&V3: support filters for list availability zones action

Filtering the AZ list by resource & name will now be supported.

Change-Id: I02f44e78142b40f23022b7ea70442cd2d877f06c
This commit is contained in:
Adit Sarfaty 2018-05-09 08:03:49 +03:00
parent ce58a9a8fa
commit 0eb00662a6
2 changed files with 13 additions and 9 deletions

View File

@ -1053,13 +1053,15 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
use_tvd_config=self._is_sub_plugin)
def _list_availability_zones(self, context, filters=None):
#TODO(asarfaty): We may need to use the filters arg, but now it
# is here only for overriding the original api
result = {}
for az in self.get_azs_names():
# Add this availability zone as a router & network resource
for resource in ('router', 'network'):
result[(az, resource)] = True
if filters:
if 'name' in filters and az not in filters['name']:
continue
for res in ['network', 'router']:
if 'resource' not in filters or res in filters['resource']:
result[(az, res)] = True
return result
def _validate_availability_zones_in_obj(self, context, resource_type,

View File

@ -4863,13 +4863,15 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
return super(NsxV3Plugin, self)._list_availability_zones(
context, filters=filters)
#TODO(asarfaty): We may need to use the filters arg, but now it
# is here only for overriding the original api
result = {}
for az in self._availability_zones_data.list_availability_zones():
# Add this availability zone as a network resource
result[(az, 'network')] = True
result[(az, 'router')] = True
# Add this availability zone as a network & router resource
if filters:
if 'name' in filters and az not in filters['name']:
continue
for res in ['network', 'router']:
if 'resource' not in filters or res in filters['resource']:
result[(az, res)] = True
return result
def _validate_availability_zones_forced(self, context, resource_type,