Merge "NSXv BGP: Adding IP address check for ESG BGP peer"

This commit is contained in:
Jenkins 2017-05-26 18:27:48 +00:00 committed by Gerrit Code Review
commit 740a2ec3f5
2 changed files with 14 additions and 0 deletions

View File

@ -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.

View File

@ -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']