diff --git a/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py b/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py index 7d72248971..e0c2113d59 100644 --- a/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py +++ b/vmware_nsx/extensions/edge_service_gateway_bgp_peer.py @@ -65,6 +65,11 @@ class ExternalSubnetHasGW(nexception.InvalidInput): "BGP on the network.") +class EsgInternalIfaceDoesNotMatch(nexception.InvalidInput): + message = _("Given BGP peer IP address doesn't match " + "any interface on ESG '%(esg_id)s'") + + class Edge_service_gateway_bgp_peer(extensions.ExtensionDescriptor): """Extension class to allow identifying of-peer with specificN SXv edge service gateway. diff --git a/vmware_nsx/services/dynamic_routing/nsx_v/driver.py b/vmware_nsx/services/dynamic_routing/nsx_v/driver.py index f640e82b69..77e6ef706b 100644 --- a/vmware_nsx/services/dynamic_routing/nsx_v/driver.py +++ b/vmware_nsx/services/dynamic_routing/nsx_v/driver.py @@ -249,6 +249,15 @@ class NSXvBgpDriver(object): raise ext_esg_peer.EsgRemoteASDoNotMatch(remote_as=remote_as, esg_id=esg_id, esg_as=esg_as) + h, resp = self._nsxv.vcns.get_interfaces(esg_id) + for iface in resp['vnics']: + address_groups = iface['addressGroups']['addressGroups'] + matching_iface = [ag for ag in address_groups + if ag['primaryAddress'] == bgp_peer['peer_ip']] + if matching_iface: + break + else: + raise ext_esg_peer.EsgInternalIfaceDoesNotMatch(esg_id=esg_id) def create_bgp_peer(self, context, bgp_peer): bgp_peer = bgp_peer['bgp_peer']