Add FixedIP.floating_ips dynamic property
This adds a lazy-loading FixedIP.floating_ips property which mimics the use of the backref between the two objects in the SQLAlchemy model. This doesn't introduce a new database query because it was being used as a lazy-load in network manager already. Related to blueprint nova-network-objects Change-Id: I2f13f7a0463486e51c2317e02c2e7b378ac9e55d
This commit is contained in:
@@ -42,6 +42,13 @@ class FixedIP(obj_base.NovaPersistentObject, obj_base.NovaObject):
|
||||
'network': fields.ObjectField('Network', nullable=True),
|
||||
}
|
||||
|
||||
@property
|
||||
def floating_ips(self):
|
||||
# NOTE(danms): avoid circular import
|
||||
from nova.objects import floating_ip
|
||||
return floating_ip.FloatingIPList.get_by_fixed_ip_id(self._context,
|
||||
self.id)
|
||||
|
||||
@staticmethod
|
||||
def _from_db_object(context, fixedip, db_fixedip, expected_attrs=None):
|
||||
if expected_attrs is None:
|
||||
|
||||
Reference in New Issue
Block a user