Include CellMapping in InstanceMapping object

Right now InstanceMapping exposes the cell_mappings.id db field which is
just an implementation detail of the db relationship and should not be
exposed in the object. It is also useless as a way to look up the actual
CellMapping through that object interface. And InstanceMapping is only
looked up in order to find a CellMapping.

So the CellMapping should be joined during the db query and loaded on
the InstanceMapping object by default.

Change-Id: Ia8691b76bba310327bfe0995964525409794d1af
This commit is contained in:
Andrew Laski 2016-02-29 14:39:20 -05:00 committed by Dan Smith
parent 208fd5560f
commit 62c94408af

View File

@ -68,6 +68,10 @@ class InstanceMapping(API_BASE):
cell_id = Column(Integer, ForeignKey('cell_mappings.id'),
nullable=True)
project_id = Column(String(255), nullable=False)
cell_mapping = orm.relationship('CellMapping',
backref=backref('instance_mapping', uselist=False),
foreign_keys=cell_id,
primaryjoin=('InstanceMapping.cell_id == CellMapping.id'))
class HostMapping(API_BASE):