Provide "atomic" database access for networks

Fixes bug 1093637

In the OVS and LB plugins there are cases when accessing the network
has an additional database query. The patch enables this to occur
without accessing an invalid database entry.

Change-Id: I7d4944cf3240819f23dd7b4993d6ae3cefab9dc2
This commit is contained in:
Gary Kotton 2012-12-25 15:11:35 +00:00
parent fa20b0587e
commit f513b6326f
2 changed files with 32 additions and 20 deletions

View File

@ -383,13 +383,19 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2,
self.notifier.network_delete(context, id)
def get_network(self, context, id, fields=None):
net = super(LinuxBridgePluginV2, self).get_network(context, id, None)
session = context.session
with session.begin(subtransactions=True):
net = super(LinuxBridgePluginV2, self).get_network(context,
id, None)
self._extend_network_dict_provider(context, net)
self._extend_network_dict_l3(context, net)
return self._fields(net, fields)
def get_networks(self, context, filters=None, fields=None):
nets = super(LinuxBridgePluginV2, self).get_networks(context, filters,
session = context.session
with session.begin(subtransactions=True):
nets = super(LinuxBridgePluginV2, self).get_networks(context,
filters,
None)
for net in nets:
self._extend_network_dict_provider(context, net)

View File

@ -468,13 +468,19 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
self.notifier.network_delete(context, id)
def get_network(self, context, id, fields=None):
net = super(OVSQuantumPluginV2, self).get_network(context, id, None)
session = context.session
with session.begin(subtransactions=True):
net = super(OVSQuantumPluginV2, self).get_network(context,
id, None)
self._extend_network_dict_provider(context, net)
self._extend_network_dict_l3(context, net)
return self._fields(net, fields)
def get_networks(self, context, filters=None, fields=None):
nets = super(OVSQuantumPluginV2, self).get_networks(context, filters,
session = context.session
with session.begin(subtransactions=True):
nets = super(OVSQuantumPluginV2, self).get_networks(context,
filters,
None)
for net in nets:
self._extend_network_dict_provider(context, net)