cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/internallb to 4530ceb
Date Mon, 15 Apr 2013 18:40:05 GMT
Updated Branches:
  refs/heads/internallb ae69f0ae5 -> 4530cebf2


InternalLbVm: support for start/stop Internal lb vm


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

Branch: refs/heads/internallb
Commit: 4530cebf2bef515f86fa29b3798d51e81089f92f
Parents: ae69f0a
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Apr 15 10:06:10 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Apr 15 11:36:52 2013 -0700

----------------------------------------------------------------------
 .../network/VirtualNetworkApplianceService.java    |    2 +
 api/src/org/apache/cloudstack/api/BaseCmd.java     |    4 +-
 .../api/command/admin/router/StartRouterCmd.java   |   12 ++++-
 .../api/command/admin/router/StopRouterCmd.java    |   13 +++++-
 .../network/lb/InternalLoadBalancerService.java    |   34 +++++++++++++
 .../network/lb/InternalLoadBalancerManager.java    |    2 +-
 .../lb/InternalLoadBalancerManagerImpl.java        |   37 +++++++++++---
 .../network/lb/LoadBalancingRulesManagerImpl.java  |    3 +
 .../router/VirtualNetworkApplianceManagerImpl.java |    7 +++
 .../vpc/MockVpcVirtualNetworkApplianceManager.java |    6 ++
 10 files changed, 108 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/api/src/com/cloud/network/VirtualNetworkApplianceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/VirtualNetworkApplianceService.java b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
index 250ecb2..58eead2 100644
--- a/api/src/com/cloud/network/VirtualNetworkApplianceService.java
+++ b/api/src/com/cloud/network/VirtualNetworkApplianceService.java
@@ -63,5 +63,7 @@ public interface VirtualNetworkApplianceService {
     VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException,
ConcurrentOperationException;
 
     VirtualRouter destroyRouter(long routerId, Account caller, Long callerUserId) throws
ResourceUnavailableException, ConcurrentOperationException;
+    
+    VirtualRouter findRouter(long routerId);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseCmd.java b/api/src/org/apache/cloudstack/api/BaseCmd.java
index 60fa9ba..beebe5b 100644
--- a/api/src/org/apache/cloudstack/api/BaseCmd.java
+++ b/api/src/org/apache/cloudstack/api/BaseCmd.java
@@ -30,6 +30,7 @@ import javax.inject.Inject;
 import org.apache.cloudstack.affinity.AffinityGroupService;
 import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
 import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
+import org.apache.cloudstack.network.lb.InternalLoadBalancerService;
 import org.apache.cloudstack.query.QueryService;
 import org.apache.cloudstack.usage.UsageService;
 import org.apache.log4j.Logger;
@@ -140,7 +141,8 @@ public abstract class BaseCmd {
     @Inject public NetworkModel _ntwkModel;
     @Inject public ApplicationLoadBalancerService _appLbService;
     @Inject public AffinityGroupService _affinityGroupService;
-    @Inject public InternalLoadBalancerElementService _internalLbSvs;
+    @Inject public InternalLoadBalancerElementService _internalLbElementSvc;
+    @Inject public InternalLoadBalancerService _internalLbSvc;
     
 
     public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException,
ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
index 1d3930b..9ef2ab9 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StartRouterCmd.java
@@ -29,8 +29,10 @@ import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.user.Account;
 import com.cloud.user.UserContext;
 
@@ -100,7 +102,15 @@ public class StartRouterCmd extends BaseAsyncCmd {
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException,
InsufficientCapacityException{
         UserContext.current().setEventDetails("Router Id: "+getId());
-        VirtualRouter result = _routerService.startRouter(id);
+        VirtualRouter result = null;
+        VirtualRouter router = _routerService.findRouter(getId());
+        if (router == null) {
+            throw new InvalidParameterValueException("Can't find router by id");
+        } else if (router.getRole() == Role.INTERNAL_LB_VM) {
+            result = _internalLbSvc.startInternalLbVm(getId(), UserContext.current().getCaller(),
UserContext.current().getCallerUserId());
+        } else {
+            result = _routerService.startRouter(getId());
+        }
         if (result != null){
             DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
             routerResponse.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
index 60dd938..ff8ba36 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/router/StopRouterCmd.java
@@ -28,8 +28,10 @@ import org.apache.log4j.Logger;
 import com.cloud.async.AsyncJob;
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.user.Account;
 import com.cloud.user.UserContext;
 
@@ -103,7 +105,16 @@ public class StopRouterCmd extends BaseAsyncCmd {
     @Override
     public void execute() throws ConcurrentOperationException, ResourceUnavailableException
{
         UserContext.current().setEventDetails("Router Id: "+getId());
-        VirtualRouter result = _routerService.stopRouter(getId(), isForced());
+        VirtualRouter result = null;
+        VirtualRouter router = _routerService.findRouter(getId());
+        if (router == null) {
+            throw new InvalidParameterValueException("Can't find router by id");
+        } else if (router.getRole() == Role.INTERNAL_LB_VM) {
+            result = _internalLbSvc.stopInternalLbVm(getId(), isForced(), UserContext.current().getCaller(),
UserContext.current().getCallerUserId());
+        } else {
+            result = _routerService.stopRouter(getId(), isForced());
+        }
+        
         if (result != null) {
             DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
             response.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerService.java b/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerService.java
new file mode 100644
index 0000000..f908936
--- /dev/null
+++ b/api/src/org/apache/cloudstack/network/lb/InternalLoadBalancerService.java
@@ -0,0 +1,34 @@
+// 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.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.network.router.VirtualRouter;
+import com.cloud.user.Account;
+
+public interface InternalLoadBalancerService {
+
+    VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)

+            throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException,
ResourceUnavailableException;
+
+    VirtualRouter stopInternalLbVm(long vmId, boolean forced, Account caller, long callerUserId)
+            throws ConcurrentOperationException, ResourceUnavailableException;
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/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
index 5219775..c3cccb3 100644
--- 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
@@ -31,7 +31,7 @@ import com.cloud.utils.component.Manager;
 import com.cloud.utils.net.Ip;
 import com.cloud.vm.VirtualMachineProfile.Param;
 
-public interface InternalLoadBalancerManager extends Manager{
+public interface InternalLoadBalancerManager extends Manager, InternalLoadBalancerService{
     /**
      * Destroys Internal LB vm instance
      * @param vmId

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/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 b4b79bc..2471c49 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,6 +56,7 @@ 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;
@@ -116,7 +117,7 @@ import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
 
 @Component
-@Local(value = { InternalLoadBalancerManager.class})
+@Local(value = { InternalLoadBalancerManager.class, InternalLoadBalancerService.class})
 public class InternalLoadBalancerManagerImpl extends ManagerBase implements
 InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO> {
     private static final Logger s_logger = Logger
@@ -539,12 +540,18 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO>
{
     }
 
     
-    protected VirtualRouter stopInternalLbVm(long vmId, boolean forced, Account caller, long
callerUserId) throws ConcurrentOperationException, ResourceUnavailableException {
+    @Override
+    public VirtualRouter stopInternalLbVm(long vmId, boolean forced, Account caller, long
callerUserId) throws ConcurrentOperationException,
+    ResourceUnavailableException {
         DomainRouterVO internalLbVm = _routerDao.findById(vmId);
-        if (internalLbVm == null) {
-            return null;
+        if (internalLbVm == null || internalLbVm.getRole() != Role.INTERNAL_LB_VM) {
+            throw new InvalidParameterValueException("Can't find internal lb vm by id");
         }
         
+        return stopInternalLbVm(internalLbVm, forced, caller, callerUserId);
+    }
+
+    protected VirtualRouter stopInternalLbVm(DomainRouterVO internalLbVm, boolean forced,
Account caller, long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException
{
         s_logger.debug("Stopping internal lb vm " + internalLbVm);
         try {
             if (_itMgr.advanceStop((DomainRouterVO) internalLbVm, forced, _accountMgr.getActiveUser(callerUserId),
caller)) {
@@ -578,7 +585,7 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO>
{
 
         for (DomainRouterVO internalLbVm : internalLbVms) {
             if (internalLbVm.getState() != VirtualMachine.State.Running) {
-                internalLbVm = startInternalLbVm(internalLbVm, _accountMgr.getSystemUser(),
_accountMgr.getSystemAccount(), User.UID_SYSTEM, params);
+                internalLbVm = startInternalLbVm(internalLbVm, _accountMgr.getSystemAccount(),
User.UID_SYSTEM, params);
             }
             
             if (internalLbVm != null) {
@@ -768,7 +775,7 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO>
{
 
             if (startVm) {
                 try {
-                    internalLbVm = startInternalLbVm(internalLbVm, _accountMgr.getSystemUser(),
_accountMgr.getSystemAccount(), User.UID_SYSTEM, params);
+                    internalLbVm = startInternalLbVm(internalLbVm, _accountMgr.getSystemAccount(),
User.UID_SYSTEM, params);
                     break;
                 } catch (InsufficientCapacityException ex) {
                     if (startRetry < 2 && iter.hasNext()) {
@@ -793,11 +800,11 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO>
{
     
     
 
-    protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, User user, Account
caller, long callerUserId, Map<Param, Object> params) 
+    protected DomainRouterVO startInternalLbVm(DomainRouterVO internalLbVm, Account caller,
long callerUserId, Map<Param, Object> params) 
             throws StorageUnavailableException, InsufficientCapacityException,
             ConcurrentOperationException, ResourceUnavailableException {
         s_logger.debug("Starting Internal LB VM " + internalLbVm);
-        if (_itMgr.start(internalLbVm, params, user, caller, null) != null) {
+        if (_itMgr.start(internalLbVm, params, _accountMgr.getUserIncludingRemoved(callerUserId),
caller, null) != null) {
             if (internalLbVm.isStopPending()) {
                 s_logger.info("Clear the stop pending flag of Internal LB VM " + internalLbVm.getHostName()
+ " after start router successfully!");
                 internalLbVm.setStopPending(false);
@@ -886,4 +893,18 @@ InternalLoadBalancerManager, VirtualMachineGuru<DomainRouterVO>
{
         }
         return result;
     }
+    
+    
+    @Override
+    public VirtualRouter startInternalLbVm(long internalLbVmId, Account caller, long callerUserId)

+            throws StorageUnavailableException, InsufficientCapacityException,
+            ConcurrentOperationException, ResourceUnavailableException {
+        
+        DomainRouterVO internalLbVm = _routerDao.findById(internalLbVmId);
+        if (internalLbVm == null || internalLbVm.getRole() != Role.INTERNAL_LB_VM) {
+            throw new InvalidParameterValueException("Can't find internal lb vm by id specified");
+        }
+        
+        return startInternalLbVm(internalLbVm, caller, callerUserId, null);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index 59ff435..f16b486 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -1475,6 +1475,9 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
     @Override
     public boolean revokeLoadBalancersForNetwork(long networkId, Scheme scheme) throws ResourceUnavailableException
{
         List<LoadBalancerVO> lbs = _lbDao.listByNetworkIdAndScheme(networkId, scheme);
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Revoking " + lbs.size() + " " + scheme + " load balancing rules
for network id=" + networkId);
+        }
         if (lbs != null) {
             for(LoadBalancerVO lb : lbs) { // called during restart, not persisting state
in db
                 lb.setState(FirewallRule.State.Revoke);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 1464991..6c43474 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -3742,4 +3742,11 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
             }
         }
     }
+
+
+
+    @Override
+    public VirtualRouter findRouter(long routerId) {
+        return _routerDao.findById(routerId);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4530cebf/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java b/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
index aee4fcb..9010f1f 100644
--- a/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
+++ b/server/test/com/cloud/vpc/MockVpcVirtualNetworkApplianceManager.java
@@ -408,4 +408,10 @@ VpcVirtualNetworkApplianceService {
         return false;
     }
 
+    @Override
+    public VirtualRouter findRouter(long routerId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
 }


Mime
View raw message