Merge "Implement "IPAllocation" router ports allocated retrieval" into stable/train
This commit is contained in:
commit
fff2d07fe6
|
@ -622,15 +622,12 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
|
||||||
# a subnet-update and a router-interface-add operation are
|
# a subnet-update and a router-interface-add operation are
|
||||||
# executed concurrently
|
# executed concurrently
|
||||||
if cur_subnet and not ipv6_utils.is_ipv6_pd_enabled(s):
|
if cur_subnet and not ipv6_utils.is_ipv6_pd_enabled(s):
|
||||||
|
gateway_ip = str(cur_subnet['gateway_ip'])
|
||||||
with db_api.CONTEXT_READER.using(context):
|
with db_api.CONTEXT_READER.using(context):
|
||||||
# TODO(electrocucaracha): Look a solution for Join in OVO
|
allocated = port_obj.IPAllocation.get_alloc_routerports(
|
||||||
ipal = models_v2.IPAllocation
|
context, cur_subnet['id'], gateway_ip=gateway_ip,
|
||||||
alloc_qry = context.session.query(ipal.port_id)
|
first=True)
|
||||||
alloc_qry = alloc_qry.join("port", "routerport")
|
|
||||||
gateway_ip = str(cur_subnet['gateway_ip'])
|
|
||||||
allocated = alloc_qry.filter(
|
|
||||||
ipal.ip_address == gateway_ip,
|
|
||||||
ipal.subnet_id == cur_subnet['id']).first()
|
|
||||||
if allocated and allocated.port_id:
|
if allocated and allocated.port_id:
|
||||||
raise exc.GatewayIpInUse(
|
raise exc.GatewayIpInUse(
|
||||||
ip_address=gateway_ip,
|
ip_address=gateway_ip,
|
||||||
|
|
|
@ -215,6 +215,21 @@ class IPAllocation(base.NeutronDbObject):
|
||||||
if alloc_db:
|
if alloc_db:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_alloc_routerports(cls, context, subnet_id, gateway_ip=None,
|
||||||
|
first=False):
|
||||||
|
alloc_qry = context.session.query(cls.db_model.port_id)
|
||||||
|
alloc_qry = alloc_qry.join(
|
||||||
|
l3.RouterPort, l3.RouterPort.port_id == cls.db_model.port_id)
|
||||||
|
alloc_qry = alloc_qry.filter(cls.db_model.subnet_id == subnet_id)
|
||||||
|
if gateway_ip:
|
||||||
|
alloc_qry = alloc_qry.filter(cls.db_model.ip_address == gateway_ip)
|
||||||
|
|
||||||
|
if first:
|
||||||
|
return alloc_qry.first()
|
||||||
|
else:
|
||||||
|
return alloc_qry.all()
|
||||||
|
|
||||||
|
|
||||||
@base.NeutronObjectRegistry.register
|
@base.NeutronObjectRegistry.register
|
||||||
class PortDNS(base.NeutronDbObject):
|
class PortDNS(base.NeutronDbObject):
|
||||||
|
|
Loading…
Reference in New Issue