Skip to content

Commit 86bbe21

Browse files
author
Sheng Yang
committed
CLOUDSTACK-494: Loose the limition of same ip used by site-to-site vpn
Different account can have same remote side IP now. Of course the remote side need to identify them and configured properly to handle it.
1 parent fff763e commit 86bbe21

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.cloud.utils.db.GenericDao;
2222

2323
public interface Site2SiteCustomerGatewayDao extends GenericDao<Site2SiteCustomerGatewayVO, Long> {
24-
Site2SiteCustomerGatewayVO findByGatewayIp(String ip);
24+
Site2SiteCustomerGatewayVO findByGatewayIpAndAccountId(String ip, long accountId);
2525
Site2SiteCustomerGatewayVO findByNameAndAccountId(String name, long accountId);
2626
List<Site2SiteCustomerGatewayVO> listByAccountId(long accountId);
2727
}

engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayDaoImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ protected Site2SiteCustomerGatewayDaoImpl() {
4343
}
4444

4545
@Override
46-
public Site2SiteCustomerGatewayVO findByGatewayIp(String ip) {
46+
public Site2SiteCustomerGatewayVO findByGatewayIpAndAccountId(String ip, long accountId) {
4747
SearchCriteria<Site2SiteCustomerGatewayVO> sc = AllFieldsSearch.create();
4848
sc.setParameters("gatewayIp", ip);
49+
sc.setParameters("accountId", accountId);
4950
return findOneBy(sc);
5051
}
5152

server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCm
208208
}
209209

210210
long accountId = owner.getAccountId();
211-
if (_customerGatewayDao.findByGatewayIp(gatewayIp) != null) {
211+
if (_customerGatewayDao.findByGatewayIpAndAccountId(gatewayIp, accountId) != null) {
212212
throw new InvalidParameterValueException("The customer gateway with ip " + gatewayIp + " already existed in the system!");
213213
}
214214
if (_customerGatewayDao.findByNameAndAccountId(name, accountId) != null) {
@@ -454,7 +454,7 @@ public Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCm
454454
checkCustomerGatewayCidrList(guestCidrList);
455455

456456
long accountId = gw.getAccountId();
457-
Site2SiteCustomerGatewayVO existedGw = _customerGatewayDao.findByGatewayIp(gatewayIp);
457+
Site2SiteCustomerGatewayVO existedGw = _customerGatewayDao.findByGatewayIpAndAccountId(gatewayIp, accountId);
458458
if (existedGw != null && existedGw.getId() != gw.getId()) {
459459
throw new InvalidParameterValueException("The customer gateway with ip " + gatewayIp + " already existed in the system!");
460460
}

0 commit comments

Comments
 (0)