Pass existing DB obj to save DB requests
On port and network update ML2 plugin gets a db object and can pass it to db_base_plugin_v2 when doing super call. Change-Id: I1213f59fe643807f303e3ad7f24925fa333a5512
This commit is contained in:
parent
3d4a3b6db9
commit
02f4eca1ae
|
@ -419,10 +419,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||
return network
|
||||
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_network(self, context, id, network):
|
||||
def update_network(self, context, id, network, db_network=None):
|
||||
n = network['network']
|
||||
# we dont't use DB objects not belonging to the current active session
|
||||
db_network = db_network if context.session.is_active else None
|
||||
with db_api.CONTEXT_WRITER.using(context):
|
||||
network = self._get_network(context, id)
|
||||
network = db_network or self._get_network(context, id)
|
||||
# validate 'shared' parameter
|
||||
if 'shared' in n:
|
||||
entry = None
|
||||
|
@ -1458,11 +1460,13 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
|||
new_mac, current_owner)
|
||||
|
||||
@db_api.retry_if_session_inactive()
|
||||
def update_port(self, context, id, port):
|
||||
def update_port(self, context, id, port, db_port=None):
|
||||
# we dont't use DB objects not belonging to the current active session
|
||||
db_port = db_port if context.session.is_active else None
|
||||
new_port = port['port']
|
||||
|
||||
with db_api.CONTEXT_WRITER.using(context):
|
||||
db_port = self._get_port(context, id)
|
||||
db_port = db_port or self._get_port(context, id)
|
||||
new_mac = new_port.get('mac_address')
|
||||
self._validate_port_for_update(context, db_port, new_port, new_mac)
|
||||
# Note: _make_port_dict is called here to load extension data
|
||||
|
|
|
@ -1128,9 +1128,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
self._update_provider_network_attributes(
|
||||
context, original_network, net_data)
|
||||
|
||||
updated_network = super(Ml2Plugin, self).update_network(context,
|
||||
id,
|
||||
network)
|
||||
updated_network = super(Ml2Plugin, self).update_network(
|
||||
context, id, network, db_network=db_network)
|
||||
self.extension_manager.process_update_network(context, net_data,
|
||||
updated_network)
|
||||
self._process_l3_update(context, updated_network, net_data)
|
||||
|
@ -1689,7 +1688,8 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||
need_port_update_notify |= mac_address_updated
|
||||
original_port = self._make_port_dict(port_db)
|
||||
updated_port = super(Ml2Plugin, self).update_port(context, id,
|
||||
port)
|
||||
port,
|
||||
db_port=port_db)
|
||||
self.extension_manager.process_update_port(context, attrs,
|
||||
updated_port)
|
||||
self._portsec_ext_port_update_processing(updated_port, context,
|
||||
|
|
Loading…
Reference in New Issue