bug 13829: Add default capacity for SRX

And per Alex's request, add default value directly into the database, rather
than using it at last minute of implemention.

status 13829: resolved fixed

Reviewed-by: Alex
This commit is contained in:
Sheng Yang 2012-02-17 15:12:47 -08:00
parent 56a54819d3
commit d94189a3d9
3 changed files with 14 additions and 2 deletions

View File

@ -138,11 +138,13 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
@Inject HostDetailsDao _hostDetailDao;
private static final org.apache.log4j.Logger s_logger = Logger.getLogger(ExternalFirewallDeviceManagerImpl.class);
private long _defaultFwCapacity;
@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
super.configure(name, params);
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
_defaultFwCapacity = NumbersUtil.parseLong(_configDao.getValue(Config.DefaultExternalFirewallCapacity.key()), 50);
return true;
}
@ -211,6 +213,9 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
boolean dedicatedUse = (configParams.get(ApiConstants.FIREWALL_DEVICE_DEDICATED) != null) ? Boolean.parseBoolean(configParams.get(ApiConstants.FIREWALL_DEVICE_DEDICATED)) : false;
long capacity = NumbersUtil.parseLong((String)configParams.get(ApiConstants.FIREWALL_DEVICE_CAPACITY), 0);
if (capacity == 0) {
capacity = _defaultFwCapacity;
}
ExternalFirewallDeviceVO fwDevice = new ExternalFirewallDeviceVO(externalFirewall.getId(), pNetwork.getId(), ntwkSvcProvider.getProviderName(),
deviceName, capacity, dedicatedUse);
@ -298,6 +303,9 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
for (ExternalFirewallDeviceVO fwDevice: fwDevices) {
// max number of guest networks that can be mapped to this device
long fullCapacity = fwDevice.getCapacity();
if (fullCapacity == 0) {
fullCapacity = _defaultFwCapacity; // if capacity not configured then use the default
}
// get the list of guest networks that are mapped to this load balancer
List<NetworkExternalFirewallVO> mappedNetworks = _networkExternalFirewallDao.listByFirewallDeviceId(fwDevice.getId());
@ -308,7 +316,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase impl
}
}
throw new InsufficientNetworkCapacityException("Unable to find a firewall provider with sufficient capcity " +
" to implement the network", Network.class, network.getId());
" to implement the network", DataCenter.class, network.getDataCenterId());
}
public String getExternalNetworkResourceGuid(long physicalNetworkId, String deviceName, String ip) {

View File

@ -257,6 +257,9 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
boolean dedicatedUse = (configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED) != null) ? Boolean.parseBoolean(configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_DEDICATED)) : false;
boolean inline = (configParams.get(ApiConstants.INLINE) != null) ? Boolean.parseBoolean(configParams.get(ApiConstants.INLINE)) : false;
long capacity = NumbersUtil.parseLong((String) configParams.get(ApiConstants.LOAD_BALANCER_DEVICE_CAPACITY), 0);
if (capacity == 0) {
capacity = _defaultLbCapacity;
}
txn.start();
ExternalLoadBalancerDeviceVO lbDeviceVO = new ExternalLoadBalancerDeviceVO(host.getId(), pNetwork.getId(), ntwkSvcProvider.getProviderName(),

View File

@ -167,7 +167,8 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
return manageGuestNetworkWithExternalFirewall(true, network);
} catch (InsufficientCapacityException capacityException) {
// TODO: handle out of capacity exception in more gracefule manner when multiple providers are present for
// the network
// the network
s_logger.error("Fail to implement the JuniperSRX for network " + network, capacityException);
return false;
}
}