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/4.2 to 7b728cd
Date Fri, 26 Jul 2013 11:05:15 GMT
Updated Branches:
  refs/heads/4.2 567e4a849 -> 7b728cdb7


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

Conflicts:

	api/src/org/apache/cloudstack/api/ApiConstants.java
	api/src/org/apache/cloudstack/api/response/UserVmResponse.java


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

Branch: refs/heads/4.2
Commit: 7b728cdb717599a49ce040f260691257371c53a5
Parents: 567e4a8
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:27:16 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/7b728cdb/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/7b728cdb/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 34aed47..2c66299 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -516,7 +516,7 @@ public class ApiConstants {
     public static final String NUMBER = "number";
     public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
     public static final String ROUTING = "isrouting";
-
+    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/7b728cdb/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/7b728cdb/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/7b728cdb/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 6e0d0d7..fba93db 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -1832,7 +1832,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 = UserContext.current().getCaller();
         Long loadBalancerId = cmd.getId();
@@ -1850,14 +1850,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());
             }
         }
 
@@ -1878,10 +1880,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