NSXv: Fix validation for bgp peer 'esg_id' attr and peer removal
Not every bgp peer object required to have a valid 'esg_id', it could be left blank if the bgp peer doesn't correspond with any NSX ESG. Change-Id: I33b655b047a0f2b1cb22f5625a90fda180bcfeec
This commit is contained in:
parent
8548f110ac
commit
064b72d342
|
@ -25,7 +25,7 @@ ESG_BGP_PEER_EXT_ALIAS = 'edge-service-gateway-bgp-peer'
|
|||
|
||||
|
||||
def _validate_edge_service_gw_id(esg_id, valid_values=None):
|
||||
if re.match(r'^edge-[1-9]+[0-9]*$', esg_id) is None:
|
||||
if esg_id and re.match(r'^edge-[1-9]+[0-9]*$', esg_id) is None:
|
||||
msg = _("'%s' is not a valid edge service gateway id.") % esg_id
|
||||
return msg
|
||||
|
||||
|
|
|
@ -147,8 +147,8 @@ class NSXvBgpPlugin(service_base.ServicePluginBase, bgp_db.BgpDbMixin):
|
|||
|
||||
def remove_bgp_peer(self, context, bgp_speaker_id, bgp_peer_info):
|
||||
with locking.LockManager.get_lock(str(bgp_speaker_id)):
|
||||
speaker = self._get_bgp_speaker(context, bgp_speaker_id)
|
||||
if bgp_peer_info['bgp_peer_id'] not in speaker['peers']:
|
||||
peers = self.get_bgp_peers_by_bgp_speaker(context, bgp_speaker_id)
|
||||
if bgp_peer_info['bgp_peer_id'] not in [p['id'] for p in peers]:
|
||||
return
|
||||
self.nsxv_driver.remove_bgp_peer(context,
|
||||
bgp_speaker_id, bgp_peer_info)
|
||||
|
|
|
@ -247,8 +247,9 @@ class NSXvBgpDriver(object):
|
|||
neighbour = bgp_neighbour(old_bgp_peer)
|
||||
for bgp_speaker_id in bgp_speaker_ids:
|
||||
with locking.LockManager.get_lock(bgp_speaker_id):
|
||||
speaker = self._plugin.get_bgp_speaker(context, bgp_speaker_id)
|
||||
if bgp_peer_id not in speaker['peers']:
|
||||
peers = self._plugin.get_bgp_peers_by_bgp_speaker(
|
||||
context, bgp_speaker_id)
|
||||
if bgp_peer_id not in [p['id'] for p in peers]:
|
||||
continue
|
||||
bgp_bindings = nsxv_db.get_nsxv_bgp_speaker_bindings(
|
||||
context.session, bgp_speaker_id)
|
||||
|
|
Loading…
Reference in New Issue