cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [10/12] git commit: updated refs/heads/internallb to e665f2a
Date Mon, 08 Apr 2013 22:24:17 GMT
InternalLB:

1) Added new capability for the LB service - LbSchemes. Can take 2 values - Internal and Public.
2) F5 and Netscaler LB providers - changes all LB related methods to accept LoadBalancingRule
instead of ? extends FirewallRule.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0ed4e852
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0ed4e852
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0ed4e852

Branch: refs/heads/internallb
Commit: 0ed4e8527b62eb65deefa5a41ba074c714937f87
Parents: b468d5f
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Apr 8 12:34:59 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Apr 8 15:23:56 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java             |   15 +---
 .../com/cloud/network/lb/LoadBalancingRule.java    |    4 +
 .../element/ElasticLoadBalancerElement.java        |   22 ++++-
 .../element/F5ExternalLoadBalancerElement.java     |   65 ++++++++++---
 .../cloud/network/element/NetscalerElement.java    |   74 ++++++++++-----
 .../network/ExternalLoadBalancerDeviceManager.java |    6 +-
 .../ExternalLoadBalancerDeviceManagerImpl.java     |   20 +----
 .../network/element/VirtualRouterElement.java      |   19 ++++-
 8 files changed, 148 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java
index c0b0117..159274b 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -19,7 +19,6 @@ package com.cloud.network;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.api.Identity;
@@ -28,20 +27,9 @@ import org.apache.cloudstack.api.InternalIdentity;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.Networks.BroadcastDomainType;
-import com.cloud.network.Networks.Mode;
-import com.cloud.network.Networks.TrafficType;
 import com.cloud.utils.fsm.StateMachine2;
 import com.cloud.utils.fsm.StateObject;
 
-import org.apache.cloudstack.acl.ControlledEntity;
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * owned by an account.
  */
@@ -63,7 +51,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>,
I
                 Capability.MultipleIps, Capability.TrafficStatistics, Capability.SupportedTrafficDirection,
Capability.SupportedEgressProtocols);
         public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms,
Capability.SupportedLBIsolation,
                 Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps,
-                Capability.SupportedStickinessMethods, Capability.ElasticLb);
+                Capability.SupportedStickinessMethods, Capability.ElasticLb, Capability.LbSchemes);
         public static final Service UserData = new Service("UserData");
         public static final Service SourceNat = new Service("SourceNat", Capability.SupportedSourceNatTypes,
Capability.RedundantRouter);
         public static final Service StaticNat = new Service("StaticNat", Capability.ElasticIp);
@@ -188,6 +176,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>,
I
         public static final Capability SupportedTrafficDirection = new Capability("SupportedTrafficDirection");
         public static final Capability SupportedEgressProtocols = new Capability("SupportedEgressProtocols");
         public static final Capability HealthCheckPolicy = new Capability("HealthCheckPolicy");
+        public static final Capability LbSchemes = new Capability("LbSchemes");
 
         private String name;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/api/src/com/cloud/network/lb/LoadBalancingRule.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRule.java b/api/src/com/cloud/network/lb/LoadBalancingRule.java
index f7710f6..4b37782 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRule.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRule.java
@@ -25,6 +25,7 @@ import com.cloud.network.as.Condition;
 import com.cloud.network.as.Counter;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.LoadBalancer;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.utils.Pair;
 import com.cloud.utils.net.Ip;
 
@@ -418,4 +419,7 @@ public class LoadBalancingRule {
         return sourceIp;
     }
 
+    public Scheme getScheme() {
+        return lb.getScheme();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/element/ElasticLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/element/ElasticLoadBalancerElement.java
b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/element/ElasticLoadBalancerElement.java
index bebba3c..8b1b414 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/element/ElasticLoadBalancerElement.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/element/ElasticLoadBalancerElement.java
@@ -35,6 +35,7 @@ import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.exception.UnsupportedServiceException;
 import com.cloud.network.Network;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Provider;
@@ -46,6 +47,7 @@ import com.cloud.network.PublicIpAddress;
 import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.lb.ElasticLoadBalancerManager;
 import com.cloud.network.lb.LoadBalancingRule;
+import com.cloud.network.rules.LoadBalancerContainer;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.utils.component.AdapterBase;
@@ -68,12 +70,25 @@ public class ElasticLoadBalancerElement extends AdapterBase implements
LoadBalan
     boolean _enabled;
     TrafficType _frontEndTrafficType = TrafficType.Guest;
     
-    private boolean canHandle(Network network) {
+    private boolean canHandle(Network network, List<LoadBalancingRule> rules) {
         if (network.getGuestType() != Network.GuestType.Shared|| network.getTrafficType()
!= TrafficType.Guest) {
             s_logger.debug("Not handling network with type  " + network.getGuestType() +
" and traffic type " + network.getTrafficType());
             return false;
         }
         
+        Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+        if (!lbCaps.isEmpty()) {
+            String schemeCaps = lbCaps.get(Capability.LbSchemes);
+            if (schemeCaps != null) {
+                for (LoadBalancingRule rule : rules) {
+                    if (!schemeCaps.contains(rule.getScheme().toString())) {
+                        s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported
by the provider " + this.getName());
+                        return false;
+                    }
+                }
+            }
+        }
+        
         return true;
     }
     
@@ -94,6 +109,7 @@ public class ElasticLoadBalancerElement extends AdapterBase implements
LoadBalan
         lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn,source");
         lbCapabilities.put(Capability.SupportedLBIsolation, "shared");
         lbCapabilities.put(Capability.SupportedProtocols, "tcp, udp");
+        lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
         
         capabilities.put(Service.Lb, lbCapabilities);   
         return capabilities;
@@ -139,10 +155,10 @@ public class ElasticLoadBalancerElement extends AdapterBase implements
LoadBalan
     
     @Override
     public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws
ResourceUnavailableException {
-        if (!canHandle(network)) {
+        if (!canHandle(network, rules)) {
             return false;
         }
-        
+                
         return _lbMgr.applyLoadBalancerRules(network, rules);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
index 77f6b60..e4002a2 100644
--- a/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
+++ b/plugins/network-elements/f5/src/com/cloud/network/element/F5ExternalLoadBalancerElement.java
@@ -31,7 +31,14 @@ import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.api.ApiDBUtils;
-import com.cloud.api.commands.*;
+import com.cloud.api.commands.AddExternalLoadBalancerCmd;
+import com.cloud.api.commands.AddF5LoadBalancerCmd;
+import com.cloud.api.commands.ConfigureF5LoadBalancerCmd;
+import com.cloud.api.commands.DeleteExternalLoadBalancerCmd;
+import com.cloud.api.commands.DeleteF5LoadBalancerCmd;
+import com.cloud.api.commands.ListExternalLoadBalancersCmd;
+import com.cloud.api.commands.ListF5LoadBalancerNetworksCmd;
+import com.cloud.api.commands.ListF5LoadBalancersCmd;
 import com.cloud.api.response.F5LoadBalancerResponse;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
@@ -40,22 +47,41 @@ import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.*;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InsufficientNetworkCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.host.dao.HostDetailsDao;
-import com.cloud.network.*;
+import com.cloud.network.ExternalLoadBalancerDeviceManager;
+import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl;
+import com.cloud.network.Network;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.TrafficType;
-import com.cloud.network.dao.*;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.PublicIpAddress;
+import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
+import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
 import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceState;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
+import com.cloud.network.dao.NetworkExternalLoadBalancerVO;
+import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.network.resource.F5BigIpResource;
 import com.cloud.network.rules.LbStickinessMethod;
 import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
+import com.cloud.network.rules.LoadBalancerContainer;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -64,13 +90,6 @@ import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 import com.google.gson.Gson;
-import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
-import org.apache.log4j.Logger;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import java.util.*;
 
 @Local(value = {NetworkElement.class, LoadBalancingServiceProvider.class, IpDeployer.class})
 public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceManagerImpl
implements LoadBalancingServiceProvider, IpDeployer, F5ExternalLoadBalancerElementService,
ExternalLoadBalancerDeviceManager {
@@ -100,11 +119,24 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
     @Inject
     ConfigurationDao _configDao;
 
-    private boolean canHandle(Network config) {
+    private boolean canHandle(Network config, List<LoadBalancingRule> rules) {
         if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType()
!= TrafficType.Guest) {
             s_logger.trace("Not handling network with Type  " + config.getGuestType() + "
and traffic type " + config.getTrafficType());
             return false;
         }
+        
+        Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+        if (!lbCaps.isEmpty()) {
+            String schemeCaps = lbCaps.get(Capability.LbSchemes);
+            if (schemeCaps != null && rules != null && !rules.isEmpty())
{
+                for (LoadBalancingRule rule : rules) {
+                    if (!schemeCaps.contains(rule.getScheme().toString())) {
+                        s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not supported
by the provider " + this.getName());
+                        return false;
+                    }
+                }
+            }
+        }
 
         return (_networkManager.isProviderForNetwork(getProvider(), config.getId()) &&
_ntwkSrvcDao.canProviderSupportServiceInNetwork(config.getId(), Service.Lb, Network.Provider.F5BigIp));
     }
@@ -113,7 +145,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
     public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination
dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
     InsufficientNetworkCapacityException {
 
-        if (!canHandle(guestConfig)) {
+        if (!canHandle(guestConfig, null)) {
             return false;
         }
 
@@ -137,7 +169,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
 
     @Override
     public boolean shutdown(Network guestConfig, ReservationContext context, boolean cleanup)
throws ResourceUnavailableException, ConcurrentOperationException {
-        if (!canHandle(guestConfig)) {
+        if (!canHandle(guestConfig, null)) {
             return false;
         }
 
@@ -162,7 +194,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
 
     @Override
     public boolean applyLBRules(Network config, List<LoadBalancingRule> rules) throws
ResourceUnavailableException {
-        if (!canHandle(config)) {
+        if (!canHandle(config, rules)) {
             return false;
         }
 
@@ -193,6 +225,9 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
 
         // Support inline mode with firewall
         lbCapabilities.put(Capability.InlineMode, "true");
+        
+        //support only for public lb
+        lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
 
         LbStickinessMethod method;
         List<LbStickinessMethod> methodList = new ArrayList<LbStickinessMethod>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
index bf2f56b..98b8939 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/element/NetscalerElement.java
@@ -16,6 +16,22 @@
 // under the License.
 package com.cloud.network.element;
 
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
+import org.apache.cloudstack.region.gslb.GslbServiceProvider;
+import org.apache.log4j.Logger;
+
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.routing.GlobalLoadBalancerConfigCommand;
@@ -25,7 +41,11 @@ import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
 import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.agent.api.to.StaticNatRuleTO;
 import com.cloud.api.ApiDBUtils;
-import com.cloud.api.commands.*;
+import com.cloud.api.commands.AddNetscalerLoadBalancerCmd;
+import com.cloud.api.commands.ConfigureNetscalerLoadBalancerCmd;
+import com.cloud.api.commands.DeleteNetscalerLoadBalancerCmd;
+import com.cloud.api.commands.ListNetscalerLoadBalancerNetworksCmd;
+import com.cloud.api.commands.ListNetscalerLoadBalancersCmd;
 import com.cloud.api.response.NetscalerLoadBalancerResponse;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
@@ -37,27 +57,48 @@ import com.cloud.dc.HostPodVO;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.DataCenterIpAddressDao;
 import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.*;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InsufficientNetworkCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.host.dao.HostDetailsDao;
-import com.cloud.network.*;
+import com.cloud.network.ExternalLoadBalancerDeviceManager;
+import com.cloud.network.ExternalLoadBalancerDeviceManagerImpl;
+import com.cloud.network.IpAddress;
+import com.cloud.network.NetScalerPodVO;
+import com.cloud.network.Network;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.TrafficType;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.PublicIpAddress;
 import com.cloud.network.as.AutoScaleCounter;
 import com.cloud.network.as.AutoScaleCounter.AutoScaleCounterType;
-import com.cloud.network.dao.*;
+import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
+import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
 import com.cloud.network.dao.ExternalLoadBalancerDeviceVO.LBDeviceState;
+import com.cloud.network.dao.NetScalerPodDao;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
+import com.cloud.network.dao.NetworkExternalLoadBalancerVO;
+import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.network.lb.LoadBalancingRule.LbDestination;
 import com.cloud.network.resource.NetscalerResource;
 import com.cloud.network.rules.FirewallRule;
-import com.cloud.network.rules.FirewallRule.Purpose;
 import com.cloud.network.rules.LbStickinessMethod;
 import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
+import com.cloud.network.rules.LoadBalancerContainer;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.utils.NumbersUtil;
@@ -70,15 +111,6 @@ import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 import com.google.gson.Gson;
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
-import org.apache.cloudstack.region.gslb.GslbServiceProvider;
-import org.apache.log4j.Logger;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import java.net.URI;
-import java.util.*;
 
 @Local(value = {NetworkElement.class, StaticNatServiceProvider.class, LoadBalancingServiceProvider.class,
GslbServiceProvider.class})
 public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider,
@@ -231,6 +263,9 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         // Specifies that load balancing rules can only be made with public IPs that aren't
source NAT IPs
         lbCapabilities.put(Capability.LoadBalancingSupportedIps, "additional");
 
+        // Supports only Public load balancing
+        lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
+        
         // Specifies that load balancing rules can support autoscaling and the list of counters
it supports
         AutoScaleCounter counter;
         List<AutoScaleCounter> counterList = new ArrayList<AutoScaleCounter>();
@@ -638,14 +673,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         return this;
     }
 
-    public boolean applyElasticLoadBalancerRules(Network network, List<? extends FirewallRule>
rules) throws ResourceUnavailableException {
-
-        List<LoadBalancingRule> loadBalancingRules = new ArrayList<LoadBalancingRule>();
-        for (FirewallRule rule : rules) {
-            if (rule.getPurpose().equals(Purpose.LoadBalancing)) {
-                loadBalancingRules.add((LoadBalancingRule) rule);
-            }
-        }
+    public boolean applyElasticLoadBalancerRules(Network network, List<LoadBalancingRule>
loadBalancingRules) throws ResourceUnavailableException {
 
         if (loadBalancingRules == null || loadBalancingRules.isEmpty()) {
             return true;
@@ -821,7 +849,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl
impl
         return null;
     }
 
-    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<? extends
FirewallRule> rules)
+    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<LoadBalancingRule>
rules)
             throws ResourceUnavailableException {
         return super.getLBHealthChecks(network, rules);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java
index 9f11b85..cb00614 100644
--- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java
+++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManager.java
@@ -23,7 +23,7 @@ import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.network.dao.ExternalLoadBalancerDeviceVO;
-import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.resource.ServerResource;
 import com.cloud.utils.component.Manager;
 
@@ -89,7 +89,7 @@ public interface ExternalLoadBalancerDeviceManager extends Manager{
      * @return true if successfully applied rules
      * @throws ResourceUnavailableException
      */
-    public boolean applyLoadBalancerRules(Network network, List<? extends FirewallRule>
rules) throws ResourceUnavailableException;
+    public boolean applyLoadBalancerRules(Network network, List<LoadBalancingRule>
rules) throws ResourceUnavailableException;
 
     /**
      * implements or shutdowns guest network on the load balancer device assigned to the
guest network
@@ -102,6 +102,6 @@ public interface ExternalLoadBalancerDeviceManager extends Manager{
     public boolean manageGuestNetworkWithExternalLoadBalancer(boolean add, Network guestConfig)
throws ResourceUnavailableException,
             InsufficientCapacityException;
 
-    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<? extends
FirewallRule> rules)
+    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<LoadBalancingRule>
rules)
             throws ResourceUnavailableException;
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
index dea0e0c..4268039 100644
--- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
@@ -829,19 +829,11 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends
AdapterBase
     }
 
     @Override
-    public boolean applyLoadBalancerRules(Network network, List<? extends FirewallRule>
rules) throws ResourceUnavailableException {
+    public boolean applyLoadBalancerRules(Network network, List<LoadBalancingRule>
loadBalancingRules) throws ResourceUnavailableException {
         // Find the external load balancer in this zone
         long zoneId = network.getDataCenterId();
         DataCenterVO zone = _dcDao.findById(zoneId);
 
-        List<LoadBalancingRule> loadBalancingRules = new ArrayList<LoadBalancingRule>();
-
-        for (FirewallRule rule : rules) {
-            if (rule.getPurpose().equals(Purpose.LoadBalancing)) {
-                loadBalancingRules.add((LoadBalancingRule) rule);
-            }
-        }
-
         if (loadBalancingRules == null || loadBalancingRules.isEmpty()) {
             return true;
         }
@@ -1115,7 +1107,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends
AdapterBase
     }
 
     @Override
-    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<? extends
FirewallRule> rules)
+    public List<LoadBalancerTO> getLBHealthChecks(Network network, List<LoadBalancingRule>
loadBalancingRules)
             throws ResourceUnavailableException {
 
         // Find the external load balancer in this zone
@@ -1123,14 +1115,6 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends
AdapterBase
         DataCenterVO zone = _dcDao.findById(zoneId);
         HealthCheckLBConfigAnswer answer = null;
 
-        List<LoadBalancingRule> loadBalancingRules = new ArrayList<LoadBalancingRule>();
-
-        for (FirewallRule rule : rules) {
-            if (rule.getPurpose().equals(Purpose.LoadBalancing)) {
-                loadBalancingRules.add((LoadBalancingRule) rule);
-            }
-        }
-
         if (loadBalancingRules == null || loadBalancingRules.isEmpty()) {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0ed4e852/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index 6fb6ad6..2d4e718 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -25,7 +25,6 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import com.cloud.utils.PropertiesUtil;
 import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
 import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
 import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
@@ -66,6 +65,7 @@ import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.LbStickinessMethod;
 import com.cloud.network.rules.LbStickinessMethod.StickinessMethodType;
+import com.cloud.network.rules.LoadBalancerContainer;
 import com.cloud.network.rules.PortForwardingRule;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.network.rules.StaticNat;
@@ -351,6 +351,19 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     @Override
     public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws
ResourceUnavailableException {
         if (canHandle(network, Service.Lb)) {
+            Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+            if (!lbCaps.isEmpty()) {
+                String schemeCaps = lbCaps.get(Capability.LbSchemes);
+                if (schemeCaps != null) {
+                    for (LoadBalancingRule rule : rules) {
+                        if (!schemeCaps.contains(rule.getScheme().toString())) {
+                            s_logger.debug("Scheme " + rules.get(0).getScheme() + " is not
supported by the provider " + this.getName());
+                            return false;
+                        }
+                    }
+                }
+            }
+            
             List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(),
Role.VIRTUAL_ROUTER);
             if (routers == null || routers.isEmpty()) {
                 s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules
on the backend; virtual " +
@@ -363,6 +376,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
             } else {
                 return true;
             }
+            
+            
         } else {
             return false;
         }
@@ -557,8 +572,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
         lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn,source");
         lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated");
         lbCapabilities.put(Capability.SupportedProtocols, "tcp, udp");
-
         lbCapabilities.put(Capability.SupportedStickinessMethods, getHAProxyStickinessCapability());
+        lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Public.toString());
 
         capabilities.put(Service.Lb, lbCapabilities);
 


Mime
View raw message