cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [3/5] git commit: updated refs/heads/internallb to d8ea854
Date Wed, 10 Apr 2013 01:00:45 GMT
Internal LB:

1)Added InternalLoadBalancerManager and corresponding Impl
2)Add InternalLbVm as a default CS provider. DB upgrade is covered as well


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

Branch: refs/heads/internallb
Commit: caa6d87c1a5d6f41e3558471a9c16e41a9d02226
Parents: a7b43c3
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Tue Apr 9 12:56:42 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue Apr 9 17:55:59 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/Network.java             |    2 +-
 api/src/com/cloud/vm/VirtualMachine.java           |    3 +-
 client/pom.xml                                     |    5 +
 client/tomcatconf/applicationContext.xml.in        |    6 +-
 client/tomcatconf/componentContext.xml.in          |    1 +
 .../network/lb/ElasticLoadBalancerManager.java     |    2 +-
 .../element/InternalLoadBalancerElement.java       |  203 ---------------
 .../element/InternalLoadBalancerElement.java       |  203 +++++++++++++++
 .../network/lb/InternalLoadBalancerManager.java    |   23 ++
 .../lb/InternalLoadBalancerManagerImpl.java        |  148 +++++++++++
 .../src/com/cloud/network/NetworkServiceImpl.java  |   18 ++
 11 files changed, 406 insertions(+), 208 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/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 9f1e579..5bb218b 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -125,7 +125,7 @@ public interface Network extends ControlledEntity, StateObject<Network.State>,
I
         public static final Provider None = new Provider("None", false);
         // NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking

         public static final Provider NiciraNvp = new Provider("NiciraNvp", false);
-        public static final Provider InternalLoadBalancerVm = new Provider("InternalLoadBalancerVm",
false);
+        public static final Provider InternalLbVm = new Provider("InternalLbVm", false);
 
         private String name;
         private boolean isExternal;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/api/src/com/cloud/vm/VirtualMachine.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/VirtualMachine.java b/api/src/com/cloud/vm/VirtualMachine.java
index 8f807d4..ce9add6 100755
--- a/api/src/com/cloud/vm/VirtualMachine.java
+++ b/api/src/com/cloud/vm/VirtualMachine.java
@@ -186,6 +186,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity,
I
         SecondaryStorageVm,
         ElasticIpVm,
         ElasticLoadBalancerVm,
+        InternalLoadBalancerVm,
 
         /*
          * UserBareMetal is only used for selecting VirtualMachineGuru, there is no
@@ -196,7 +197,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity,
I
         public static boolean isSystemVM(VirtualMachine.Type vmtype) {
             if (DomainRouter.equals(vmtype)
                     || ConsoleProxy.equals(vmtype)
-                    || SecondaryStorageVm.equals(vmtype)) {
+                    || SecondaryStorageVm.equals(vmtype) || InternalLoadBalancerVm.equals(vmtype))
{
                 return true;
             }
             return false;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 9323d0f..70924bc 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -85,6 +85,11 @@
       <artifactId>cloud-plugin-network-midonet</artifactId>
       <version>${project.version}</version>
     </dependency>
+  <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-network-internallb</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-hypervisor-xen</artifactId>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 289d61a..f54c052 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -409,10 +409,12 @@
   <bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
     <property name="name" value="VpcVirtualRouter"/>
   </bean>
-
   <bean id="elasticLoadBalancerElement" class="com.cloud.network.element.ElasticLoadBalancerElement">
     <property name="name" value="ElasticLoadBalancerElement"/>
   </bean>
+  <bean id="InternalLbVm" class="org.apache.cloudstack.network.element.InternalLoadBalancerElement">
+    <property name="name" value="InternalLbVm"/>
+  </bean>
 
   <!-- 
     General allocators
@@ -789,7 +791,7 @@
   <bean id="volumeManagerImpl" class="com.cloud.storage.VolumeManagerImpl" />
   <bean id="ClassicalPrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl"
/>
   <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl"
/>
-
+  <bean id="InternalLoadBalancerManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerManagerImpl"
/>
 
 
 <!--=======================================================================================================-->

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index bea2f78..f96a330 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -240,6 +240,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/caa6d87c/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 fc9548e..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;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/element/InternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/element/InternalLoadBalancerElement.java
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/element/InternalLoadBalancerElement.java
deleted file mode 100644
index f55465d..0000000
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/element/InternalLoadBalancerElement.java
+++ /dev/null
@@ -1,203 +0,0 @@
-// 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.element;
-
-import java.util.ArrayList;
-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.log4j.Logger;
-
-import com.cloud.agent.api.to.LoadBalancerTO;
-import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ResourceUnavailableException;
-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.PhysicalNetworkServiceProvider;
-import com.cloud.network.dao.NetworkServiceMapDao;
-import com.cloud.network.element.IpDeployer;
-import com.cloud.network.element.LoadBalancingServiceProvider;
-import com.cloud.network.element.NetworkElement;
-import com.cloud.network.element.VirtualRouterElement;
-import com.cloud.network.lb.LoadBalancingRule;
-import com.cloud.network.router.VirtualRouter.Role;
-import com.cloud.network.rules.LoadBalancerContainer;
-import com.cloud.offering.NetworkOffering;
-import com.cloud.utils.component.AdapterBase;
-import com.cloud.vm.DomainRouterVO;
-import com.cloud.vm.NicProfile;
-import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.dao.DomainRouterDao;
-
-@Local(value = {NetworkElement.class})
-public class InternalLoadBalancerElement extends AdapterBase implements LoadBalancingServiceProvider{
-    private static final Logger s_logger = Logger.getLogger(InternalLoadBalancerElement.class);
-    protected static final Map<Service, Map<Capability, String>> capabilities
= setCapabilities();
-
-    @Inject NetworkModel _ntwkModel;
-    @Inject NetworkServiceMapDao _ntwkSrvcDao;
-    @Inject DomainRouterDao _routerDao;
-    
-    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;
-                    }
-                }
-            }
-        }
-        
-        if (!_ntwkModel.isProviderSupportServiceInNetwork(config.getId(), Service.Lb, getProvider()))
{
-            s_logger.trace("Element " + getProvider().getName() + " doesn't support service
" + Service.Lb
-                    + " in the network " + config);
-            return false;
-        }
-        return true;
-    }
-
-    @Override
-    public Map<Service, Map<Capability, String>> getCapabilities() {
-        return capabilities;
-    }
-
-    @Override
-    public Provider getProvider() {
-        return Provider.InternalLoadBalancerVm;
-    }
-
-    @Override
-    public boolean implement(Network network, NetworkOffering offering, DeployDestination
dest, ReservationContext context)
-            throws ConcurrentOperationException, ResourceUnavailableException,
-            InsufficientCapacityException {
-        return true;
-    }
-
-    @Override
-    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
-            ResourceUnavailableException, InsufficientCapacityException {
-        return true;
-    }
-
-    @Override
-    public boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException
{
-        return true;
-    }
-
-    @Override
-    public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
throws ConcurrentOperationException, ResourceUnavailableException {
-        // TODO Shutdown all the internal lb elements
-        return false;
-    }
-
-    @Override
-    public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
-        // TODO Shutdown all the internal lb elements
-        return false;
-    }
-
-    @Override
-    public boolean isReady(PhysicalNetworkServiceProvider provider) {
-        // TODO Shutdown all the internal lb elements
-        return false;
-    }
-
-    @Override
-    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext
context) throws ConcurrentOperationException, ResourceUnavailableException {
-        // TODO Shutdown all the internal lb elements
-        return false;
-    }
-
-    @Override
-    public boolean canEnableIndividualServices() {
-        return false;
-    }
-
-    @Override
-    public boolean verifyServicesCombination(Set<Service> services) {
-        return true;
-    }
-
-    @Override
-    public IpDeployer getIpDeployer(Network network) {
-        return null;
-    }
-
-    @Override
-    public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws
ResourceUnavailableException {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public boolean validateLBRule(Network network, LoadBalancingRule rule) {
-        List<LoadBalancingRule> rules = new ArrayList<LoadBalancingRule>();
-        rules.add(rule);
-        if (canHandle(network, rules)) {
-            List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(),
Role.InternalLB);
-            if (routers == null || routers.isEmpty()) {
-                return true;
-            }
-            return VirtualRouterElement.validateHAProxyLBRule(rule);
-        }
-        return true;
-    }
-
-    @Override
-    public List<LoadBalancerTO> updateHealthChecks(Network network, List<LoadBalancingRule>
lbrules) {
-        return null;
-    }
-    
-    private static Map<Service, Map<Capability, String>> setCapabilities() {
-        Map<Service, Map<Capability, String>> capabilities = new HashMap<Service,
Map<Capability, String>>();
-
-        // Set capabilities for LB service
-        Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
-        lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn,source");
-        lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated");
-        lbCapabilities.put(Capability.SupportedProtocols, "tcp, udp");
-        lbCapabilities.put(Capability.SupportedStickinessMethods, VirtualRouterElement.getHAProxyStickinessCapability());
-        lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Internal.toString());
-
-        capabilities.put(Service.Lb, lbCapabilities);
-        return capabilities;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
new file mode 100644
index 0000000..6d3269c
--- /dev/null
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
@@ -0,0 +1,203 @@
+// 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.network.element;
+
+import java.util.ArrayList;
+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.log4j.Logger;
+
+import com.cloud.agent.api.to.LoadBalancerTO;
+import com.cloud.deploy.DeployDestination;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+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.PhysicalNetworkServiceProvider;
+import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.element.IpDeployer;
+import com.cloud.network.element.LoadBalancingServiceProvider;
+import com.cloud.network.element.NetworkElement;
+import com.cloud.network.element.VirtualRouterElement;
+import com.cloud.network.lb.LoadBalancingRule;
+import com.cloud.network.router.VirtualRouter.Role;
+import com.cloud.network.rules.LoadBalancerContainer;
+import com.cloud.offering.NetworkOffering;
+import com.cloud.utils.component.AdapterBase;
+import com.cloud.vm.DomainRouterVO;
+import com.cloud.vm.NicProfile;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.DomainRouterDao;
+
+@Local(value = {NetworkElement.class})
+public class InternalLoadBalancerElement extends AdapterBase implements LoadBalancingServiceProvider{
+    private static final Logger s_logger = Logger.getLogger(InternalLoadBalancerElement.class);
+    protected static final Map<Service, Map<Capability, String>> capabilities
= setCapabilities();
+
+    @Inject NetworkModel _ntwkModel;
+    @Inject NetworkServiceMapDao _ntwkSrvcDao;
+    @Inject DomainRouterDao _routerDao;
+    
+    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;
+                    }
+                }
+            }
+        }
+        
+        if (!_ntwkModel.isProviderSupportServiceInNetwork(config.getId(), Service.Lb, getProvider()))
{
+            s_logger.trace("Element " + getProvider().getName() + " doesn't support service
" + Service.Lb
+                    + " in the network " + config);
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public Map<Service, Map<Capability, String>> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public Provider getProvider() {
+        return Provider.InternalLbVm;
+    }
+
+    @Override
+    public boolean implement(Network network, NetworkOffering offering, DeployDestination
dest, ReservationContext context)
+            throws ConcurrentOperationException, ResourceUnavailableException,
+            InsufficientCapacityException {
+        return true;
+    }
+
+    @Override
+    public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
+            ResourceUnavailableException, InsufficientCapacityException {
+        return true;
+    }
+
+    @Override
+    public boolean release(Network network, NicProfile nic, VirtualMachineProfile<? extends
VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException
{
+        return true;
+    }
+
+    @Override
+    public boolean shutdown(Network network, ReservationContext context, boolean cleanup)
throws ConcurrentOperationException, ResourceUnavailableException {
+        // TODO Shutdown all the internal lb elements
+        return true;
+    }
+
+    @Override
+    public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
+        // TODO Shutdown all the internal lb elements
+        return true;
+    }
+
+    @Override
+    public boolean isReady(PhysicalNetworkServiceProvider provider) {
+        // TODO Shutdown all the internal lb elements
+        return true;
+    }
+
+    @Override
+    public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext
context) throws ConcurrentOperationException, ResourceUnavailableException {
+        // TODO Shutdown all the internal lb elements
+        return true;
+    }
+
+    @Override
+    public boolean canEnableIndividualServices() {
+        return true;
+    }
+
+    @Override
+    public boolean verifyServicesCombination(Set<Service> services) {
+        return true;
+    }
+
+    @Override
+    public IpDeployer getIpDeployer(Network network) {
+        return null;
+    }
+
+    @Override
+    public boolean applyLBRules(Network network, List<LoadBalancingRule> rules) throws
ResourceUnavailableException {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    @Override
+    public boolean validateLBRule(Network network, LoadBalancingRule rule) {
+        List<LoadBalancingRule> rules = new ArrayList<LoadBalancingRule>();
+        rules.add(rule);
+        if (canHandle(network, rules)) {
+            List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(),
Role.InternalLB);
+            if (routers == null || routers.isEmpty()) {
+                return true;
+            }
+            return VirtualRouterElement.validateHAProxyLBRule(rule);
+        }
+        return true;
+    }
+
+    @Override
+    public List<LoadBalancerTO> updateHealthChecks(Network network, List<LoadBalancingRule>
lbrules) {
+        return null;
+    }
+    
+    private static Map<Service, Map<Capability, String>> setCapabilities() {
+        Map<Service, Map<Capability, String>> capabilities = new HashMap<Service,
Map<Capability, String>>();
+
+        // Set capabilities for LB service
+        Map<Capability, String> lbCapabilities = new HashMap<Capability, String>();
+        lbCapabilities.put(Capability.SupportedLBAlgorithms, "roundrobin,leastconn,source");
+        lbCapabilities.put(Capability.SupportedLBIsolation, "dedicated");
+        lbCapabilities.put(Capability.SupportedProtocols, "tcp, udp");
+        lbCapabilities.put(Capability.SupportedStickinessMethods, VirtualRouterElement.getHAProxyStickinessCapability());
+        lbCapabilities.put(Capability.LbSchemes, LoadBalancerContainer.Scheme.Internal.toString());
+
+        capabilities.put(Service.Lb, lbCapabilities);
+        return capabilities;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManager.java
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManager.java
new file mode 100644
index 0000000..eab5e6a
--- /dev/null
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManager.java
@@ -0,0 +1,23 @@
+// 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.network.lb;
+
+import com.cloud.utils.component.Manager;
+
+public interface InternalLoadBalancerManager extends Manager{
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManagerImpl.java
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManagerImpl.java
new file mode 100644
index 0000000..0a023ae
--- /dev/null
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerManagerImpl.java
@@ -0,0 +1,148 @@
+// 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.network.lb;
+
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.agent.api.StopAnswer;
+import com.cloud.agent.api.to.NicTO;
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.agent.manager.Commands;
+import com.cloud.deploy.DeployDestination;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.Network;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.vm.DomainRouterVO;
+import com.cloud.vm.ReservationContext;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineGuru;
+import com.cloud.vm.VirtualMachineManager;
+import com.cloud.vm.VirtualMachineProfile;
+
+@Component
+@Local(value = { InternalLoadBalancerManager.class })
+public class InternalLoadBalancerManagerImpl extends ManagerBase implements
+InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
+    private static final Logger s_logger = Logger
+            .getLogger(InternalLoadBalancerManagerImpl.class);
+    
+    @Inject VirtualMachineManager _itMgr;
+
+    @Override
+    public DomainRouterVO findByName(String name) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public DomainRouterVO findById(long id) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public DomainRouterVO persist(DomainRouterVO vm) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<DomainRouterVO>
profile, DeployDestination dest, ReservationContext context) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<DomainRouterVO>
profile, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException
{
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean finalizeStart(VirtualMachineProfile<DomainRouterVO> profile, long
hostId, Commands cmds, ReservationContext context) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<DomainRouterVO>
profile) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void finalizeStop(VirtualMachineProfile<DomainRouterVO> profile, StopAnswer
answer) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public void finalizeExpunge(DomainRouterVO vm) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    @Override
+    public Long convertToId(String vmName) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean plugNic(Network network, NicTO nic, VirtualMachineTO vm, ReservationContext
context, DeployDestination dest) throws ConcurrentOperationException, ResourceUnavailableException,
+            InsufficientCapacityException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean unplugNic(Network network, NicTO nic, VirtualMachineTO vm, ReservationContext
context, DeployDestination dest) throws ConcurrentOperationException, ResourceUnavailableException
{
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void prepareStop(VirtualMachineProfile<DomainRouterVO> profile) {
+        // TODO Auto-generated method stub
+        
+    }
+    
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
+        _itMgr.registerGuru(VirtualMachine.Type.InternalLoadBalancerVm, this);
+
+        if (s_logger.isInfoEnabled()) {
+            s_logger.info(getName()  +  " has been configured");
+        }
+        return true;
+    }
+    
+    @Override
+    public String getName() {
+        return _name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/caa6d87c/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 4eb620c..b0dcee0 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -3077,6 +3077,22 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
 
         return nsp;
     }
+    
+    
+    protected PhysicalNetworkServiceProvider addDefaultInternalLbProviderToPhysicalNetwork(long
physicalNetworkId) {
+
+        PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId,
Network.Provider.InternalLbVm.getName(), null, null);
+        // add instance of the provider
+        NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.InternalLbVm.getName());
+        if (networkElement == null) {
+            throw new CloudRuntimeException("Unable to find the Network Element implementing
the " + Network.Provider.InternalLbVm.getName() + " Provider");
+        }
+        
+        VirtualRouterElement element = (VirtualRouterElement)networkElement;
+        element.addElement(nsp.getId(), VirtualRouterProviderType.VirtualRouter);
+
+        return nsp;
+    }
 
     protected PhysicalNetworkServiceProvider addDefaultSecurityGroupProviderToPhysicalNetwork(long
physicalNetworkId) {
 
@@ -3085,6 +3101,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
 
         return nsp;
     }
+    
+    
 
     private PhysicalNetworkServiceProvider addDefaultBaremetalProvidersToPhysicalNetwork(long
physicalNetworkId) {
         PhysicalNetworkVO pvo = _physicalNetworkDao.findById(physicalNetworkId);


Mime
View raw message