cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pran...@apache.org
Subject [07/56] [abbrv] CLOUDSTACK-747: Internal LB between VPC tiers support
Date Tue, 14 May 2013 11:21:42 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 687c3c1..cdc1992 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -577,6 +577,17 @@ revertToVMSnapshot=15
 #### Baremetal commands
 addBaremetalHost=1
 
+#### New Load Balancer commands
+createLoadBalancer=15
+listLoadBalancers=15
+deleteLoadBalancer=15
+
+#Internal Load Balancer Element commands
+configureInternalLoadBalancerElement=1
+createInternalLoadBalancerElement=1
+listInternalLoadBalancerElements=1
+
+
 #### Affinity group commands
 createAffinityGroup=15
 deleteAffinityGroup=15
@@ -594,5 +605,10 @@ addCiscoAsa1000vResource=1
 deleteCiscoAsa1000vResource=1
 listCiscoAsa1000vResources=1
 
+#### Internal LB VM commands
+stopInternalLoadBalancerVM=1
+startInternalLoadBalancerVM=1
+listInternalLoadBalancerVMs=1
+
 ### Network Isolation methods listing
 listNetworkIsolationMethods=1

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index 7a46981..8a45e5f 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -198,6 +198,7 @@
           <ref bean="VirtualRouter"/>
           <ref bean="VpcVirtualRouter"/>
           <ref bean="NiciraNvp"/>
+          <ref bean="InternalLbVm"/>
       </list>
     </property>
   </bean>
@@ -241,6 +242,7 @@
           <ref bean="VpcVirtualRouter"/>
           <ref bean="NiciraNvp" />
           <ref bean="MidoNetElement"/>
+          <ref bean="InternalLbVm"/>
 <!--
           <ref bean="BareMetalDhcp"/>
           <ref bean="BareMetalPxe"/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/client/tomcatconf/nonossComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in
index ff52457..1b6ee6e 100644
--- a/client/tomcatconf/nonossComponentContext.xml.in
+++ b/client/tomcatconf/nonossComponentContext.xml.in
@@ -294,6 +294,7 @@
           <ref bean="VirtualRouter"/>
           <ref bean="VpcVirtualRouter"/>
           <ref bean="NiciraNvp"/>
+          <ref bean="InternalLbVm"/>
       </list>
     </property>
   </bean>
@@ -343,6 +344,7 @@
           <ref bean="Ovs"/>
           <ref bean="SecurityGroupProvider"/>
           <ref bean="VpcVirtualRouter"/>
+          <ref bean="InternalLbVm"/>
 <!--
           <ref bean="BareMetalDhcp"/>
           <ref bean="BareMetalPxe"/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/client/tomcatconf/simulatorComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/simulatorComponentContext.xml.in b/client/tomcatconf/simulatorComponentContext.xml.in
index 9d8c6c0..652c4c8 100644
--- a/client/tomcatconf/simulatorComponentContext.xml.in
+++ b/client/tomcatconf/simulatorComponentContext.xml.in
@@ -205,6 +205,7 @@
         <ref bean="Ovs"/>
         <ref bean="SecurityGroupProvider"/>
         <ref bean="VpcVirtualRouter"/>
+        <ref bean="InternalLbVm"/>
         <!--
                   <ref bean="BareMetalDhcp"/>
                   <ref bean="BareMetalPxe"/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java b/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java
index 0bbaa93..6b9b3bb 100644
--- a/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java
+++ b/engine/schema/src/com/cloud/network/dao/FirewallRulesDao.java
@@ -18,7 +18,6 @@ package com.cloud.network.dao;
 
 import java.util.List;
 
-import com.cloud.host.HostVO;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.utils.db.GenericDao;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
index c5c78e5..ae27e95 100644
--- a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
+++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java
@@ -31,12 +31,8 @@ import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
-import org.apache.cloudstack.api.Identity;
-
 import com.cloud.network.IpAddress;
-import com.cloud.network.IpAddress.State;
 import com.cloud.utils.net.Ip;
-import org.apache.cloudstack.api.InternalIdentity;
 
 /**
  * A bean representing a public IP Address
@@ -304,4 +300,9 @@ public class IPAddressVO implements IpAddress {
     public void setVmIp(String vmIp) {
         this.vmIp = vmIp;
     }
+
+    @Override
+    public Long getNetworkId() {
+        return sourceNetworkId;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
index 611282e..331f755 100644
--- a/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerDao.java
@@ -18,19 +18,15 @@ package com.cloud.network.dao;
 
 import java.util.List;
 
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.utils.db.GenericDao;
 
 public interface LoadBalancerDao extends GenericDao<LoadBalancerVO, Long> {
-    List<Long> listInstancesByLoadBalancer(long loadBalancerId);
 
     List<LoadBalancerVO> listByIpAddress(long ipAddressId);
 
-    LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort);
+    List<LoadBalancerVO> listByNetworkIdAndScheme(long networkId, Scheme scheme);
 
-    LoadBalancerVO findByAccountAndName(Long accountId, String name);
-
-    List<LoadBalancerVO> listByNetworkId(long networkId);
-
-    List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId);
+    List<LoadBalancerVO> listInTransitionStateByNetworkIdAndScheme(long networkId, Scheme scheme);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
index f211a7f..c20d8b2 100644
--- a/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
@@ -16,39 +16,24 @@
 // under the License.
 package com.cloud.network.dao;
 
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
 import java.util.List;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
 import com.cloud.network.rules.FirewallRule.State;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.Transaction;
 
 @Component
 @Local(value = { LoadBalancerDao.class })
 public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> implements LoadBalancerDao {
-    private static final Logger s_logger = Logger.getLogger(LoadBalancerDaoImpl.class);
-    private static final String LIST_INSTANCES_BY_LOAD_BALANCER = "SELECT vm.id " +
-            "    FROM vm_instance vm, load_balancer lb, ip_forwarding fwd, user_ip_address ip " +
-            "    WHERE lb.id = ? AND " +
-            "          fwd.group_id = lb.id AND " +
-            "          fwd.forwarding = 0 AND " +
-            "          fwd.private_ip_address = vm.private_ip_address AND " +
-            "          lb.ip_address = ip.public_ip_address AND " +
-            "          ip.data_center_id = vm.data_center_id ";
     private final SearchBuilder<LoadBalancerVO> ListByIp;
-    private final SearchBuilder<LoadBalancerVO> IpAndPublicPortSearch;
-    private final SearchBuilder<LoadBalancerVO> AccountAndNameSearch;
     protected final SearchBuilder<LoadBalancerVO> TransitionStateSearch;
 
     @Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao;
@@ -57,45 +42,16 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> im
         ListByIp = createSearchBuilder();
         ListByIp.and("ipAddressId", ListByIp.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
         ListByIp.and("networkId", ListByIp.entity().getNetworkId(), SearchCriteria.Op.EQ);
+        ListByIp.and("scheme", ListByIp.entity().getScheme(), SearchCriteria.Op.EQ);
         ListByIp.done();
 
-        IpAndPublicPortSearch = createSearchBuilder();
-        IpAndPublicPortSearch.and("ipAddressId", IpAndPublicPortSearch.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
-        IpAndPublicPortSearch.and("publicPort", IpAndPublicPortSearch.entity().getSourcePortStart(), SearchCriteria.Op.EQ);
-        IpAndPublicPortSearch.done();
-
-        AccountAndNameSearch = createSearchBuilder();
-        AccountAndNameSearch.and("accountId", AccountAndNameSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
-        AccountAndNameSearch.and("name", AccountAndNameSearch.entity().getName(), SearchCriteria.Op.EQ);
-        AccountAndNameSearch.done();
-
         TransitionStateSearch = createSearchBuilder();
         TransitionStateSearch.and("networkId", TransitionStateSearch.entity().getNetworkId(), Op.EQ);
         TransitionStateSearch.and("state", TransitionStateSearch.entity().getState(), Op.IN);
+        TransitionStateSearch.and("scheme", TransitionStateSearch.entity().getScheme(), Op.EQ);
         TransitionStateSearch.done();
     }
-
-    @Override
-    public List<Long> listInstancesByLoadBalancer(long loadBalancerId) {
-        Transaction txn = Transaction.currentTxn();
-        String sql = LIST_INSTANCES_BY_LOAD_BALANCER;
-        PreparedStatement pstmt = null;
-        List<Long> instanceList = new ArrayList<Long>();
-        try {
-            pstmt = txn.prepareAutoCloseStatement(sql);
-            pstmt.setLong(1, loadBalancerId);
-
-            ResultSet rs = pstmt.executeQuery();
-            while (rs.next()) {
-                Long vmId = rs.getLong(1);
-                instanceList.add(vmId);
-            }
-        } catch (Exception ex) {
-            s_logger.error("error getting recent usage network stats", ex);
-        }
-        return instanceList;
-    }
-
+    
     @Override
     public List<LoadBalancerVO> listByIpAddress(long ipAddressId) {
         SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
@@ -104,33 +60,19 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> im
     }
 
     @Override
-    public List<LoadBalancerVO> listByNetworkId(long networkId) {
+    public List<LoadBalancerVO> listByNetworkIdAndScheme(long networkId, Scheme scheme) {
         SearchCriteria<LoadBalancerVO> sc = ListByIp.create();
         sc.setParameters("networkId", networkId);
+        sc.setParameters("scheme", scheme);
         return listBy(sc);
     }
 
     @Override
-    public LoadBalancerVO findByIpAddressAndPublicPort(long ipAddressId, String publicPort) {
-        SearchCriteria<LoadBalancerVO> sc = IpAndPublicPortSearch.create();
-        sc.setParameters("ipAddressId", ipAddressId);
-        sc.setParameters("publicPort", publicPort);
-        return findOneBy(sc);
-    }
-
-    @Override
-    public LoadBalancerVO findByAccountAndName(Long accountId, String name) {
-        SearchCriteria<LoadBalancerVO> sc = AccountAndNameSearch.create();
-        sc.setParameters("accountId", accountId);
-        sc.setParameters("name", name);
-        return findOneBy(sc);
-    }
-
-    @Override
-    public List<LoadBalancerVO> listInTransitionStateByNetworkId(long networkId) {
+    public List<LoadBalancerVO> listInTransitionStateByNetworkIdAndScheme(long networkId, Scheme scheme) {
         SearchCriteria<LoadBalancerVO> sc = TransitionStateSearch.create();
         sc.setParameters("networkId", networkId);
         sc.setParameters("state", State.Add.toString(), State.Revoke.toString());
+        sc.setParameters("scheme", scheme);
         return listBy(sc);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java b/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
index 5422f41..fee88cf 100644
--- a/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
+++ b/engine/schema/src/com/cloud/network/dao/LoadBalancerVO.java
@@ -19,6 +19,8 @@ package com.cloud.network.dao;
 import javax.persistence.Column;
 import javax.persistence.DiscriminatorValue;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.PrimaryKeyJoinColumn;
 import javax.persistence.Table;
 
@@ -26,6 +28,12 @@ import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.LoadBalancer;
 import com.cloud.utils.net.NetUtils;
 
+/**
+ * This VO represent Public Load Balancer
+ * It references source ip address by its Id. 
+ * To get the VO for Internal Load Balancer rule, please refer to LoadBalancerRuleVO
+ *
+ */
 @Entity
 @Table(name=("load_balancing_rules"))
 @DiscriminatorValue(value="LoadBalancing")
@@ -46,6 +54,10 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
     
     @Column(name="default_port_end")
     private int defaultPortEnd;
+    
+    @Enumerated(value=EnumType.STRING)
+    @Column(name="scheme")
+    Scheme scheme = Scheme.Public;
 
     public LoadBalancerVO() { 
     }
@@ -57,6 +69,7 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
         this.algorithm = algorithm;
         this.defaultPortStart = dstPort;
         this.defaultPortEnd = dstPort;
+        this.scheme = Scheme.Public;
     }
     
     @Override
@@ -94,5 +107,10 @@ public class LoadBalancerVO extends FirewallRuleVO implements LoadBalancer {
 
     public void setDescription(String description) {
         this.description = description;
+    }
+
+    @Override
+    public Scheme getScheme() {
+        return scheme;
     }  
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java
index 79b97be..6d401c4 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDao.java
@@ -35,4 +35,5 @@ public interface NetworkServiceMapDao extends GenericDao<NetworkServiceMapVO, Lo
 	void deleteByNetworkId(long networkId);
 	List<String> getDistinctProviders(long networkId);
 	String isProviderForNetwork(long networkId, Provider provider);
+	List<String> getProvidersForServiceInNetwork(long networkId, Service service);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
index 13fbfbc..3cdd738 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkServiceMapDaoImpl.java
@@ -56,6 +56,7 @@ public class NetworkServiceMapDaoImpl extends GenericDaoBase<NetworkServiceMapVO
         DistinctProvidersSearch = createSearchBuilder(String.class);
         DistinctProvidersSearch.and("networkId", DistinctProvidersSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
         DistinctProvidersSearch.and("provider", DistinctProvidersSearch.entity().getProvider(), SearchCriteria.Op.EQ);
+        DistinctProvidersSearch.and("service", DistinctProvidersSearch.entity().getService(), SearchCriteria.Op.EQ);
         DistinctProvidersSearch.selectField(DistinctProvidersSearch.entity().getProvider());
         DistinctProvidersSearch.done();
     }
@@ -163,5 +164,13 @@ public class NetworkServiceMapDaoImpl extends GenericDaoBase<NetworkServiceMapVO
         	return results.get(0);
         }
     }
+
+    @Override
+    public List<String> getProvidersForServiceInNetwork(long networkId, Service service) {
+        SearchCriteria<String> sc = DistinctProvidersSearch.create();
+        sc.setParameters("networkId", networkId);
+        sc.setParameters("service", service.getName());
+        return customSearch(sc, null);
+    }
     
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/dao/NetworkVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/dao/NetworkVO.java b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
index 77b40c8..8e728ab 100644
--- a/engine/schema/src/com/cloud/network/dao/NetworkVO.java
+++ b/engine/schema/src/com/cloud/network/dao/NetworkVO.java
@@ -32,9 +32,6 @@ import javax.persistence.Transient;
 import org.apache.cloudstack.acl.ControlledEntity;
 
 import com.cloud.network.Network;
-import com.cloud.network.Networks;
-import com.cloud.network.Network.GuestType;
-import com.cloud.network.Network.State;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
index a761520..9f73029 100644
--- a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
+++ b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java
@@ -20,7 +20,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.UUID;
 
-import javax.inject.Inject;
 import javax.persistence.Column;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.DiscriminatorType;
@@ -35,7 +34,6 @@ import javax.persistence.InheritanceType;
 import javax.persistence.Table;
 import javax.persistence.Transient;
 
-import com.cloud.network.dao.FirewallRulesCidrsDao;
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.net.NetUtils;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/offerings/NetworkOfferingDetailsVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/NetworkOfferingDetailsVO.java b/engine/schema/src/com/cloud/offerings/NetworkOfferingDetailsVO.java
new file mode 100644
index 0000000..6cd5abc
--- /dev/null
+++ b/engine/schema/src/com/cloud/offerings/NetworkOfferingDetailsVO.java
@@ -0,0 +1,90 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.offerings;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Detail;
+
+@Entity
+@Table(name="network_offering_details")
+public class NetworkOfferingDetailsVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+    
+    @Column(name="network_offering_id")
+    private long offeringId;
+    
+    @Enumerated(value=EnumType.STRING)
+    @Column(name="name")
+    private NetworkOffering.Detail name;
+    
+    @Column(name="value", length=1024)
+    private String value;
+    
+    public NetworkOfferingDetailsVO() {}
+    
+    public NetworkOfferingDetailsVO(long offeringId, Detail detailName, String value) {
+        this.offeringId = offeringId;
+        this.name = detailName;
+        this.value = value;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public long getOfferingId() {
+        return offeringId;
+    }
+
+    public NetworkOffering.Detail getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public void setOfferingId(long offeringId) {
+        this.offeringId = offeringId;
+    }
+
+    public void setName(NetworkOffering.Detail name) {
+        this.name = name;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java
index c015989..3ae0bf3 100755
--- a/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java
+++ b/engine/schema/src/com/cloud/offerings/NetworkOfferingVO.java
@@ -16,15 +16,23 @@
 // under the License.
 package com.cloud.offerings;
 
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
 import com.cloud.network.Network;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.utils.db.GenericDao;
 
-import javax.persistence.*;
-import java.util.Date;
-import java.util.UUID;
-
 @Entity
 @Table(name = "network_offerings")
 public class NetworkOfferingVO implements NetworkOffering {
@@ -126,6 +134,12 @@ public class NetworkOfferingVO implements NetworkOffering {
     public String getDisplayText() {
         return displayText;
     }
+    
+    @Column(name = "internal_lb")
+    boolean internalLb;
+    
+    @Column(name = "public_lb")
+    boolean publicLb;
 
     @Override
     public long getId() {
@@ -262,7 +276,7 @@ public class NetworkOfferingVO implements NetworkOffering {
     }
 
     public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault,
-            Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean specifyIpRanges, boolean isPersistent) {
+            Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean specifyIpRanges, boolean isPersistent, boolean internalLb, boolean publicLb) {
         this.name = name;
         this.displayText = displayText;
         this.rateMbps = rateMbps;
@@ -286,12 +300,14 @@ public class NetworkOfferingVO implements NetworkOffering {
         this.inline = false;
         this.specifyIpRanges = specifyIpRanges;
         this.isPersistent=isPersistent;
+        this.publicLb = publicLb;
+        this.internalLb = internalLb;
     }
 
     public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault,
             Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter, boolean elasticIp, boolean elasticLb,
-            boolean specifyIpRanges, boolean inline, boolean isPersistent, boolean associatePublicIP) {
-        this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges, isPersistent);
+            boolean specifyIpRanges, boolean inline, boolean isPersistent, boolean associatePublicIP, boolean publicLb, boolean internalLb) {
+        this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges, isPersistent, internalLb, publicLb);
         this.dedicatedLB = dedicatedLb;
         this.sharedSourceNat = sharedSourceNat;
         this.redundantRouter = redundantRouter;
@@ -313,13 +329,13 @@ public class NetworkOfferingVO implements NetworkOffering {
      *            TODO
      */
     public NetworkOfferingVO(String name, TrafficType trafficType, boolean specifyIpRanges) {
-        this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges, false);
+        this(name, "System Offering for " + name, trafficType, true, false, 0, 0, true, Availability.Required, null, null, true, specifyIpRanges, false, false, false);
         this.state = State.Enabled;
     }
 
     public NetworkOfferingVO(String name, Network.GuestType guestType) {
         this(name, "System Offering for " + name, TrafficType.Guest, true, true, 0, 0, true, Availability.Optional,
-                null, Network.GuestType.Isolated, true, false, false);
+                null, Network.GuestType.Isolated, true, false, false, false, false);
         this.state = State.Enabled;
     }
 
@@ -388,4 +404,14 @@ public class NetworkOfferingVO implements NetworkOffering {
         return isPersistent;
     }
 
+    @Override
+    public boolean getInternalLb() {
+        return internalLb;
+    }
+
+    @Override
+    public boolean getPublicLb() {
+        return publicLb;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java
index 405d348..5bb79ce 100644
--- a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDao.java
@@ -17,11 +17,13 @@
 package com.cloud.offerings.dao;
 
 import java.util.List;
+import java.util.Map;
 
 import com.cloud.network.Network;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.NetworkOffering.Availability;
+import com.cloud.offering.NetworkOffering.Detail;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.utils.db.GenericDao;
 
@@ -57,4 +59,6 @@ public interface NetworkOfferingDao extends GenericDao<NetworkOfferingVO, Long>
 
     List<NetworkOfferingVO> listByTrafficTypeGuestTypeAndState(NetworkOffering.State state, TrafficType trafficType, Network.GuestType type);
 
+    NetworkOfferingVO persist(NetworkOfferingVO off, Map<Detail, String> details);
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
index d1e4424..ef8237a 100644
--- a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDaoImpl.java
@@ -17,8 +17,10 @@
 package com.cloud.offerings.dao;
 
 import java.util.List;
+import java.util.Map;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 import javax.persistence.EntityExistsException;
 
 import org.springframework.stereotype.Component;
@@ -27,6 +29,8 @@ import com.cloud.network.Network;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.NetworkOffering.Availability;
+import com.cloud.offering.NetworkOffering.Detail;
+import com.cloud.offerings.NetworkOfferingDetailsVO;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
@@ -45,6 +49,7 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
     final SearchBuilder<NetworkOfferingVO> AvailabilitySearch;
     final SearchBuilder<NetworkOfferingVO> AllFieldsSearch;
     private final GenericSearchBuilder<NetworkOfferingVO, Long> UpgradeSearch;
+    @Inject NetworkOfferingDetailsDao _detailsDao;
 
     protected NetworkOfferingDaoImpl() {
         super();
@@ -165,5 +170,24 @@ public class NetworkOfferingDaoImpl extends GenericDaoBase<NetworkOfferingVO, Lo
         sc.setParameters("state", state);
         return listBy(sc, null);
     }
+    
+    @Override
+    @DB
+    public NetworkOfferingVO persist(NetworkOfferingVO off, Map<Detail, String> details) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        //1) persist the offering
+        NetworkOfferingVO vo = super.persist(off);
+        
+        //2) persist the details
+        if (details != null && !details.isEmpty()) {
+            for (NetworkOffering.Detail detail : details.keySet()) {
+                _detailsDao.persist(new NetworkOfferingDetailsVO(off.getId(), detail, details.get(detail)));
+            }
+        }
+       
+        txn.commit();
+        return vo;
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDao.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDao.java
new file mode 100644
index 0000000..ce209e0
--- /dev/null
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDao.java
@@ -0,0 +1,31 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.offerings.dao;
+
+
+import java.util.Map;
+
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Detail;
+import com.cloud.offerings.NetworkOfferingDetailsVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface NetworkOfferingDetailsDao extends GenericDao<NetworkOfferingDetailsVO, Long>{
+
+    Map<NetworkOffering.Detail,String> getNtwkOffDetails(long offeringId);
+    String getDetail(long offeringId, Detail detailName);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDaoImpl.java b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDaoImpl.java
new file mode 100644
index 0000000..068f390
--- /dev/null
+++ b/engine/schema/src/com/cloud/offerings/dao/NetworkOfferingDetailsDaoImpl.java
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.offerings.dao;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.cloud.offering.NetworkOffering;
+import com.cloud.offering.NetworkOffering.Detail;
+import com.cloud.offerings.NetworkOfferingDetailsVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+public class NetworkOfferingDetailsDaoImpl extends GenericDaoBase<NetworkOfferingDetailsVO, Long> implements NetworkOfferingDetailsDao{
+    protected final SearchBuilder<NetworkOfferingDetailsVO> DetailSearch;
+    private final GenericSearchBuilder<NetworkOfferingDetailsVO, String> ValueSearch;
+
+    
+    public NetworkOfferingDetailsDaoImpl() {
+        
+        DetailSearch = createSearchBuilder();
+        DetailSearch.and("offeringId", DetailSearch.entity().getOfferingId(), SearchCriteria.Op.EQ);
+        DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
+        DetailSearch.done();
+        
+        ValueSearch = createSearchBuilder(String.class);
+        ValueSearch.select(null, Func.DISTINCT, ValueSearch.entity().getValue());
+        ValueSearch.and("offeringId", ValueSearch.entity().getOfferingId(), SearchCriteria.Op.EQ);
+        ValueSearch.and("name", ValueSearch.entity().getName(), Op.EQ);
+        ValueSearch.done();
+    }
+    
+    @Override
+    public Map<NetworkOffering.Detail,String> getNtwkOffDetails(long offeringId) {
+        SearchCriteria<NetworkOfferingDetailsVO> sc = DetailSearch.create();
+        sc.setParameters("offeringId", offeringId);
+        
+        List<NetworkOfferingDetailsVO> results = search(sc, null);
+        Map<NetworkOffering.Detail, String> details = new HashMap<NetworkOffering.Detail, String>(results.size());
+        for (NetworkOfferingDetailsVO result : results) {
+            details.put(result.getName(), result.getValue());
+        }
+        
+        return details;
+    }
+
+    @Override
+    public String getDetail(long offeringId, Detail detailName) {
+        SearchCriteria<String> sc = ValueSearch.create();
+        sc.setParameters("name", detailName);
+        sc.setParameters("offeringId", offeringId);
+        List<String> results = customSearch(sc, null);
+        if (results.isEmpty()) {
+            return null;
+        } else {
+            return results.get(0);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 05e2b49..3a164c4 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -17,10 +17,6 @@
 
 package com.cloud.upgrade.dao;
 
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.script.Script;
-import org.apache.log4j.Logger;
-
 import java.io.File;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
@@ -28,6 +24,11 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.UUID;
 
+import org.apache.log4j.Logger;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.script.Script;
+
 public class Upgrade410to420 implements DbUpgrade {
 	final static Logger s_logger = Logger.getLogger(Upgrade410to420.class);
 
@@ -66,6 +67,8 @@ public class Upgrade410to420 implements DbUpgrade {
         updatePrimaryStore(conn);
         addEgressFwRulesForSRXGuestNw(conn);
         upgradeEIPNetworkOfferings(conn);
+        upgradeDefaultVpcOffering(conn);
+        upgradePhysicalNtwksWithInternalLbProvider(conn);
     }
 	
 	private void updateSystemVmTemplates(Connection conn) {
@@ -399,4 +402,88 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         }
     }
+    
+    
+    private void upgradeDefaultVpcOffering(Connection conn) {
+
+        PreparedStatement pstmt = null;
+        ResultSet rs = null;
+
+        try {
+            pstmt = conn.prepareStatement("select distinct map.vpc_offering_id from `cloud`.`vpc_offering_service_map` map, `cloud`.`vpc_offerings` off where off.id=map.vpc_offering_id AND service='Lb'");
+            rs = pstmt.executeQuery();
+            while (rs.next()) {
+                long id = rs.getLong(1);
+                //Add internal LB vm as a supported provider for the load balancer service
+                pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vpc_offering_service_map` (vpc_offering_id, service, provider) VALUES (?,?,?)");
+                pstmt.setLong(1, id);
+                pstmt.setString(2, "Lb");
+                pstmt.setString(3, "InternalLbVm");
+                pstmt.executeUpdate();
+            }
+            
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Unable update the default VPC offering with the internal lb service", e);
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+                if (pstmt != null) {
+                    pstmt.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+    }
+    
+    
+    private void upgradePhysicalNtwksWithInternalLbProvider(Connection conn) {
+
+        PreparedStatement pstmt = null;
+        ResultSet rs = null;
+
+        try {
+            pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where removed is null");
+            rs = pstmt.executeQuery();
+            while (rs.next()) {
+                long pNtwkId = rs.getLong(1);
+                String uuid = UUID.randomUUID().toString();
+                //Add internal LB VM to the list of physical network service providers
+                pstmt = conn.prepareStatement("INSERT INTO `cloud`.`physical_network_service_providers` " +
+                		"(uuid, physical_network_id, provider_name, state, load_balance_service_provided, destination_physical_network_id)" +
+                		" VALUES (?, ?, 'InternalLbVm', 'Enabled', 1, 0)");
+                pstmt.setString(1, uuid);
+                pstmt.setLong(2, pNtwkId);
+                pstmt.executeUpdate();
+                
+                //Add internal lb vm to the list of physical network elements
+                PreparedStatement pstmt1 = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network_service_providers`" +
+                		" WHERE physical_network_id=? AND provider_name='InternalLbVm'");
+                ResultSet rs1 = pstmt1.executeQuery();
+                while (rs1.next()) {
+                    long providerId = rs1.getLong(1);
+                    uuid = UUID.randomUUID().toString();
+                    pstmt1 = conn.prepareStatement("INSERT INTO `cloud`.`virtual_router_providers` (nsp_id, uuid, type, enabled) VALUES (?, ?, 'InternalLbVm', 1)");
+                    pstmt1.setLong(1, providerId);
+                    pstmt1.setString(2, uuid);
+                    pstmt1.executeUpdate();
+                }
+            }
+            
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Unable existing physical networks with internal lb provider", e);
+        } finally {
+            try {
+                if (rs != null) {
+                    rs.close();
+                }
+                if (pstmt != null) {
+                    pstmt.close();
+                }
+            } catch (SQLException e) {
+            }
+        }
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/vm/dao/NicDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicDao.java b/engine/schema/src/com/cloud/vm/dao/NicDao.java
index 67c1e07..12efe08 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicDao.java
@@ -30,7 +30,7 @@ public interface NicDao extends GenericDao<NicVO, Long> {
     
     List<NicVO> listByNetworkId(long networkId);
     
-    NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId);
+    NicVO findByNtwkIdAndInstanceId(long networkId, long instanceId);
     
     NicVO findByInstanceIdAndNetworkIdIncludingRemoved(long networkId, long instanceId);
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
index c70d194..fa30168 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java
@@ -113,7 +113,7 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao {
     }
     
     @Override
-    public NicVO findByInstanceIdAndNetworkId(long networkId, long instanceId) {
+    public NicVO findByNtwkIdAndInstanceId(long networkId, long instanceId) {
         SearchCriteria<NicVO> sc = AllFieldsSearch.create();
         sc.setParameters("network", networkId);
         sc.setParameters("instance", instanceId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/org/apache/cloudstack/lb/ApplicationLoadBalancerRuleVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/lb/ApplicationLoadBalancerRuleVO.java b/engine/schema/src/org/apache/cloudstack/lb/ApplicationLoadBalancerRuleVO.java
new file mode 100644
index 0000000..37a747e
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/lb/ApplicationLoadBalancerRuleVO.java
@@ -0,0 +1,133 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.lb;
+
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.PrimaryKeyJoinColumn;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule;
+
+import com.cloud.network.rules.FirewallRuleVO;
+import com.cloud.utils.net.Ip;
+import com.cloud.utils.net.NetUtils;
+
+/**
+ * This VO represent Internal Load Balancer rule.
+ * Instead of pointing to the public ip address id directly as External Load Balancer rule does, it refers to the ip address by its value/sourceNetworkid
+ *
+ */
+@Entity
+@Table(name=("load_balancing_rules"))
+@DiscriminatorValue(value="LoadBalancing")
+@PrimaryKeyJoinColumn(name="id")
+public class ApplicationLoadBalancerRuleVO extends FirewallRuleVO implements ApplicationLoadBalancerRule{
+    @Column(name="name")
+    private String name;
+
+    @Column(name="description", length=4096)
+    private String description;
+
+    @Column(name="algorithm")
+    private String algorithm;
+
+    @Column(name="default_port_start")
+    private int defaultPortStart;
+    
+    @Column(name="default_port_end")
+    private int defaultPortEnd;
+    
+    @Column(name="source_ip_address_network_id")
+    Long sourceIpNetworkId;
+    
+    @Column(name="source_ip_address")
+    @Enumerated(value=EnumType.STRING)
+    private Ip sourceIp = null;
+    
+    @Enumerated(value=EnumType.STRING)
+    @Column(name="scheme")
+    Scheme scheme;
+
+
+    public ApplicationLoadBalancerRuleVO() {  
+    }
+    
+    public ApplicationLoadBalancerRuleVO(String name, String description, int srcPort, int instancePort, String algorithm,
+            long networkId, long accountId, long domainId, Ip sourceIp, long sourceIpNtwkId, Scheme scheme) {
+        super(null, null, srcPort, srcPort, NetUtils.TCP_PROTO, networkId, accountId, domainId, Purpose.LoadBalancing, null, null,null, null, null);
+        
+        this.name = name;
+        this.description = description;
+        this.algorithm = algorithm;
+        this.defaultPortStart = instancePort;
+        this.defaultPortEnd = instancePort;
+        this.sourceIp = sourceIp;
+        this.sourceIpNetworkId = sourceIpNtwkId;
+        this.scheme = scheme;
+    }
+    
+    
+    @Override
+    public Long getSourceIpNetworkId() {
+        return sourceIpNetworkId;
+    }
+
+    @Override
+    public Ip getSourceIp() {
+        return sourceIp;
+    }
+    
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public String getAlgorithm() {
+        return algorithm;
+    }
+
+    @Override
+    public int getDefaultPortStart() {
+        return defaultPortStart;
+    }
+
+    @Override
+    public int getDefaultPortEnd() {
+        return defaultPortEnd;
+    }
+
+    @Override
+    public Scheme getScheme() {
+        return scheme;
+    }
+
+    @Override
+    public int getInstancePort() {
+        return defaultPortStart;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDao.java b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDao.java
new file mode 100644
index 0000000..c385e62
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDao.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+// 
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.lb.dao;
+
+import java.util.List;
+
+import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
+
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.net.Ip;
+
+public interface ApplicationLoadBalancerRuleDao extends GenericDao<ApplicationLoadBalancerRuleVO, Long>{
+    List<ApplicationLoadBalancerRuleVO> listBySrcIpSrcNtwkId(Ip sourceIp, long sourceNetworkId);
+    List<String> listLbIpsBySourceIpNetworkId(long sourceIpNetworkId);
+    long countBySourceIp(Ip sourceIp, long sourceIpNetworkId);
+    List<ApplicationLoadBalancerRuleVO> listBySourceIpAndNotRevoked(Ip sourceIp, long sourceNetworkId);
+    List<String> listLbIpsBySourceIpNetworkIdAndScheme(long sourceIpNetworkId, Scheme scheme);
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDaoImpl.java b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDaoImpl.java
new file mode 100644
index 0000000..880c67e
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/lb/dao/ApplicationLoadBalancerRuleDaoImpl.java
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.cloudstack.lb.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
+import org.springframework.stereotype.Component;
+
+import com.cloud.network.rules.FirewallRule;
+import com.cloud.network.rules.LoadBalancerContainer.Scheme;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.net.Ip;
+
+@Component
+@Local(value = { ApplicationLoadBalancerRuleDao.class })
+public class ApplicationLoadBalancerRuleDaoImpl extends GenericDaoBase<ApplicationLoadBalancerRuleVO, Long> implements ApplicationLoadBalancerRuleDao{
+    protected final SearchBuilder<ApplicationLoadBalancerRuleVO> AllFieldsSearch;
+    final GenericSearchBuilder<ApplicationLoadBalancerRuleVO, String> listIps;
+    final GenericSearchBuilder<ApplicationLoadBalancerRuleVO, Long> CountBy;
+    protected final SearchBuilder<ApplicationLoadBalancerRuleVO> NotRevokedSearch;
+
+
+    
+    protected ApplicationLoadBalancerRuleDaoImpl() {
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("sourceIp", AllFieldsSearch.entity().getSourceIp(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("sourceIpNetworkId", AllFieldsSearch.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("networkId", AllFieldsSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.and("scheme", AllFieldsSearch.entity().getScheme(), SearchCriteria.Op.EQ);
+        AllFieldsSearch.done();
+        
+        listIps = createSearchBuilder(String.class);
+        listIps.select(null, Func.DISTINCT, listIps.entity().getSourceIp());
+        listIps.and("sourceIpNetworkId", listIps.entity().getSourceIpNetworkId(), Op.EQ);
+        listIps.and("scheme", listIps.entity().getScheme(), Op.EQ);
+        listIps.done();
+        
+        CountBy = createSearchBuilder(Long.class);
+        CountBy.select(null, Func.COUNT, CountBy.entity().getId());
+        CountBy.and("sourceIp", CountBy.entity().getSourceIp(), Op.EQ);
+        CountBy.and("sourceIpNetworkId", CountBy.entity().getSourceIpNetworkId(), Op.EQ);
+        CountBy.done();
+        
+        NotRevokedSearch = createSearchBuilder();
+        NotRevokedSearch.and("sourceIp", NotRevokedSearch.entity().getSourceIp(), SearchCriteria.Op.EQ);
+        NotRevokedSearch.and("sourceIpNetworkId", NotRevokedSearch.entity().getSourceIpNetworkId(), SearchCriteria.Op.EQ);
+        NotRevokedSearch.and("state", NotRevokedSearch.entity().getState(), SearchCriteria.Op.NEQ);
+        NotRevokedSearch.done();
+    }
+
+    @Override
+    public List<ApplicationLoadBalancerRuleVO> listBySrcIpSrcNtwkId(Ip sourceIp, long sourceNetworkId) {
+        SearchCriteria<ApplicationLoadBalancerRuleVO> sc = AllFieldsSearch.create();
+        sc.setParameters("sourceIp", sourceIp);
+        sc.setParameters("sourceIpNetworkId", sourceNetworkId);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<String> listLbIpsBySourceIpNetworkId(long sourceIpNetworkId) {
+        SearchCriteria<String> sc = listIps.create();
+        sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
+        return customSearch(sc, null);
+    }
+
+    @Override
+    public long countBySourceIp(Ip sourceIp, long sourceIpNetworkId) {
+        SearchCriteria<Long> sc = CountBy.create();
+        sc.setParameters("sourceIp", sourceIp);
+        sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
+        List<Long> results = customSearch(sc, null);
+        return results.get(0);
+    }
+
+    @Override
+    public List<ApplicationLoadBalancerRuleVO> listBySourceIpAndNotRevoked(Ip sourceIp, long sourceNetworkId) {
+        SearchCriteria<ApplicationLoadBalancerRuleVO> sc = NotRevokedSearch.create();
+        sc.setParameters("sourceIp", sourceIp);
+        sc.setParameters("sourceIpNetworkId", sourceNetworkId);
+        sc.setParameters("state", FirewallRule.State.Revoke);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<String> listLbIpsBySourceIpNetworkIdAndScheme(long sourceIpNetworkId, Scheme scheme) {
+        SearchCriteria<String> sc = listIps.create();
+        sc.setParameters("sourceIpNetworkId", sourceIpNetworkId);
+        sc.setParameters("scheme", scheme);
+        return customSearch(sc, null);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/patches/systemvm/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
index ed3894f..a457f22 100755
--- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config
+++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config
@@ -901,6 +901,28 @@ setup_elbvm() {
   chkconfig portmap off
 }
 
+setup_ilbvm() {
+  log_it "Setting up Internal Load Balancer system vm"
+  local hyp=$1
+  setup_common eth0 eth1
+  #eth0 = guest network, eth1=control network
+
+  sed -i  /$NAME/d /etc/hosts
+  echo "$ETH0_IP $NAME" >> /etc/hosts
+
+  cp /etc/iptables/iptables-ilbvm /etc/iptables/rules.v4
+  cp /etc/iptables/iptables-ilbvm /etc/iptables/rules
+  setup_sshd $ETH1_IP "eth1"
+  
+  enable_fwding 0
+  enable_svc haproxy 1
+  enable_svc dnsmasq 0
+  enable_svc cloud-passwd-srvr 0
+  enable_svc cloud 0
+  chkconfig nfs-common off
+  chkconfig portmap off
+}
+
 setup_default() {
   cat > /etc/network/interfaces << EOF
 auto lo
@@ -951,6 +973,10 @@ start() {
          [ "$NAME" == "" ] && NAME=elb
          setup_elbvm
 	  ;;
+     ilbvm)
+         [ "$NAME" == "" ] && NAME=ilb
+         setup_ilbvm
+	  ;;
      unknown)
          [ "$NAME" == "" ] && NAME=systemvm
          setup_default;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/patches/systemvm/debian/config/etc/iptables/iptables-ilbvm
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/etc/iptables/iptables-ilbvm b/patches/systemvm/debian/config/etc/iptables/iptables-ilbvm
new file mode 100755
index 0000000..8d5ca65
--- /dev/null
+++ b/patches/systemvm/debian/config/etc/iptables/iptables-ilbvm
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+*nat
+:PREROUTING ACCEPT [0:0]
+:POSTROUTING ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+COMMIT
+*filter
+:INPUT DROP [0:0]
+:FORWARD DROP [0:0]
+:OUTPUT ACCEPT [0:0]
+-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
+-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
+-A INPUT -p icmp -j ACCEPT
+-A INPUT -i lo -j ACCEPT
+-A INPUT -i eth1 -p tcp -m state --state NEW --dport 3922 -j ACCEPT
+COMMIT
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/patches/systemvm/debian/config/opt/cloud/bin/ilb.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/ilb.sh b/patches/systemvm/debian/config/opt/cloud/bin/ilb.sh
new file mode 100755
index 0000000..2a29892
--- /dev/null
+++ b/patches/systemvm/debian/config/opt/cloud/bin/ilb.sh
@@ -0,0 +1,211 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+source /root/func.sh
+
+lock="biglock"
+locked=$(getLockFile $lock)
+if [ "$locked" != "1" ]
+then
+    exit 1
+fi
+
+usage() {
+  printf "Usage: %s:  -a <added public ip address ip:port> -d <removed ip:port> -f <load balancer config> -s <stats ip ip:port:cidr>  \n" $(basename $0) >&2
+}
+
+#set -x
+
+fw_remove_backup() {
+  logger -t cloud "$(basename $0): Entering fw_remove_backup"
+  local lb_vif_list=eth0
+  for vif in $lb_vif_list; do 
+    sudo iptables -F back_load_balancer_$vif 2> /dev/null
+    sudo iptables -D INPUT -i $vif -p tcp  -j back_load_balancer_$vif 2> /dev/null
+    sudo iptables -X back_load_balancer_$vif 2> /dev/null
+  done
+  sudo iptables -F back_lb_stats 2> /dev/null
+  sudo iptables -D INPUT -p tcp  -j back_lb_stats 2> /dev/null
+  sudo iptables -X back_lb_stats 2> /dev/null
+}
+
+fw_restore() {
+  logger -t cloud "$(basename $0): Entering fw_restore"
+  local lb_vif_list="eth0"
+  for vif in $lb_vif_list; do 
+    sudo iptables -F load_balancer_$vif 2> /dev/null
+    sudo iptables -D INPUT -i $vif -p tcp  -j load_balancer_$vif 2> /dev/null
+    sudo iptables -X load_balancer_$vif 2> /dev/null
+    sudo iptables -E back_load_balancer_$vif load_balancer_$vif 2> /dev/null
+  done
+  sudo iptables -F lb_stats 2> /dev/null
+  sudo iptables -D INPUT -p tcp  -j lb_stats 2> /dev/null
+  sudo iptables -X lb_stats 2> /dev/null
+  sudo iptables -E back_lb_stats lb_stats 2> /dev/null
+}
+
+# firewall entry to ensure that haproxy can receive on specified port
+fw_entry() {
+  logger -t cloud "$(basename $0): Entering fw_entry"
+  local added=$1
+  local removed=$2
+  local stats=$3
+  
+  if [ "$added" == "none" ]
+  then
+  	added=""
+  fi
+  
+  if [ "$removed" == "none" ]
+  then
+  	removed=""
+  fi
+  
+  local a=$(echo $added | cut -d, -f1- --output-delimiter=" ")
+  local r=$(echo $removed | cut -d, -f1- --output-delimiter=" ")
+
+# back up the iptable rules by renaming before creating new. 
+  local lb_vif_list=eth0
+  for vif in $lb_vif_list; do 
+    sudo iptables -E load_balancer_$vif back_load_balancer_$vif 2> /dev/null
+    sudo iptables -N load_balancer_$vif 2> /dev/null
+    sudo iptables -A INPUT -i $vif -p tcp  -j load_balancer_$vif
+  done
+  sudo iptables -E lb_stats back_lb_stats 2> /dev/null
+  sudo iptables -N lb_stats 2> /dev/null
+  sudo iptables -A INPUT  -p tcp  -j lb_stats
+
+  for i in $a
+  do
+    local pubIp=$(echo $i | cut -d: -f1)
+    local dport=$(echo $i | cut -d: -f2)    
+    local lb_vif_list="eth0"
+    for vif in $lb_vif_list; do 
+      sudo iptables -A load_balancer_$vif  -p tcp -d $pubIp --dport $dport -j ACCEPT
+      if [ $? -gt 0 ]
+      then
+        return 1
+      fi
+    done      
+  done
+  local pubIp=$(echo $stats | cut -d: -f1)
+  local dport=$(echo $stats | cut -d: -f2)    
+  local cidrs=$(echo $stats | cut -d: -f3 | sed 's/-/,/')
+  sudo iptables -A lb_stats -s $cidrs -p tcp -m state --state NEW -d $pubIp --dport $dport -j ACCEPT
+ 
+  return 0
+}
+
+#Hot reconfigure HA Proxy in the routing domain
+reconfig_lb() {
+  /root/reconfigLB.sh
+  return $?
+}
+
+# Restore the HA Proxy to its previous state, and revert iptables rules on loadbalancer
+restore_lb() {
+  logger -t cloud "Restoring HA Proxy to previous state"
+  # Copy the old version of haproxy.cfg into the file that reconfigLB.sh uses
+  cp /etc/haproxy/haproxy.cfg.old /etc/haproxy/haproxy.cfg.new
+   
+  if [ $? -eq 0 ]
+  then
+    # Run reconfigLB.sh again
+    /root/reconfigLB.sh
+  fi
+}
+
+
+logger -t cloud "$(basename $0): Entering $(dirname $0)/$(basename $0)"
+
+iflag=
+aflag=
+dflag=
+sflag=
+
+while getopts 'i:a:d:s:' OPTION
+do
+  case $OPTION in
+  i)	iflag=1
+		domRIp="$OPTARG" #unused but passed in
+		;;
+  a)	aflag=1
+		addedIps="$OPTARG"
+		;;
+  d)	dflag=1
+		removedIps="$OPTARG"
+		;;
+
+  s)	sflag=1
+		statsIp="$OPTARG"
+		;;
+  ?)	usage
+                unlock_exit 2 $lock $locked
+		;;
+  esac
+done
+
+if [[ "$aflag$dflag" != "1" && "$aflag$dflag" != "11" ]]
+then
+   usage
+   unlock_exit 2 $lock $locked
+fi
+
+if [ "$addedIps" == "" ]
+then
+  addedIps="none"
+fi
+
+
+if [ "$removedIps" == "" ]
+then
+  removedIps="none"
+fi
+
+
+# hot reconfigure haproxy
+reconfig_lb $cfgfile
+
+if [ $? -gt 0 ]
+then
+  logger -t cloud "Reconfiguring ilb failed"
+  unlock_exit 1 $lock $locked
+fi
+
+logger -t cloud "HAProxy reconfigured successfully, configuring firewall"
+
+# iptables entry to ensure that haproxy receives traffic
+fw_entry $addedIps $removedIps $statsIp
+  	
+if [ $? -gt 0 ]
+then
+  logger -t cloud "Failed to apply firewall rules for internal load balancing, reverting HA Proxy config"
+  # Restore the LB
+  restore_lb
+
+  logger -t cloud "Reverting firewall config"
+  fw_restore
+
+  unlock_exit 1 $lock $locked
+else
+  # Remove backedup iptable rules
+  logger -t cloud "Firewall configured successfully, deleting backup firewall config"
+  fw_remove_backup
+fi
+ 
+unlock_exit 0 $lock $locked

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh b/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh
index 8816ad7..9cb0250 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/patchsystemvm.sh
@@ -135,6 +135,19 @@ elbvm_svcs() {
    echo "cloud dnsmasq cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs
 }
 
+
+ilbvm_svcs() {
+   chkconfig cloud off
+   chkconfig haproxy on ; 
+   chkconfig ssh on
+   chkconfig nfs-common off
+   chkconfig portmap off
+   chkconfig keepalived off
+   chkconfig conntrackd off
+   echo "ssh haproxy" > /var/cache/cloud/enabled_svcs
+   echo "cloud dnsmasq cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs
+}
+
 enable_pcihotplug() {
    sed -i -e "/acpiphp/d" /etc/modules
    sed -i -e "/pci_hotplug/d" /etc/modules
@@ -253,4 +266,14 @@ then
   fi
 fi
 
+if [ "$TYPE" == "ilbvm" ]
+then
+  ilbvm_svcs
+  if [ $? -gt 0 ]
+  then
+    printf "Failed to execute ilbvm svcs\n" >$logfile
+    exit 9
+  fi
+fi
+
 exit $?

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh b/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
index 334c617..36a2347 100755
--- a/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
+++ b/patches/systemvm/debian/config/opt/cloud/bin/vpc_loadbalancer.sh
@@ -18,6 +18,29 @@
 
 # @VERSION@
 
+do_ilb_if_ilb () {
+  local typ=""
+  local pattern="type=(.*)"
+
+  for keyval in $(cat /var/cache/cloud/cmdline)
+  do    
+     if [[ $keyval =~ $pattern ]]; then      
+        typ=${BASH_REMATCH[1]}; 
+     fi 
+  done
+  if [ "$typ" == "ilbvm" ]
+  then
+     logger -t cloud "$(basename $0): Detected that we are running in an internal load balancer vm"
+     $(dirname $0)/ilb.sh "$@"
+     exit $?
+  fi
+
+}
+
+logger -t cloud "$(basename $0): Entering $(dirname $0)/$(basename $0)"
+
+do_ilb_if_ilb "$@"
+
 source /root/func.sh
 source /opt/cloud/bin/vpc_func.sh
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/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/2660a6b7/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
index aea795d..cce2b2c 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManager.java
@@ -19,11 +19,11 @@ package com.cloud.network.lb;
 import java.util.List;
 
 import org.apache.cloudstack.api.command.user.loadbalancer.CreateLoadBalancerRuleCmd;
+
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.NetworkRuleConflictException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
-import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.LoadBalancer;
 import com.cloud.user.Account;
 
@@ -32,7 +32,7 @@ public interface ElasticLoadBalancerManager {
     public static final int DEFAULT_ELB_VM_CPU_MHZ = 256;               // 500 MHz
 
     public boolean applyLoadBalancerRules(Network network, 
-            List<? extends FirewallRule> rules) 
+            List<LoadBalancingRule> rules) 
             throws ResourceUnavailableException;
 
     public LoadBalancer handleCreateLoadBalancerRule(CreateLoadBalancerRuleCmd lb, Account caller, long networkId) throws InsufficientAddressCapacityException, NetworkRuleConflictException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
index 283b517..b21e8f9 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java
@@ -102,7 +102,6 @@ import com.cloud.network.router.VirtualRouter.RedundantState;
 import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
 import com.cloud.network.rules.FirewallRule;
-import com.cloud.network.rules.FirewallRule.Purpose;
 import com.cloud.network.rules.LoadBalancer;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
@@ -118,7 +117,6 @@ import com.cloud.user.UserContext;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
-import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
@@ -126,6 +124,7 @@ import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.net.Ip;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
@@ -297,8 +296,7 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
             String protocol = rule.getProtocol();
             String algorithm = rule.getAlgorithm();
 
-            String elbIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress()
-                    .addr();
+            String elbIp = rule.getSourceIp().addr();
             int srcPort = rule.getSourcePortStart();
             String uuid = rule.getUuid();
             List<LbDestination> destinations = rule.getDestinations();
@@ -331,8 +329,10 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
         return sendCommandsToRouter(elbVm, cmds);
     }
     
-    protected DomainRouterVO findElbVmForLb(FirewallRule lb) {//TODO: use a table to lookup
-        ElasticLbVmMapVO map = _elbVmMapDao.findOneByIp(lb.getSourceIpAddressId());
+    protected DomainRouterVO findElbVmForLb(LoadBalancingRule lb) {//TODO: use a table to lookup
+        Network ntwk = _networkModel.getNetwork(lb.getNetworkId());
+        long sourceIpId = _networkModel.getPublicIpAddress(lb.getSourceIp().addr(), ntwk.getDataCenterId()).getId();
+        ElasticLbVmMapVO map = _elbVmMapDao.findOneByIp(sourceIpId);
         if (map == null) {
             return null;
         }
@@ -342,15 +342,11 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
 
     @Override
     public boolean applyLoadBalancerRules(Network network,
-            List<? extends FirewallRule> rules)
+            List<LoadBalancingRule> rules)
             throws ResourceUnavailableException {
         if (rules == null || rules.isEmpty()) {
             return true;
         }
-        if (rules.get(0).getPurpose() != Purpose.LoadBalancing) {
-            s_logger.warn("ELB: Not handling non-LB firewall rules");
-            return false;
-        }
         
         DomainRouterVO elbVm = findElbVmForLb(rules.get(0));
                                                                           
@@ -363,14 +359,16 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
 
         if (elbVm.getState() == State.Running) {
             //resend all rules for the public ip
-            List<LoadBalancerVO> lbs = _lbDao.listByIpAddress(rules.get(0).getSourceIpAddressId());
+            long sourceIpId = _networkModel.getPublicIpAddress(rules.get(0).getSourceIp().addr(), network.getDataCenterId()).getId();
+            List<LoadBalancerVO> lbs = _lbDao.listByIpAddress(sourceIpId);
             List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
             for (LoadBalancerVO lb : lbs) {
                 List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
                 List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
                 List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
+                Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
                 LoadBalancingRule loadBalancing = new LoadBalancingRule(
-                        lb, dstList, policyList, hcPolicyList);
+                        lb, dstList, policyList, hcPolicyList, sourceIp);
                 lbRules.add(loadBalancing);
             }
             return applyLBRules(elbVm, lbRules, network.getId());
@@ -656,7 +654,10 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
             LoadBalancer result = null;
             try {
                 lb.setSourceIpAddressId(ipId);
-                result = _lbMgr.createLoadBalancer(lb, false);
+                
+                result = _lbMgr.createPublicLoadBalancer(lb.getXid(), lb.getName(), lb.getDescription(), 
+                        lb.getSourcePortStart(), lb.getDefaultPortStart(), ipId.longValue(), lb.getProtocol(),
+                        lb.getAlgorithm(), false, UserContext.current());
             } catch (NetworkRuleConflictException e) {
                 s_logger.warn("Failed to create LB rule, not continuing with ELB deployment");
                 if (newIp) {
@@ -943,7 +944,8 @@ ElasticLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
             List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
             List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
             List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
-            LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList);
+            Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
+            LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList, sourceIp);
             lbRules.add(loadBalancing);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2660a6b7/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 e384e3c..80b42e0 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
@@ -16,9 +16,30 @@
 // under the License.
 package com.cloud.network.element;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+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.response.ExternalLoadBalancerResponse;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
+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;
@@ -27,22 +48,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;
@@ -51,13 +91,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 {
@@ -87,11 +120,25 @@ 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.getGuestType() != Network.GuestType.Shared) || 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));
     }
@@ -100,7 +147,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;
         }
 
@@ -124,7 +171,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;
         }
 
@@ -143,13 +190,16 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
 
     @Override
     public boolean validateLBRule(Network network, LoadBalancingRule rule) {
-        String algo = rule.getAlgorithm();
-        return (algo.equals("roundrobin") || algo.equals("leastconn"));
+        if (canHandle(network, new ArrayList<LoadBalancingRule>(Arrays.asList(rule)))) {
+            String algo = rule.getAlgorithm();
+            return (algo.equals("roundrobin") || algo.equals("leastconn"));
+        }
+        return true;
     }
 
     @Override
     public boolean applyLBRules(Network config, List<LoadBalancingRule> rules) throws ResourceUnavailableException {
-        if (!canHandle(config)) {
+        if (!canHandle(config, rules)) {
             return false;
         }
 
@@ -180,6 +230,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>();


Mime
View raw message