mirror of https://github.com/apache/cloudstack.git
CS-15730: Prohibit create VPN connection from different gateway to same customer gateway
This commit is contained in:
parent
4b0f317074
commit
65ef8b24c1
|
|
@ -10,4 +10,5 @@ public interface Site2SiteVpnConnectionDao extends GenericDao<Site2SiteVpnConnec
|
|||
List<Site2SiteVpnConnectionVO> listByVpnGatewayId(long id);
|
||||
List<Site2SiteVpnConnectionVO> listByVpcId(long vpcId);
|
||||
Site2SiteVpnConnectionVO findByVpnGatewayIdAndCustomerGatewayId(long vpnId, long customerId);
|
||||
Site2SiteVpnConnectionVO findByCustomerGatewayId(long customerId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,4 +67,11 @@ public class Site2SiteVpnConnectionDaoImpl extends GenericDaoBase<Site2SiteVpnCo
|
|||
sc.setParameters("customerGatewayId", customerId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Site2SiteVpnConnectionVO findByCustomerGatewayId(long customerId) {
|
||||
SearchCriteria<Site2SiteVpnConnectionVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("customerGatewayId", customerId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,6 +211,12 @@ public class Site2SiteVpnManagerImpl implements Site2SiteVpnManager, Manager {
|
|||
throw new InvalidParameterValueException("The vpn connection with specified customer gateway id or vpn gateway id " +
|
||||
" already exists!", idList);
|
||||
}
|
||||
if (_vpnConnectionDao.findByCustomerGatewayId(customerGatewayId) != null) {
|
||||
List<IdentityProxy> idList = new ArrayList<IdentityProxy>();
|
||||
idList.add(new IdentityProxy(customerGateway, customerGatewayId, "customerGatewayId"));
|
||||
throw new InvalidParameterValueException("The vpn connection with specified customer gateway id " +
|
||||
" already exists!", idList);
|
||||
}
|
||||
Site2SiteVpnConnectionVO conn = new Site2SiteVpnConnectionVO(owner.getAccountId(), owner.getDomainId(), vpnGatewayId, customerGatewayId);
|
||||
conn.setState(State.Pending);
|
||||
_vpnConnectionDao.persist(conn);
|
||||
|
|
|
|||
Loading…
Reference in New Issue