move make_port_dict back out of txn

Change I50be115ea69f805b48b02aebe4259ec2c839830e moved the
dict construction inside of the transaction to deal with the
expired fixed_ips relationship. However, this no longer matches
the pattern we have everywhere else of waiting until after commit
to build the response so this patch moves it back out and loads
the fixed_ips relationships after altering them so they can be
referenced outside of the new engine facade transactions.

Partially-Implements blueprint: enginefacade-switch
Change-Id: I9149d8ab3bf977f0247e542e0c47731d900dd119
This commit is contained in:
Kevin Benton 2017-04-15 17:43:13 -07:00
parent 8756cb7d99
commit 43e069fd06
3 changed files with 3 additions and 1 deletions

View File

@ -1293,7 +1293,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
# conflict, bubble up a retry instead that should bring things
# back to sanity.
raise os_db_exc.RetryRequest(e)
return self._make_port_dict(db_port)
return self._make_port_dict(db_port)
@db_api.retry_if_session_inactive()
def delete_port(self, context, id):

View File

@ -784,4 +784,5 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon):
context.session.expire(old_port_db, ['fixed_ips'])
ips = self.allocate_ips_for_port_and_store(
context, {'port': port_copy}, port_copy['id'])
getattr(old_port_db, 'fixed_ips') # refresh relationship before return
return self.Changes(add=ips, original=[], remove=[])

View File

@ -344,6 +344,7 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
ip['subnet_id'], db_port.id)
self._update_db_port(context, db_port, new_port, network_id,
new_mac)
getattr(db_port, 'fixed_ips') # refresh relationship before return
except Exception:
with excutils.save_and_reraise_exception():
if 'fixed_ips' in new_port: