Skip to content

Commit 102e2df

Browse files
author
Pearl Dsilva
committed
Fix IP address conflict
1 parent f836200 commit 102e2df

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

server/src/main/java/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
3434
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
35+
import org.apache.cloudstack.api.ApiConstants;
3536
import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse;
3637
import org.apache.cloudstack.context.CallContext;
3738
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
@@ -850,10 +851,16 @@ public IPAddressVO doInTransaction(TransactionStatus status) throws Insufficient
850851
errorMessage.append(", network id=" + guestNetworkId);
851852
}
852853
sc.setJoinParameters("vlan", "type", vlanUse);
853-
854+
String routerIpAddress = null;
855+
if (network != null) {
856+
NetworkDetailVO routerIpDetail = _networkDetailsDao.findDetail(network.getId(), ApiConstants.ROUTER_IP);
857+
routerIpAddress = routerIpDetail != null ? routerIpDetail.getValue() : null;
858+
}
854859
if (requestedIp != null) {
855860
sc.addAnd("address", SearchCriteria.Op.EQ, requestedIp);
856861
errorMessage.append(": requested ip " + requestedIp + " is not available");
862+
} else if (routerIpAddress != null) {
863+
sc.addAnd("address", Op.NEQ, routerIpAddress);
857864
}
858865

859866
boolean ascOrder = ! forSystemVms;
@@ -2104,7 +2111,6 @@ public void allocateDirectIp(final NicProfile nic, final DataCenter dc, final Vi
21042111
public void doInTransactionWithoutResult(TransactionStatus status) throws InsufficientAddressCapacityException {
21052112
//This method allocates direct ip for the Shared network in Advance zones
21062113
boolean ipv4 = false;
2107-
21082114
if (network.getGateway() != null) {
21092115
if (nic.getIPv4Address() == null) {
21102116
PublicIp ip = null;

0 commit comments

Comments
 (0)