Skip to content

Commit be9e06f

Browse files
committed
reserve first IP (after g/w) of subnet for router nic - NSX
1 parent 58eb567 commit be9e06f

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,6 +2044,9 @@ public String acquireGuestIpAddressByPlacement(Network network, String requested
20442044
if (requestedIp != null) {
20452045
return this.acquireGuestIpAddress(network, requestedIp);
20462046
}
2047+
if ("NsxGuestNetworkGuru".equals(network.getGuruName())) {
2048+
return getRouterIp(network.getGateway());
2049+
}
20472050
String placementConfig = VrouterRedundantTiersPlacement.valueIn(network.getAccountId());
20482051
IpPlacement ipPlacement = IpPlacement.fromString(placementConfig);
20492052
switch (ipPlacement) {
@@ -2055,6 +2058,13 @@ public String acquireGuestIpAddressByPlacement(Network network, String requested
20552058
return this.acquireGuestIpAddress(network, null);
20562059
}
20572060

2061+
private String getRouterIp(String gatewayIp) {
2062+
int i = gatewayIp.lastIndexOf('.');
2063+
String ipPart1 = gatewayIp.substring(0, i);
2064+
int ipLastOctect = Integer.parseInt(gatewayIp.substring(i+1)) + 1;
2065+
return ipPart1.concat("." + ipLastOctect);
2066+
}
2067+
20582068
/**
20592069
* Get the list of public IPs that need to be applied for a static NAT enable/disable operation.
20602070
* Manipulating only these ips prevents concurrency issues when disabling static nat at the same time.

0 commit comments

Comments
 (0)