summaryrefslogtreecommitdiff
path: root/neutron/db
diff options
context:
space:
mode:
authorvikram.choudhary <vikram.choudhary@huawei.com>2016-02-14 16:51:00 +0530
committerRyan Tidwell <ryan.tidwell@hpe.com>2016-03-08 14:06:39 -0800
commit8bf46be67cc543cc3938122708a67271ce2eb7aa (patch)
tree54d78482ae96b890c86205b1a4444b016fb7baae /neutron/db
parent1c9e439e7a1bda5b665997816891111e679faf67 (diff)
downloadneutron-8bf46be67cc543cc3938122708a67271ce2eb7aa.tar.gz
Add BGP Callback and agent RPC notifcation implementations
This patch adds RPC calls to the BGP speaker service plugin. This enables the service plugin to notify the appropriate BGP dynamic routing agents (bgp_dragent) when tenants add router gateway ports, router interfaces, associate/disassociate floating IP's, and when and admin binds/unbinds a gateway network to a BGP speaker. Compatible with centralized routers, distributed routers not supported. Partially-Implements: blueprint bgp-dynamic-routing Co-Authored-By: vikram.choudhary <vikram.choudhary@huawei.com> Change-Id: Ide76f9fdfba228000ddfa41a1168e77d21e92d9f
Diffstat (limited to 'neutron/db')
-rw-r--r--neutron/db/bgp_db.py16
-rw-r--r--neutron/db/l3_db.py9
-rw-r--r--neutron/db/l3_dvr_db.py12
3 files changed, 23 insertions, 14 deletions
diff --git a/neutron/db/bgp_db.py b/neutron/db/bgp_db.py
index a60a97f053..94c26f9406 100644
--- a/neutron/db/bgp_db.py
+++ b/neutron/db/bgp_db.py
@@ -876,13 +876,10 @@ class BgpDbMixin(common_db.CommonDbMixin):
query = query.filter(
BgpSpeakerNetworkBinding.network_id == network_id,
BgpSpeakerNetworkBinding.bgp_speaker_id == BgpSpeaker.id)
- try:
- return query.all()
- except sa_exc.NoResultFound:
- raise bgp_ext.NetworkNotBound(network_id=network_id)
+ return query.all()
- def _bgp_speaker_for_gateway_network(self, context,
- network_id, ip_version):
+ def _bgp_speakers_for_gw_network_by_family(self, context,
+ network_id, ip_version):
"""Return the BgpSpeaker by given gateway network and ip_version"""
with context.session.begin(subtransactions=True):
query = context.session.query(BgpSpeaker)
@@ -890,12 +887,7 @@ class BgpDbMixin(common_db.CommonDbMixin):
BgpSpeakerNetworkBinding.network_id == network_id,
BgpSpeakerNetworkBinding.bgp_speaker_id == BgpSpeaker.id,
BgpSpeakerNetworkBinding.ip_version == ip_version)
- try:
- return query.one()
- except sa_exc.NoResultFound:
- raise bgp_ext.NetworkNotBoundForIpVersion(
- network_id=network_id,
- ip_version=ip_version)
+ return query.all()
def _make_advertised_routes_list(self, routes):
route_list = ({'destination': x,
diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py
index 9d4e465db2..3113d53d22 100644
--- a/neutron/db/l3_db.py
+++ b/neutron/db/l3_db.py
@@ -358,6 +358,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
admin_ctx, {'router_id': [router_id]}):
raise l3.RouterExternalGatewayInUseByFloatingIp(
router_id=router_id, net_id=router.gw_port['network_id'])
+ gw_ips = [x['ip_address'] for x in router.gw_port.fixed_ips]
with context.session.begin(subtransactions=True):
gw_port = router.gw_port
router.gw_port = None
@@ -369,7 +370,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
registry.notify(resources.ROUTER_GATEWAY,
events.AFTER_DELETE, self,
router_id=router_id,
- network_id=old_network_id)
+ network_id=old_network_id,
+ gateway_ips=gw_ips)
def _check_router_gw_port_in_use(self, context, router_id):
try:
@@ -819,15 +821,18 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
context, router_id, subnet_id, device_owner)
gw_network_id = None
+ gw_ips = []
router = self._get_router(context, router_id)
if router.gw_port:
gw_network_id = router.gw_port.network_id
+ gw_ips = [x['ip_address'] for x in router.gw_port.fixed_ips]
registry.notify(resources.ROUTER_INTERFACE,
events.AFTER_DELETE,
self,
cidrs=[x['cidr'] for x in subnets],
- network_id=gw_network_id)
+ network_id=gw_network_id,
+ gateway_ips=gw_ips)
return self._make_router_interface_info(router_id, port['tenant_id'],
port['id'], port['network_id'],
subnets[0]['id'],
diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py
index f4a62c073c..2df7df3768 100644
--- a/neutron/db/l3_dvr_db.py
+++ b/neutron/db/l3_dvr_db.py
@@ -302,6 +302,18 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
subnet['id'], [subnet['id']])
self.notify_router_interface_action(
context, router_interface_info, 'add')
+ if router.gw_port:
+ gw_network_id = router.gw_port.network_id
+ gw_ips = [x['ip_address'] for x in router.gw_port.fixed_ips]
+ registry.notify(resources.ROUTER_INTERFACE,
+ events.AFTER_CREATE,
+ self,
+ network_id=gw_network_id,
+ gateway_ips=gw_ips,
+ cidrs=[x['cidr'] for x in subnets],
+ port_id=port['id'],
+ router_id=router_id,
+ interface_info=interface_info)
return router_interface_info
def _port_has_ipv6_address(self, port, csnat_port_check=True):