CLOUDSTACK-191: Update checking for updateCustomerGateway
Reviewed-by: Anthony Xu
Conflicts:
server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit:
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/a82ee771
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/a82ee771
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/a82ee771
Branch: refs/heads/junit-tests
Commit: a82ee7715e9e9a33c6924359fef9060cee002151
Parents: 3a313ee
Author: Sheng Yang <[email protected]>
Authored: Mon Sep 24 16:39:01 2012 -0700
Committer: Sheng Yang <[email protected]>
Committed: Mon Sep 24 17:47:09 2012 -0700
----------------------------------------------------------------------
.../cloud/network/vpn/Site2SiteVpnManagerImpl.java | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a82ee771/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
index db678ae..ae0f4ec 100644
--- a/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java
@@ -468,12 +468,14 @@ public class Site2SiteVpnManagerImpl implements
Site2SiteVpnManager, Manager {
}
checkCustomerGatewayCidrList(guestCidrList);
-
+
long accountId = gw.getAccountId();
- if (_customerGatewayDao.findByGatewayIp(gatewayIp) != null) {
+ Site2SiteCustomerGatewayVO existedGw =
_customerGatewayDao.findByGatewayIp(gatewayIp);
+ if (existedGw != null && existedGw.getId() != gw.getId()) {
throw new InvalidParameterValueException("The customer gateway
with ip " + gatewayIp + " already existed in the system!");
}
- if (_customerGatewayDao.findByNameAndAccountId(name, accountId) !=
null) {
+ existedGw = _customerGatewayDao.findByNameAndAccountId(name,
accountId);
+ if (existedGw != null && existedGw.getId() != gw.getId()) {
throw new InvalidParameterValueException("The customer gateway
with name " + name + " already existed!");
}