Revert "Update network revision only when it needs"
Closes-Bug: #1787028 This reverts commit e9a7ed8c63ec5bb0fdca3406c8b21071729dd09d. Change-Id: If52eb8f7c6a801f22a67d2a5786f16ddaa7c5f0f
This commit is contained in:
parent
e9a7ed8c63
commit
c8b04827a9
neutron
db
services/revisions
tests/unit/services/revisions
@ -56,12 +56,7 @@ class IPAllocation(model_base.BASEV2):
|
||||
network_id = sa.Column(sa.String(36), sa.ForeignKey("networks.id",
|
||||
ondelete="CASCADE"),
|
||||
nullable=False, primary_key=True)
|
||||
network_standard_attr = orm.relationship(
|
||||
'StandardAttribute', lazy='subquery', viewonly=True,
|
||||
secondary='networks', uselist=False,
|
||||
load_on_pending=True)
|
||||
|
||||
revises_on_change = ('port', 'network_standard_attr',)
|
||||
revises_on_change = ('port', )
|
||||
|
||||
|
||||
class Route(object):
|
||||
|
@ -47,8 +47,7 @@ class RevisionPlugin(service_base.ServicePluginBase):
|
||||
self._enforce_if_match_constraints(session)
|
||||
# bump revision number for any updated objects in the session
|
||||
for obj in session.dirty:
|
||||
if (session.is_modified(obj) and
|
||||
isinstance(obj, standard_attr.HasStandardAttributes)):
|
||||
if isinstance(obj, standard_attr.HasStandardAttributes):
|
||||
self._bump_obj_revision(session, obj)
|
||||
|
||||
# see if any created/updated/deleted objects bump the revision
|
||||
|
@ -86,17 +86,10 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase):
|
||||
def test_port_name_update_revises(self):
|
||||
with self.port() as port:
|
||||
rev = port['port']['revision_number']
|
||||
network = directory.get_plugin().get_network(
|
||||
self.ctx, port['port']['network_id'])
|
||||
net_rev = network['revision_number']
|
||||
new = {'port': {'name': 'seaweed'}}
|
||||
response = self._update('ports', port['port']['id'], new)
|
||||
new_rev = response['port']['revision_number']
|
||||
self.assertGreater(new_rev, rev)
|
||||
network = directory.get_plugin().get_network(
|
||||
self.ctx, port['port']['network_id'])
|
||||
net_ew_rev = network['revision_number']
|
||||
self.assertEqual(net_ew_rev, net_rev)
|
||||
|
||||
def test_constrained_port_update(self):
|
||||
with self.port() as port:
|
||||
@ -152,9 +145,6 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase):
|
||||
def test_port_ip_update_revises(self):
|
||||
with self.port() as port:
|
||||
rev = port['port']['revision_number']
|
||||
network = directory.get_plugin().get_network(
|
||||
self.ctx, port['port']['network_id'])
|
||||
net_rev = network['revision_number']
|
||||
new = {'port': {'fixed_ips': port['port']['fixed_ips']}}
|
||||
# ensure adding an IP allocation updates the port
|
||||
next_ip = str(netaddr.IPAddress(
|
||||
@ -164,23 +154,13 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase):
|
||||
self.assertEqual(2, len(response['port']['fixed_ips']))
|
||||
new_rev = response['port']['revision_number']
|
||||
self.assertGreater(new_rev, rev)
|
||||
network = directory.get_plugin().get_network(
|
||||
self.ctx, port['port']['network_id'])
|
||||
new_net_rev = network['revision_number']
|
||||
self.assertGreater(new_net_rev, net_rev)
|
||||
|
||||
# ensure deleting an IP allocation updates the port
|
||||
rev = new_rev
|
||||
net_rev = new_net_rev
|
||||
new['port']['fixed_ips'].pop()
|
||||
response = self._update('ports', port['port']['id'], new)
|
||||
self.assertEqual(1, len(response['port']['fixed_ips']))
|
||||
new_rev = response['port']['revision_number']
|
||||
self.assertGreater(new_rev, rev)
|
||||
network = directory.get_plugin().get_network(
|
||||
self.ctx, port['port']['network_id'])
|
||||
new_net_rev = network['revision_number']
|
||||
self.assertGreater(new_net_rev, net_rev)
|
||||
|
||||
def test_security_group_rule_ops_bump_security_group(self):
|
||||
s = {'security_group': {'tenant_id': 'some_tenant', 'name': '',
|
||||
|
Loading…
x
Reference in New Issue
Block a user