postgresql compatibility for get_l3_agent routines

This commit fixes a bug caused by the sqlalchemy group_by
statement in the get_l3_agent routines when using postgresql.
All select statements need to be replicated in the group_by statement.

Change-Id: Ib938be79408d78e0973fed10a68934397341c180
Closes-Bug: #1811873
This commit is contained in:
Andrew Karpow
2019-01-15 18:22:53 +01:00
parent a11087ec43
commit 23ca23cc79

View File

@@ -96,7 +96,7 @@ class Agent(base.NeutronDbObject):
rb_model.RouterL3AgentBinding.router_id
).label('count')).outerjoin(
rb_model.RouterL3AgentBinding).group_by(
agent_model.Agent.id,
agent_model.Agent,
rb_model.RouterL3AgentBinding
.l3_agent_id).order_by('count')
res = query.filter(agent_model.Agent.id.in_(agent_ids)).first()
@@ -110,7 +110,7 @@ class Agent(base.NeutronDbObject):
rb_model.RouterL3AgentBinding.router_id)
.label('count')).
outerjoin(rb_model.RouterL3AgentBinding).
group_by(agent_model.Agent.id).
group_by(agent_model.Agent).
filter(agent_model.Agent.id.in_(agent_ids)).
order_by('count'))
agents = [cls._load_object(context, record[0]) for record in query]