Merge "Fix session handling" into stable/queens
This commit is contained in:
@@ -165,15 +165,18 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
def _ml2_md_extend_network_dict(result, netdb):
|
def _ml2_md_extend_network_dict(result, netdb):
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(netdb)
|
session = db_api.get_session_from_obj(netdb)
|
||||||
if not session:
|
if session and session.is_active:
|
||||||
|
# REVISIT: Check if transaction begin is still
|
||||||
|
# required here, and if so, if reader pattern
|
||||||
|
# can be used instead (will require getting the
|
||||||
|
# current context, which should be available in
|
||||||
|
# the session.info's dictionary, with a key of
|
||||||
|
# 'using_context').
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_network_dict(
|
||||||
|
session, netdb, result)
|
||||||
|
else:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
# REVISIT: Check if transaction begin is still
|
|
||||||
# required here, and if so, if reader pattern
|
|
||||||
# can be used instead (will require getting the
|
|
||||||
# current context, which should be available in
|
|
||||||
# the session.info's dictionary, with a key of
|
|
||||||
# 'using_context').
|
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
plugin.extension_manager.extend_network_dict(
|
plugin.extension_manager.extend_network_dict(
|
||||||
session, netdb, result)
|
session, netdb, result)
|
||||||
|
|
||||||
@@ -183,9 +186,12 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
netdb = results[0][1] if results else None
|
netdb = results[0][1] if results else None
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(netdb)
|
session = db_api.get_session_from_obj(netdb)
|
||||||
if not session:
|
if session and session.is_active:
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_network_dict_bulk(session,
|
||||||
|
results)
|
||||||
|
else:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
plugin.extension_manager.extend_network_dict_bulk(session, results)
|
plugin.extension_manager.extend_network_dict_bulk(session, results)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -193,15 +199,18 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
def _ml2_md_extend_port_dict(result, portdb):
|
def _ml2_md_extend_port_dict(result, portdb):
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(portdb)
|
session = db_api.get_session_from_obj(portdb)
|
||||||
if not session:
|
if session and session.is_active:
|
||||||
|
# REVISIT: Check if transaction begin is still
|
||||||
|
# required here, and if so, if reader pattern
|
||||||
|
# can be used instead (will require getting the
|
||||||
|
# current context, which should be available in
|
||||||
|
# the session.info's dictionary, with a key of
|
||||||
|
# 'using_context').
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_port_dict(
|
||||||
|
session, portdb, result)
|
||||||
|
else:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
# REVISIT: Check if transaction begin is still
|
|
||||||
# required here, and if so, if reader pattern
|
|
||||||
# can be used instead (will require getting the
|
|
||||||
# current context, which should be available in
|
|
||||||
# the session.info's dictionary, with a key of
|
|
||||||
# 'using_context').
|
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
plugin.extension_manager.extend_port_dict(
|
plugin.extension_manager.extend_port_dict(
|
||||||
session, portdb, result)
|
session, portdb, result)
|
||||||
|
|
||||||
@@ -211,9 +220,12 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
portdb = results[0][1] if results else None
|
portdb = results[0][1] if results else None
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(portdb)
|
session = db_api.get_session_from_obj(portdb)
|
||||||
if not session:
|
if session and session.is_active:
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_port_dict_bulk(session,
|
||||||
|
results)
|
||||||
|
else:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
plugin.extension_manager.extend_port_dict_bulk(session, results)
|
plugin.extension_manager.extend_port_dict_bulk(session, results)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -228,13 +240,18 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
# be okay for other resources, as well
|
# be okay for other resources, as well
|
||||||
# as post-queens.
|
# as post-queens.
|
||||||
session = patch_neutron.get_current_session()
|
session = patch_neutron.get_current_session()
|
||||||
# REVISIT: Check if transaction begin is still
|
if session and session.is_active:
|
||||||
# required here, and if so, if reader pattern
|
# REVISIT: Check if transaction begin is still
|
||||||
# can be used instead (will require getting the
|
# required here, and if so, if reader pattern
|
||||||
# current context, which should be available in
|
# can be used instead (will require getting the
|
||||||
# the session.info's dictionary, with a key of
|
# current context, which should be available in
|
||||||
# 'using_context').
|
# the session.info's dictionary, with a key of
|
||||||
with session.begin(subtransactions=True):
|
# 'using_context').
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_subnet_dict(
|
||||||
|
session, subnetdb, result)
|
||||||
|
else:
|
||||||
|
session = db_api.get_writer_session()
|
||||||
plugin.extension_manager.extend_subnet_dict(
|
plugin.extension_manager.extend_subnet_dict(
|
||||||
session, subnetdb, result)
|
session, subnetdb, result)
|
||||||
|
|
||||||
@@ -251,7 +268,12 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
# be okay for other resources, as well
|
# be okay for other resources, as well
|
||||||
# as post-queens.
|
# as post-queens.
|
||||||
session = patch_neutron.get_current_session()
|
session = patch_neutron.get_current_session()
|
||||||
with session.begin(subtransactions=True):
|
if session and session.is_active:
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_subnet_dict_bulk(session,
|
||||||
|
results)
|
||||||
|
else:
|
||||||
|
session = db_api.get_writer_session()
|
||||||
plugin.extension_manager.extend_subnet_dict_bulk(session, results)
|
plugin.extension_manager.extend_subnet_dict_bulk(session, results)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -259,6 +281,8 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
def _ml2_md_extend_subnetpool_dict(result, subnetpooldb):
|
def _ml2_md_extend_subnetpool_dict(result, subnetpooldb):
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(subnetpooldb)
|
session = db_api.get_session_from_obj(subnetpooldb)
|
||||||
|
# REVISIT: This is not consistent with other dict
|
||||||
|
# extend calls, and should be fixed.
|
||||||
if not session:
|
if not session:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
# REVISIT: Check if transaction begin is still
|
# REVISIT: Check if transaction begin is still
|
||||||
@@ -277,9 +301,12 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
subnetpooldb = results[0][1] if results else None
|
subnetpooldb = results[0][1] if results else None
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(subnetpooldb)
|
session = db_api.get_session_from_obj(subnetpooldb)
|
||||||
if not session:
|
if session and session.is_active:
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_subnetpool_dict_bulk(session,
|
||||||
|
results)
|
||||||
|
else:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
plugin.extension_manager.extend_subnetpool_dict_bulk(session,
|
plugin.extension_manager.extend_subnetpool_dict_bulk(session,
|
||||||
results)
|
results)
|
||||||
|
|
||||||
@@ -288,15 +315,18 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
def _ml2_md_extend_address_scope_dict(result, address_scope):
|
def _ml2_md_extend_address_scope_dict(result, address_scope):
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(address_scope)
|
session = db_api.get_session_from_obj(address_scope)
|
||||||
if not session:
|
if session and session.is_active:
|
||||||
|
# REVISIT: Check if transaction begin is still
|
||||||
|
# required here, and if so, if reader pattern
|
||||||
|
# can be used instead (will require getting the
|
||||||
|
# current context, which should be available in
|
||||||
|
# the session.info's dictionary, with a key of
|
||||||
|
# 'using_context').
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_address_scope_dict(
|
||||||
|
session, address_scope, result)
|
||||||
|
else:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
# REVISIT: Check if transaction begin is still
|
|
||||||
# required here, and if so, if reader pattern
|
|
||||||
# can be used instead (will require getting the
|
|
||||||
# current context, which should be available in
|
|
||||||
# the session.info's dictionary, with a key of
|
|
||||||
# 'using_context').
|
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
plugin.extension_manager.extend_address_scope_dict(
|
plugin.extension_manager.extend_address_scope_dict(
|
||||||
session, address_scope, result)
|
session, address_scope, result)
|
||||||
|
|
||||||
@@ -306,9 +336,12 @@ class Ml2PlusPlugin(ml2_plugin.Ml2Plugin,
|
|||||||
address_scope = results[0][1] if results else None
|
address_scope = results[0][1] if results else None
|
||||||
plugin = directory.get_plugin()
|
plugin = directory.get_plugin()
|
||||||
session = db_api.get_session_from_obj(address_scope)
|
session = db_api.get_session_from_obj(address_scope)
|
||||||
if not session:
|
if session and session.is_active:
|
||||||
|
with session.begin(subtransactions=True):
|
||||||
|
plugin.extension_manager.extend_address_scope_dict_bulk(
|
||||||
|
session, results)
|
||||||
|
else:
|
||||||
session = db_api.get_writer_session()
|
session = db_api.get_writer_session()
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
plugin.extension_manager.extend_address_scope_dict_bulk(session,
|
plugin.extension_manager.extend_address_scope_dict_bulk(session,
|
||||||
results)
|
results)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user