mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-2369 fixed adding same private gw twice
This commit is contained in:
parent
7370638915
commit
9b6513466f
|
|
@ -70,6 +70,7 @@ public interface PrivateIpDao extends GenericDao<PrivateIpVO, Long>{
|
|||
*/
|
||||
PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address);
|
||||
|
||||
|
||||
|
||||
|
||||
PrivateIpVO findByIpAndSourceNetworkIdAndVpcId(long networkId, String ip4Address, long vpcId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,16 @@ public class PrivateIpDaoImpl extends GenericDaoBase<PrivateIpVO, Long> implemen
|
|||
sc.setParameters("networkId", networkId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PrivateIpVO findByIpAndSourceNetworkIdAndVpcId(long networkId, String ip4Address, long vpcId) {
|
||||
SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("ip", ip4Address);
|
||||
sc.setParameters("networkId", networkId);
|
||||
sc.setParameters("vpcId", vpcId);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivateIpVO findByIpAndVpcId(long vpcId, String ip4Address) {
|
||||
SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
|
||||
|
|
|
|||
|
|
@ -3813,10 +3813,12 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
|||
s_logger.debug("Created private network " + privateNetwork);
|
||||
} else {
|
||||
s_logger.debug("Private network already exists: " + privateNetwork);
|
||||
throw new InvalidParameterValueException("Private network for the vlan: " + vlan + " and cidr "+ cidr +" already exists " +
|
||||
" in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());
|
||||
}
|
||||
|
||||
//add entry to private_ip_address table
|
||||
PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkId(privateNetwork.getId(), startIp);
|
||||
PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(), startIp, vpcId);
|
||||
if (privateIp != null) {
|
||||
throw new InvalidParameterValueException("Private ip address " + startIp + " already used for private gateway" +
|
||||
" in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());
|
||||
|
|
|
|||
Loading…
Reference in New Issue