reserve first IP (after g/w) of subnet for router nic - NSX

This commit is contained in:
Pearl Dsilva 2023-10-04 17:50:57 -04:00
parent 58eb567b25
commit be9e06f6af

View File

@ -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.