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
This commit is contained in:
Rodolfo Alonso Hernandez 2021-05-27 10:28:13 +00:00 committed by Rodolfo Alonso
parent 7e98d18927
commit a98fe51b83

View File

@ -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