You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2014/06/18 12:31:45 UTC
git commit: updated refs/heads/4.4-forward to 21e452f
Repository: cloudstack
Updated Branches:
refs/heads/4.4-forward 095be4831 -> 21e452ff4
CLOUDSTACK-6920 Support listing of LBHealthcheck policy with LBHealthcheck policy ID
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/21e452ff
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/21e452ff
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/21e452ff
Branch: refs/heads/4.4-forward
Commit: 21e452ff4f0459422f0612f2ddf7033a963b0a19
Parents: 095be48
Author: Rajesh Battala <ra...@citrix.com>
Authored: Wed Jun 18 15:42:23 2014 +0530
Committer: Rajesh Battala <ra...@citrix.com>
Committed: Wed Jun 18 15:42:23 2014 +0530
----------------------------------------------------------------------
.../network/lb/LoadBalancingRulesService.java | 2 ++
.../ListLBHealthCheckPoliciesCmd.java | 21 ++++++++++++++++++--
.../lb/LoadBalancingRulesManagerImpl.java | 16 +++++++++++++--
3 files changed, 35 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/21e452ff/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 3e11014..50b39d2 100644
--- a/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
+++ b/api/src/com/cloud/network/lb/LoadBalancingRulesService.java
@@ -161,4 +161,6 @@ public interface LoadBalancingRulesService {
HealthCheckPolicy updateLBHealthCheckPolicy(long id, String customId, Boolean forDisplay);
LoadBalancer findLbByStickinessId(long stickinessPolicyId);
+
+ Long findLBIdByHealtCheckPolicyId(long lbHealthCheckPolicy);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/21e452ff/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java
index 7f78da64..3f2082a 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLBHealthCheckPoliciesCmd.java
@@ -29,6 +29,8 @@ import org.apache.cloudstack.api.response.LBHealthCheckResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.log4j.Logger;
+
+import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.rules.HealthCheckPolicy;
import com.cloud.network.rules.LoadBalancer;
@@ -45,13 +47,15 @@ public class ListLBHealthCheckPoliciesCmd extends BaseListCmd {
@Parameter(name = ApiConstants.LBID,
type = CommandType.UUID,
entityType = FirewallRuleResponse.class,
- required = true,
description = "the ID of the load balancer rule")
private Long lbRuleId;
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "list resources by display flag; only ROOT admin is eligible to pass this parameter", since = "4.4", authorized = {RoleType.Admin})
private Boolean display;
+ @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LBHealthCheckResponse.class, description = "the ID of the healthcheck policy", since = "4.4")
+ private Long id;
+
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@@ -59,6 +63,10 @@ public class ListLBHealthCheckPoliciesCmd extends BaseListCmd {
return lbRuleId;
}
+ public Long getId() {
+ return id;
+ }
+
public boolean getDisplay() {
if (display != null) {
return display;
@@ -78,9 +86,18 @@ public class ListLBHealthCheckPoliciesCmd extends BaseListCmd {
@Override
public void execute() {
List<LBHealthCheckResponse> hcpResponses = new ArrayList<LBHealthCheckResponse>();
- LoadBalancer lb = _lbService.findById(getLbRuleId());
ListResponse<LBHealthCheckResponse> response = new ListResponse<LBHealthCheckResponse>();
+ Long lbRuleId = getLbRuleId();
+ Long hId = getId();
+ if(lbRuleId == null) {
+ if(hId != null) {
+ lbRuleId = _lbService.findLBIdByHealtCheckPolicyId(hId);
+ } else {
+ throw new InvalidParameterValueException("Either LB Ruleid or HealthCheckpolicy Id should be specified");
+ }
+ }
+ LoadBalancer lb = _lbService.findById(lbRuleId);
if (lb != null) {
List<? extends HealthCheckPolicy> healthCheckPolicies = _lbService.searchForLBHealthCheckPolicies(this);
LBHealthCheckResponse spResponse = _responseGenerator.createLBHealthCheckPolicyResponse(healthCheckPolicies, lb);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/21e452ff/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 6358252..e29d8c3 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -2239,15 +2239,18 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
public List<LBHealthCheckPolicyVO> searchForLBHealthCheckPolicies(ListLBHealthCheckPoliciesCmd cmd) throws PermissionDeniedException {
Account caller = CallContext.current().getCallingAccount();
Long loadBalancerId = cmd.getLbRuleId();
+ Long policyId = cmd.getId();
boolean forDisplay = cmd.getDisplay();
-
+ if(loadBalancerId == null) {
+ loadBalancerId = findLBIdByHealtCheckPolicyId(policyId);
+ }
LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
if (loadBalancer == null) {
return null;
}
_accountMgr.checkAccess(caller, null, true, loadBalancer);
- List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(cmd.getLbRuleId(), forDisplay);
+ List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, forDisplay);
return hcDbpolicies;
}
@@ -2545,4 +2548,13 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
return _lb2healthcheckDao.findById(id);
}
+ @Override
+ public Long findLBIdByHealtCheckPolicyId(long lbHealthCheckPolicy) {
+ LBHealthCheckPolicyVO policy= _lb2healthcheckDao.findById(lbHealthCheckPolicy);
+ if(policy != null) {
+ return policy.getLoadBalancerId();
+ }
+ return null;
+ }
+
}