@@ -113,10 +113,14 @@ public Site2SiteVpnGateway createVpnGateway(CreateVpnGatewayCmd cmd) {
113113
114114 @ Override
115115 public Site2SiteCustomerGateway createCustomerGateway (CreateVpnCustomerGatewayCmd cmd ) {
116+ String name = cmd .getName ();
116117 String gatewayIp = cmd .getGatewayIp ();
117118 if (!NetUtils .isValidIp (gatewayIp )) {
118119 throw new InvalidParameterValueException ("The customer gateway ip " + gatewayIp + " is invalid!" );
119120 }
121+ if (name == null ) {
122+ name = "VPN-" + gatewayIp ;
123+ }
120124 String guestCidrList = cmd .getGuestCidrList ();
121125 if (!NetUtils .validateGuestCidrList (guestCidrList )) {
122126 throw new InvalidParameterValueException ("The customer gateway guest cidr list " + guestCidrList + " is invalid guest cidr!" );
@@ -141,12 +145,15 @@ public Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCm
141145 if (_customerGatewayDao .findByGatewayIp (gatewayIp ) != null ) {
142146 throw new InvalidParameterValueException ("The customer gateway with ip " + gatewayIp + " already existed!" );
143147 }
148+ if (_customerGatewayDao .findByName (name ) != null ) {
149+ throw new InvalidParameterValueException ("The customer gateway with name " + name + " already existed!" );
150+ }
144151 Long accountId = cmd .getEntityOwnerId ();
145152 Long domainId = cmd .getDomainId ();
146153 if (domainId == null ) {
147154 domainId = Domain .ROOT_DOMAIN ;
148155 }
149- Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO (accountId , domainId , gatewayIp , guestCidrList , ipsecPsk ,
156+ Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO (name , accountId , domainId , gatewayIp , guestCidrList , ipsecPsk ,
150157 ikePolicy , espPolicy , lifetime );
151158 _customerGatewayDao .persist (gw );
152159 return gw ;
0 commit comments