From c8f1f3859c4f1f3cc4f5b403d3314034516306b1 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Thu, 21 Dec 2017 14:50:24 +0200 Subject: [PATCH] NSX-V3 Fix router availability zones Before getting the router availability zones in get/list actions, we need to get the availability zone hints. The get_router method of the plugin is no longer needed becasue it was originally created only to avoid thios prroblem. In addition, the availability zones list should also return the router zones. Change-Id: Ief40b36955bae771fb1efd72d49be0e5a0d55cc6 --- vmware_nsx/plugins/nsx_v3/plugin.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index 0cac68415c..9e094f1278 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -3381,18 +3381,12 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, return ret_val - def get_router(self, context, id, fields=None): - with db_api.context_manager.reader.using(context): - # Get router from Neutron database - router = self._get_router(context, id) - # Don't do field selection here otherwise we won't be able to add - # provider networks fields - rtr = self._make_router_dict(router) - rtr['availability_zones'] = self.get_router_availability_zones(rtr) - return db_utils.resource_fields(rtr, fields) - def get_router_availability_zones(self, router): """Return availability zones which a router belongs to.""" + # add the hints to the structure first + l3_attrs_db.ExtraAttributesMixin._extend_extra_router_dict( + router, router) + # get the availability zones from the hints return [self.get_router_az(router).name] def _validate_ext_routes(self, context, router_id, gw_info, new_routes): @@ -4368,6 +4362,7 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, 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 return result def _validate_availability_zones_forced(self, context, resource_type,