Thanks Sean. I will check that.
Meanwhile I tried this and it is working
port1 = orm.aliased(models_v2.Port, name="port1")
port2 = orm.aliased(models_v2.Port, name="port2")
router_intf_qry =
context.session.query(RouterPort.router_id).join((port1,
port1.id==RouterPort.port_id), (port2,
port2.device_id==RouterPort.router_id)).filter(port1.network_id==int_net_id,
port2.network_id==ext_net_id).distinct()
for router in router_intf_qry:
router_id =router.router_id
Thanks
Anil Venkata
On 12/01/2015 06:35 PM, Sean M. Collins wrote:
> Consult the API:
>
> http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.join
>
> In fact, there is already one join happening a couple lines above your
> change:
>
> https://github.com/openstack/neutron/blob/stable/liberty/neutron/db/l3_db.py#L800
>
> Most likely, you will also need to use the aliased() function - since
> there are some examples that are similar to what you are trying to do -
> check out the "Joins to a Target with an ON Clause" section in the first
> link.
>
> http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.aliased
>