cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devd...@apache.org
Subject git commit: updated refs/heads/master to 24a8d60
Date Fri, 26 Jul 2013 11:20:15 GMT
Updated Branches:
  refs/heads/master 71e387f1f -> 24a8d60d6


CLOUDSTACK-62 [AWS Style Health Checks] Response of the API listLoadBalancerRuleInstances
should show the service state of a VM if health check is configured for it


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

Branch: refs/heads/master
Commit: 24a8d60d6fbd1a051b6a597b2d3c5b905c0e5fa2
Parents: 71e387f
Author: Rajesh Battala <rajesh.battala@citrix.com>
Authored: Thu Jun 13 14:40:43 2013 +0530
Committer: Devdeep Singh <devdeep@gmail.com>
Committed: Fri Jul 26 16:40:26 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/network/lb/LoadBalancingRulesService.java |  5 +++--
 api/src/org/apache/cloudstack/api/ApiConstants.java     |  2 +-
 .../loadbalancer/ListLoadBalancerRuleInstancesCmd.java  | 10 +++++++++-
 .../apache/cloudstack/api/response/UserVmResponse.java  |  6 ++++++
 .../cloud/network/lb/LoadBalancingRulesManagerImpl.java | 12 +++++++-----
 5 files changed, 26 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24a8d60d/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
index 5fc41e3..59d5c8d 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
@@ -103,9 +103,10 @@ public interface LoadBalancingRulesService {
      * balancer.
      *
      * @param cmd
-     * @return list of vm instances that have been or can be applied to a load balancer
+     * @return list of vm instances that have been or can be applied to a load balancer along
with service state,
+     * if the LB has health check policy created on it from cloudstack.
      */
-    List<? extends UserVm> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd
cmd);
+    Pair<List<? extends UserVm>, List<String>> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd
cmd);
 
     /**
      * List load balancer rules based on the given criteria

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24a8d60d/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 121403f..00d526d 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -517,7 +517,7 @@ public class ApiConstants {
     public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
     public static final String ROUTING = "isrouting";
     public static final String MAX_CONNECTIONS = "maxconnections";
-
+    public static final String SERVICE_STATE = "servicestate";
     public enum HostDetails {
         all, capacity, events, stats, min;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24a8d60d/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java
b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java
index 49ab42c..fcd41c4 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRuleInstancesCmd.java
@@ -17,6 +17,7 @@
 package org.apache.cloudstack.api.command.user.loadbalancer;
 
 import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 import org.apache.cloudstack.api.APICommand;
@@ -29,6 +30,7 @@ import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.log4j.Logger;
 
 import com.cloud.uservm.UserVm;
+import com.cloud.utils.Pair;
 
 @APICommand(name = "listLoadBalancerRuleInstances", description="List all virtual machine
instances that are assigned to a load balancer rule.", responseObject=UserVmResponse.class)
 public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
@@ -70,12 +72,18 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
 
     @Override
     public void execute(){
-        List<? extends UserVm> result = _lbService.listLoadBalancerInstances(this);
+        Pair<List<? extends UserVm>, List<String>> vmServiceMap =  _lbService.listLoadBalancerInstances(this);
+        List<? extends UserVm> result = vmServiceMap.first();
+        List<String> serviceStates  = vmServiceMap.second();
         ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
         List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
         if (result != null) {
             vmResponses = _responseGenerator.createUserVmResponse("loadbalancerruleinstance",
result.toArray(new UserVm[result.size()]));
         }
+
+        for (int i=0;i<result.size(); i++) {
+            vmResponses.get(i).setServiceState(serviceStates.get(i));
+        }
         response.setResponses(vmResponses);
         response.setResponseName(getCommandName());
         this.setResponseObject(response);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24a8d60d/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
index 0df9413..e49e16b 100644
--- a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java
@@ -191,6 +191,8 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
 
     @SerializedName(ApiConstants.IS_DYNAMICALLY_SCALABLE) @Param(description="true if vm
contains XS/VMWare tools inorder to support dynamic scaling of VM cpu/memory.")
     private Boolean isDynamicallyScalable;
+    @SerializedName(ApiConstants.SERVICE_STATE) @Param(description="State of the Service
from LB rule")
+    private String serviceState;
 
     public UserVmResponse(){
         securityGroupList = new LinkedHashSet<SecurityGroupResponse>();
@@ -439,4 +441,8 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
         this.isDynamicallyScalable = isDynamicallyScalable;
     }
 
+    public void setServiceState(String state) {
+        this.serviceState = state;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/24a8d60d/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 92f9417..3f7b70f 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -1835,7 +1835,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
     }
 
     @Override
-    public List<UserVmVO> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd
cmd)
+    public Pair<List<? extends UserVm>, List<String>> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd
cmd)
             throws PermissionDeniedException {
         Account caller = CallContext.current().getCallingAccount();
         Long loadBalancerId = cmd.getId();
@@ -1853,14 +1853,16 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
         _accountMgr.checkAccess(caller, null, true, loadBalancer);
 
         List<UserVmVO> loadBalancerInstances = new ArrayList<UserVmVO>();
+        List<String> serviceStates = new ArrayList<String>();
         List<LoadBalancerVMMapVO> vmLoadBalancerMappings = null;
-
         vmLoadBalancerMappings = _lb2VmMapDao.listByLoadBalancerId(loadBalancerId);
-
+        Map<Long, String> vmServiceState = new HashMap<Long, String>(vmLoadBalancerMappings.size());
         List<Long> appliedInstanceIdList = new ArrayList<Long>();
+
         if ((vmLoadBalancerMappings != null) && !vmLoadBalancerMappings.isEmpty())
{
             for (LoadBalancerVMMapVO vmLoadBalancerMapping : vmLoadBalancerMappings) {
                 appliedInstanceIdList.add(vmLoadBalancerMapping.getInstanceId());
+                vmServiceState.put(vmLoadBalancerMapping.getInstanceId(), vmLoadBalancerMapping.getState());
             }
         }
 
@@ -1881,10 +1883,10 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase
implements
             boolean isApplied = appliedInstanceIdList.contains(userVm.getId());
             if ((isApplied && applied) || (!isApplied && !applied)) {
                 loadBalancerInstances.add(userVm);
+                serviceStates.add(vmServiceState.get(userVm.getId()));
             }
         }
-
-        return loadBalancerInstances;
+        return new Pair<List<? extends UserVm>, List<String>>(loadBalancerInstances,serviceStates);
     }
 
     @Override


Mime
View raw message