NSXv BGP: Fix bgp-peer esg-id validation

Change-Id: I28338121122e8cb8602735fc48461d77fb57b945
This commit is contained in:
Roey Chen 2017-06-28 04:58:03 -07:00
parent b60a7f48f1
commit 8824cb267a

View File

@ -21,10 +21,14 @@ from neutron_lib import exceptions as nexception
from vmware_nsx._i18n import _ from vmware_nsx._i18n import _
EDGE_SERVICE_GW = 'esg_id' EDGE_SERVICE_GW = 'esg_id'
EDGE_ID_MAX_LEN = 15
ESG_BGP_PEER_EXT_ALIAS = 'edge-service-gateway-bgp-peer' ESG_BGP_PEER_EXT_ALIAS = 'edge-service-gateway-bgp-peer'
def _validate_edge_service_gw_id(esg_id, valid_values=None): def _validate_edge_service_gw_id(esg_id, valid_values=None):
msg = validators.validate_string(esg_id, max_len=EDGE_ID_MAX_LEN)
if msg:
return msg
if esg_id and 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 msg = _("'%s' is not a valid edge service gateway id.") % esg_id
return msg return msg