From 0068da71985b9ad5e2a5e7706bf7fd3026b5d4e8 Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Wed, 13 Nov 2013 18:20:10 +0530 Subject: [PATCH] CLOUDSTACK-5142: Guest IP address for F5 is not being selected from the defined IP Range in Shared Network ensure that for shared network, acuqire guest ip should return IP from the 'startip'-'endip' range of the network. --- .../ExternalLoadBalancerDeviceManagerImpl.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java index 8d54541dd62..3e0cd774710 100644 --- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java +++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java @@ -778,7 +778,20 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase String loadBalancingIpAddress = existedGuestIp; if (loadBalancingIpAddress == null) { - loadBalancingIpAddress = _ipAddrMgr.acquireGuestIpAddress(network, null); + if (network.getGuestType() == Network.GuestType.Isolated) { + loadBalancingIpAddress = _ipAddrMgr.acquireGuestIpAddress(network, null); + } else if (network.getGuestType() == Network.GuestType.Shared) { + try { + PublicIp directIp = _ipAddrMgr.assignPublicIpAddress(network.getDataCenterId(), + null, _accountDao.findById(network.getAccountId()), VlanType.DirectAttached, network.getId(), + null, true); + loadBalancingIpAddress = directIp.getAddress().addr(); + } catch (InsufficientCapacityException capException) { + String msg = "Ran out of guest IP addresses from the shared network."; + s_logger.error(msg); + throw new ResourceUnavailableException(msg, DataCenter.class, network.getDataCenterId()); + } + } } if (loadBalancingIpAddress == null) {