diff --git a/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java b/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java index c85328807df..b5829d5619e 100644 --- a/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java +++ b/server/src/main/java/com/cloud/network/IpAddressManagerImpl.java @@ -2044,6 +2044,9 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage if (requestedIp != null) { return this.acquireGuestIpAddress(network, requestedIp); } + if ("NsxGuestNetworkGuru".equals(network.getGuruName())) { + return getRouterIp(network.getGateway()); + } String placementConfig = VrouterRedundantTiersPlacement.valueIn(network.getAccountId()); IpPlacement ipPlacement = IpPlacement.fromString(placementConfig); switch (ipPlacement) { @@ -2055,6 +2058,13 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage return this.acquireGuestIpAddress(network, null); } + private String getRouterIp(String gatewayIp) { + int i = gatewayIp.lastIndexOf('.'); + String ipPart1 = gatewayIp.substring(0, i); + int ipLastOctect = Integer.parseInt(gatewayIp.substring(i+1)) + 1; + return ipPart1.concat("." + ipLastOctect); + } + /** * Get the list of public IPs that need to be applied for a static NAT enable/disable operation. * Manipulating only these ips prevents concurrency issues when disabling static nat at the same time.