cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [2/2] git commit: updated refs/heads/internallb to ae69f0a
Date Sat, 13 Apr 2013 00:42:06 GMT
InternalLb: fixed prepare() in InternalLbElement - have to prepare nics of User vms only


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

Branch: refs/heads/internallb
Commit: ae69f0ae5612834b8bc911bd074cfb050c0b164c
Parents: 888a83c
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Fri Apr 12 17:25:02 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Fri Apr 12 17:34:05 2013 -0700

----------------------------------------------------------------------
 .../element/InternalLoadBalancerElement.java       |   58 ++++++++-------
 .../lb/InternalLoadBalancerManagerImpl.java        |   12 ---
 2 files changed, 31 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae69f0ae/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
index 9b50e77..1ff1cab 100644
--- 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
@@ -197,26 +197,28 @@ public class InternalLoadBalancerElement extends AdapterBase implements
LoadBala
             return true;
         }
         
-        //1) Get all the Ips from the network having LB rules assigned
-        List<String> ips = _appLbDao.listLbIpsBySourceIpNetworkIdAndScheme(network.getId(),
Scheme.Internal);
-        
-        //2) Start those vms
-        for (String ip : ips) {
-            Ip sourceIp = new Ip(ip);
-            List<? extends VirtualRouter> internalLbVms;
-            try {
-                internalLbVms = _internalLbMgr.deployInternalLbVm(network, sourceIp, dest,
_accountMgr.getAccount(network.getAccountId()), null);
-            } catch (InsufficientCapacityException e) {
-                s_logger.warn("Failed to deploy element " + this.getName() + " for ip " +
sourceIp + " due to:", e);
-                return false;
-            } catch (ConcurrentOperationException e) {
-                s_logger.warn("Failed to deploy element " + this.getName() + " for ip " +
sourceIp +  " due to:", e);
-                return false;
-            }
+        if (vm.getType() == VirtualMachine.Type.User) {
+          //1) Get all the Ips from the network having LB rules assigned
+            List<String> ips = _appLbDao.listLbIpsBySourceIpNetworkIdAndScheme(network.getId(),
Scheme.Internal);
             
-            if ((internalLbVms == null) || (internalLbVms.size() == 0)) {
-                throw new ResourceUnavailableException("Can't deploy " + this.getName() +
" to handle LB rules",
-                        DataCenter.class, network.getDataCenterId());
+            //2) Start those vms
+            for (String ip : ips) {
+                Ip sourceIp = new Ip(ip);
+                List<? extends VirtualRouter> internalLbVms;
+                try {
+                    internalLbVms = _internalLbMgr.deployInternalLbVm(network, sourceIp,
dest, _accountMgr.getAccount(network.getAccountId()), null);
+                } catch (InsufficientCapacityException e) {
+                    s_logger.warn("Failed to deploy element " + this.getName() + " for ip
" + sourceIp + " due to:", e);
+                    return false;
+                } catch (ConcurrentOperationException e) {
+                    s_logger.warn("Failed to deploy element " + this.getName() + " for ip
" + sourceIp +  " due to:", e);
+                    return false;
+                }
+                
+                if ((internalLbVms == null) || (internalLbVms.size() == 0)) {
+                    throw new ResourceUnavailableException("Can't deploy " + this.getName()
+ " to handle LB rules",
+                            DataCenter.class, network.getDataCenterId());
+                }
             }
         }
         
@@ -324,14 +326,16 @@ public class InternalLoadBalancerElement extends AdapterBase implements
LoadBala
             if (vmsToDestroy.contains(sourceIp)) {
                 //2.1 Destroy internal lb vm
                 List<? extends VirtualRouter> vms = _internalLbMgr.findInternalLbVms(network.getId(),
sourceIp);
-                //only one internal lb per IP exists
-                try {
-                    s_logger.debug("Destroying internal lb vm for ip " + sourceIp.addr()
+ " as all the rules for this vm are in Revoke state");
-                    return _internalLbMgr.destroyInternalLbVm(vms.get(0).getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM),
-                            _accountMgr.getUserIncludingRemoved(User.UID_SYSTEM).getId());
-                } catch (ConcurrentOperationException e) {
-                    s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr()
+ " on the element " + this.getName() + " due to:", e);
-                    return false;
+                if (vms.size() > 0) {
+                    //only one internal lb per IP exists
+                    try {
+                        s_logger.debug("Destroying internal lb vm for ip " + sourceIp.addr()
+ " as all the rules for this vm are in Revoke state");
+                        return _internalLbMgr.destroyInternalLbVm(vms.get(0).getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM),
+                                _accountMgr.getUserIncludingRemoved(User.UID_SYSTEM).getId());
+                    } catch (ConcurrentOperationException e) {
+                        s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr()
+ " on the element " + this.getName() + " due to:", e);
+                        return false;
+                    }
                 }
             } else {
                 //2.2 Start Internal LB vm per IP address

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae69f0ae/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
index 88b8232..b4b79bc 100644
--- 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
@@ -56,7 +56,6 @@ import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.InsufficientServerCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.OperationTimedoutException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.exception.StorageUnavailableException;
@@ -887,15 +886,4 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO>
{
         }
         return result;
     }
-
-
-    protected VirtualRouter startInternalLbVm(long vmId, Account caller, long callerUserId)
throws StorageUnavailableException, InsufficientCapacityException,
-            ConcurrentOperationException, ResourceUnavailableException {
-        DomainRouterVO vm = _routerDao.findById(vmId);
-        if (vm == null || vm.getRole() != VirtualRouter.Role.INTERNAL_LB_VM) {
-            throw new InvalidParameterValueException("Unable to find internal lb vm by id");
-        }
-        
-        return startInternalLbVm(vm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount(),
callerUserId, null);
-    }
 }


Mime
View raw message