From a98fe51b83440693f8acf17b157c38a944ef65ef Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Thu, 27 May 2021 10:28:13 +0000 Subject: [PATCH] Set "floatingip.fixed_port" as viewonly Set "floatingip.fixed_port" attribute as viewonly. According to [1], "the originating relationship for a particular state change will not produce state changes within the viewonly relationship". That means any change on any of those ports won't change the backref and won't affect "floatingip" object. Closes-Bug: #1930294 [1]https://docs.sqlalchemy.org/en/14/orm/relationship_api.html Change-Id: I202a12f82f70b1094cdb986ba404f396d5e0e427 --- neutron/db/models/l3.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neutron/db/models/l3.py b/neutron/db/models/l3.py index 93180e47b51..55be2af0665 100644 --- a/neutron/db/models/l3.py +++ b/neutron/db/models/l3.py @@ -88,11 +88,11 @@ class FloatingIP(standard_attr.HasStandardAttributes, model_base.BASEV2, port = orm.relationship(models_v2.Port, backref=orm.backref('floating_ips', cascade='all,delete-orphan'), - foreign_keys='FloatingIP.floating_port_id') + foreign_keys=floating_port_id) fixed_port_id = sa.Column(sa.String(36), sa.ForeignKey('ports.id')) fixed_port = orm.relationship(models_v2.Port, - foreign_keys='FloatingIP.fixed_port_id', - lazy='joined') + foreign_keys=fixed_port_id, + lazy='joined', viewonly=True) fixed_ip_address = sa.Column(sa.String(64)) router_id = sa.Column(sa.String(36), sa.ForeignKey('routers.id')) # Additional attribute for keeping track of the router where the floating