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:
parent
ce58a9a8fa
commit
0eb00662a6
@ -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,
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user