Browse Source

Merge "Pass existing DB obj to save DB requests" into stable/victoria

changes/43/787843/1
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
1d5ced1b39
2 changed files with 12 additions and 8 deletions
  1. +8
    -4
      neutron/db/db_base_plugin_v2.py
  2. +4
    -4
      neutron/plugins/ml2/plugin.py

+ 8
- 4
neutron/db/db_base_plugin_v2.py View File

@ -418,10 +418,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
@ -1459,11 +1461,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


+ 4
- 4
neutron/plugins/ml2/plugin.py View File

@ -1089,9 +1089,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)
@ -1651,7 +1650,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…
Cancel
Save