Refetch subnet/network from DB in ML2 update ops

This ensures that any extensions run in the ML2 extension framework
that bump the revision number of the subnet or network result in the
altered revision number being returned to the API caller and passed
into the ML2 mech drivers and callback handlers.

Closes-Bug: #1627628
Change-Id: Ieb37a3833ee52c671419c6dc981cf91c2366ae94
(cherry picked from commit cd7d63bde9)
This commit is contained in:
Kevin Benton 2016-09-24 23:07:45 -07:00 committed by Armando Migliaccio
parent 0408dc51ec
commit 20bb7be828
3 changed files with 11 additions and 11 deletions

View File

@ -792,9 +792,11 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
with context.session.begin(subtransactions=True):
subnet, changes = self.ipam.update_db_subnet(context, id, s,
db_pools)
# we expire here since ipam may have made changes to relationships
# that will be stale on any subsequent lookups while the subnet object
# is in the session otherwise.
context.session.expire(subnet)
result = self._make_subnet_dict(subnet, context=context)
# Keep up with fields that changed
result.update(changes)
if update_ports_needed:
# Find ports that have not yet been updated

View File

@ -811,7 +811,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
self.type_manager.extend_network_dict_provider(context,
updated_network)
updated_network[api.MTU] = self._get_network_mtu(updated_network)
updated_network = self.get_network(context, id)
# TODO(QoS): Move out to the extension framework somehow.
need_network_update_notify = (
@ -1033,6 +1033,7 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
context, id, subnet)
self.extension_manager.process_update_subnet(
context, subnet[attributes.SUBNET], updated_subnet)
updated_subnet = self.get_subnet(context, id)
network = self.get_network(context, updated_subnet['network_id'])
mech_context = driver_context.SubnetContext(
self, context, updated_subnet, network,

View File

@ -148,9 +148,7 @@ class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest):
@test.requires_ext(extension="dns-integration", service="network")
def test_update_dns_domain_bumps_revision(self):
net = self.create_network(dns_domain='example.test.')
self.client.update_network(net['id'], dns_domain='exa.test.')
# TODO(kevinbenton): use update result after bug/1627628 is fixed
updated = self.client.show_network(net['id'])
updated = self.client.update_network(net['id'], dns_domain='exa.test.')
self.assertGreater(updated['network']['revision_number'],
net['revision_number'])
port = self.create_port(net)
@ -198,13 +196,12 @@ class TestRevisions(base.BaseAdminNetworkTest, bsg.BaseSecGroupTest):
@test.requires_ext(extension="port-security", service="network")
def test_update_port_security_bumps_revisions(self):
net = self.create_network(port_security_enabled=False)
self.client.update_network(net['id'], port_security_enabled=True)
# TODO(kevinbenton): use update result after bug/1627628 is fixed
updated = self.client.show_network(net['id'])
updated = self.client.update_network(net['id'],
port_security_enabled=True)
self.assertGreater(updated['network']['revision_number'],
net['revision_number'])
self.client.update_network(net['id'], port_security_enabled=False)
updated2 = self.client.show_network(net['id'])
updated2 = self.client.update_network(net['id'],
port_security_enabled=False)
self.assertGreater(updated2['network']['revision_number'],
updated['network']['revision_number'])
port = self.create_port(net, port_security_enabled=False)