From 1eb71689df2c7bd20b2abc141e742b568192e28e Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Fri, 17 Feb 2012 15:12:47 -0800 Subject: [PATCH] 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 --- .../network/ExternalFirewallDeviceManagerImpl.java | 10 +++++++++- .../network/ExternalLoadBalancerDeviceManagerImpl.java | 3 +++ .../element/JuniperSRXExternalFirewallElement.java | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java index 2e6fa9f1091..4b6a0d09bf6 100644 --- a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java +++ b/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java @@ -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 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 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) { diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java index 499b8db5579..86822b781c2 100644 --- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java +++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java @@ -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(), diff --git a/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java b/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java index 77f7f41f4dc..bf75e8f15f8 100644 --- a/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java +++ b/server/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java @@ -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; } }