From b98bffcc076d0fd971a4cf9b8e39b4e0b0fb97f7 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Thu, 18 Aug 2016 10:14:59 +0300 Subject: [PATCH] NSX|v Fix router type update to not update all the attributes When changing the router type from shared to exclusive, we accidentally updated other attributes too, causing backend edge rename to be called and to fail Change-Id: Idf593df7591e639824efbdb46b391e74664db709 --- .../nsx_v/drivers/exclusive_router_driver.py | 22 +++++++++---------- vmware_nsx/plugins/nsx_v/plugin.py | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v/drivers/exclusive_router_driver.py b/vmware_nsx/plugins/nsx_v/drivers/exclusive_router_driver.py index c35c6d7036..bd0884ef37 100644 --- a/vmware_nsx/plugins/nsx_v/drivers/exclusive_router_driver.py +++ b/vmware_nsx/plugins/nsx_v/drivers/exclusive_router_driver.py @@ -87,26 +87,24 @@ class RouterExclusiveDriver(router_driver.RouterBaseDriver): metadata_proxy_handler.cleanup_router_edge(router_id) def _build_router_data_from_db(self, router_db, router): - if 'status' not in router['router']: - router['router']['status'] = router_db.status - if 'name' not in router['router']: - router['router']['name'] = router_db.name - if 'admin_state_up' not in router['router']: - router['router']['admin_state_up'] = router_db.admin_state_up - if 'tenant_id' not in router['router']: - router['router']['tenant_id'] = router_db.tenant_id - if 'id' not in router['router']: - router['router']['id'] = router_db.id + """Return a new dictionary with all DB & requested router attributes + """ + router_attr = router['router'].copy() + fields = ['status', 'name', 'admin_state_up', 'tenant_id', 'id'] + for field in fields: + if field not in router['router']: + router_attr[field] = getattr(router_db, field) + return router_attr def attach_router(self, context, router_id, router, appliance_size=None): router_db = self.plugin._get_router(context, router_id) # Add DB attributes to the router data structure # before creating it as an exclusive router - self._build_router_data_from_db(router_db, router) + router_attr = self._build_router_data_from_db(router_db, router) self.create_router(context, - router['router'], + router_attr, allow_metadata=False, appliance_size=appliance_size) diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index 66332f450b..e3330c3e7a 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -2280,6 +2280,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, router, appliance_size=appliance_size) # continue to update the router with the new driver + # but remove the router-size that was already updated + router['router'].pop(ROUTER_SIZE, None) router_driver = self._find_router_driver(context, router_id) return router_driver.update_router(context, router_id, router)