mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-6596: UUID and display flag update support for LBStickinessPolicy and LBHealthCheckPolicy
This commit is contained in:
parent
25ab05a189
commit
66d5ebc657
@ -134,9 +134,11 @@ public class EventTypes {
|
||||
public static final String EVENT_LOAD_BALANCER_CREATE = "LB.CREATE";
|
||||
public static final String EVENT_LOAD_BALANCER_DELETE = "LB.DELETE";
|
||||
public static final String EVENT_LB_STICKINESSPOLICY_CREATE = "LB.STICKINESSPOLICY.CREATE";
|
||||
public static final String EVENT_LB_STICKINESSPOLICY_UPDATE = "LB.STICKINESSPOLICY.UPDATE";
|
||||
public static final String EVENT_LB_STICKINESSPOLICY_DELETE = "LB.STICKINESSPOLICY.DELETE";
|
||||
public static final String EVENT_LB_HEALTHCHECKPOLICY_CREATE = "LB.HEALTHCHECKPOLICY.CREATE";
|
||||
public static final String EVENT_LB_HEALTHCHECKPOLICY_DELETE = "LB.HEALTHCHECKPOLICY.DELETE";
|
||||
public static final String EVENT_LB_HEALTHCHECKPOLICY_UPDATE = "LB.HEALTHCHECKPOLICY.UPDATE";
|
||||
public static final String EVENT_LOAD_BALANCER_UPDATE = "LB.UPDATE";
|
||||
public static final String EVENT_LB_CERT_UPLOAD = "LB.CERT.UPLOAD";
|
||||
public static final String EVENT_LB_CERT_DELETE = "LB.CERT.DELETE";
|
||||
|
||||
@ -155,4 +155,8 @@ public interface LoadBalancingRulesService {
|
||||
boolean isLbRuleMappedToVmGuestIp(String vmSecondaryIp);
|
||||
|
||||
List<String> listLbVmIpAddress(long id, long vmId);
|
||||
|
||||
StickinessPolicy updateLBStickinessPolicy(long id, String customId, Boolean forDisplay);
|
||||
|
||||
HealthCheckPolicy updateLBHealthCheckPolicy(long id, String customId, Boolean forDisplay);
|
||||
}
|
||||
|
||||
@ -39,4 +39,9 @@ public interface HealthCheckPolicy extends InternalIdentity, Identity {
|
||||
|
||||
public boolean isRevoke();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
boolean isDisplay();
|
||||
|
||||
}
|
||||
|
||||
@ -39,4 +39,9 @@ public interface StickinessPolicy extends InternalIdentity, Identity {
|
||||
|
||||
public List<Pair<String, String>> getParams(); /* get params in Map <string,String> format */
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
boolean isDisplay();
|
||||
|
||||
}
|
||||
|
||||
@ -16,8 +16,7 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
@ -27,6 +26,7 @@ import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
@ -89,10 +89,18 @@ public class CreateLBHealthCheckPolicyCmd extends BaseAsyncCreateCmd {
|
||||
description = "Number of consecutive health check failures before declaring an instance unhealthy")
|
||||
private int unhealthyThreshold;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public Boolean getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public Long getLbRuleId() {
|
||||
return lbRuleId;
|
||||
}
|
||||
|
||||
@ -18,8 +18,7 @@ package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
@ -30,6 +29,7 @@ import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
@ -74,10 +74,18 @@ public class CreateLBStickinessPolicyCmd extends BaseAsyncCreateCmd {
|
||||
@Parameter(name = ApiConstants.PARAM_LIST, type = CommandType.MAP, description = "param list. Example: param[0].name=cookiename¶m[0].value=LBCookie ")
|
||||
private Map paramList;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the rule to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
public Boolean getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public Long getLbRuleId() {
|
||||
return lbRuleId;
|
||||
}
|
||||
|
||||
@ -19,8 +19,7 @@ package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
@ -28,6 +27,7 @@ import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.rules.HealthCheckPolicy;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
@ -49,6 +49,9 @@ public class ListLBHealthCheckPoliciesCmd extends BaseListCmd {
|
||||
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;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
@ -56,6 +59,13 @@ public class ListLBHealthCheckPoliciesCmd extends BaseListCmd {
|
||||
return lbRuleId;
|
||||
}
|
||||
|
||||
public boolean getDisplay() {
|
||||
if (display != null) {
|
||||
return display;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@ -19,8 +19,7 @@ package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
@ -29,6 +28,7 @@ import org.apache.cloudstack.api.response.FirewallRuleResponse;
|
||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
@ -51,6 +51,9 @@ public class ListLBStickinessPoliciesCmd extends BaseListCmd {
|
||||
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;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////////// Accessors ///////////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
@ -58,6 +61,13 @@ public class ListLBStickinessPoliciesCmd extends BaseListCmd {
|
||||
return lbRuleId;
|
||||
}
|
||||
|
||||
public boolean getDisplay() {
|
||||
if (display != null) {
|
||||
return display;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
// ///////////// API Implementation///////////////////
|
||||
// ///////////////////////////////////////////////////
|
||||
|
||||
@ -0,0 +1,100 @@
|
||||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by 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.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.LBHealthCheckResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.rules.HealthCheckPolicy;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "updateLBHealthCheckPolicy", description = "Updates LB HealthCheck policy", responseObject = LBHealthCheckResponse.class, since = "4.4",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class UpdateLBHealthCheckPolicyCmd extends BaseAsyncCustomIdCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateLBHealthCheckPolicyCmd.class.getName());
|
||||
|
||||
private static final String s_name = "updatelbhealthcheckpolicyresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LBHealthCheckResponse.class, required = true, description = "id of lb healthcheck policy")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the policy to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Boolean getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account account = CallContext.current().getCallingAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Update LB healthcheck policy id= " + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_LB_HEALTHCHECKPOLICY_UPDATE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public void execute() {
|
||||
HealthCheckPolicy policy = _lbService.updateLBHealthCheckPolicy(this.getId(), this.getCustomId(), this.getDisplay());
|
||||
LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
|
||||
LBHealthCheckResponse hcResponse = _responseGenerator.createLBHealthCheckPolicyResponse(policy, lb);
|
||||
setResponseObject(hcResponse);
|
||||
hcResponse.setResponseName(getCommandName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUuid() {
|
||||
if (this.getCustomId() != null) {
|
||||
_uuidMgr.checkUuid(this.getCustomId(), StickinessPolicy.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
// Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
// Apache License, Version 2.0 (the "License"); you may not use this
|
||||
// file except in compliance with the License. Citrix Systems, Inc.
|
||||
// reserves all rights not expressly granted by 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.
|
||||
//
|
||||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package org.apache.cloudstack.api.command.user.loadbalancer;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseAsyncCustomIdCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.LBStickinessResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "updateLBStickinessPolicy", description = "Updates LB Stickiness policy", responseObject = LBStickinessResponse.class, since = "4.4",
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class UpdateLBStickinessPolicyCmd extends BaseAsyncCustomIdCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateLBStickinessPolicyCmd.class.getName());
|
||||
|
||||
private static final String s_name = "updatelbstickinesspolicyresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = LBStickinessResponse.class, required = true, description = "id of lb stickiness policy")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name = ApiConstants.FOR_DISPLAY, type = CommandType.BOOLEAN, description = "an optional field, whether to the display the policy to the end user or not", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean display;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Boolean getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account account = CallContext.current().getCallingAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Update LB stickiness policy id= " + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_LB_STICKINESSPOLICY_UPDATE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@Override
|
||||
public void execute() {
|
||||
StickinessPolicy policy = _lbService.updateLBStickinessPolicy(this.getId(), this.getCustomId(), this.getDisplay());
|
||||
LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
|
||||
LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(policy, lb);
|
||||
setResponseObject(spResponse);
|
||||
spResponse.setResponseName(getCommandName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkUuid() {
|
||||
if (this.getCustomId() != null) {
|
||||
_uuidMgr.checkUuid(this.getCustomId(), StickinessPolicy.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,12 +16,13 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.network.rules.HealthCheckPolicy;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class LBHealthCheckPolicyResponse extends BaseResponse {
|
||||
@SerializedName("id")
|
||||
@ -56,6 +57,10 @@ public class LBHealthCheckPolicyResponse extends BaseResponse {
|
||||
@Param(description = "Number of consecutive health check failures before declaring an instance unhealthy.")
|
||||
private int unhealthcheckthresshold;
|
||||
|
||||
@SerializedName(ApiConstants.FOR_DISPLAY)
|
||||
@Param(description = "is policy for display to the regular user", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean forDisplay;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -95,6 +100,11 @@ public class LBHealthCheckPolicyResponse extends BaseResponse {
|
||||
this.responseTime = healthcheckpolicy.getResponseTime();
|
||||
this.healthcheckthresshold = healthcheckpolicy.getHealthcheckThresshold();
|
||||
this.unhealthcheckthresshold = healthcheckpolicy.getUnhealthThresshold();
|
||||
this.forDisplay = healthcheckpolicy.isDisplay();
|
||||
setObjectName("healthcheckpolicy");
|
||||
}
|
||||
|
||||
public void setForDisplay(Boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,8 @@ import java.util.Map;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.network.rules.StickinessPolicy;
|
||||
@ -49,6 +51,10 @@ public class LBStickinessPolicyResponse extends BaseResponse {
|
||||
@Param(description = "the state of the policy")
|
||||
private String state;
|
||||
|
||||
@SerializedName(ApiConstants.FOR_DISPLAY)
|
||||
@Param(description = "is policy for display to the regular user", since = "4.4", authorized = {RoleType.Admin})
|
||||
private Boolean forDisplay;
|
||||
|
||||
// FIXME : if prams with the same name exists more then once then value are concatinated with ":" as delimitor .
|
||||
// Reason: Map does not support duplicate keys, need to look for the alernate data structure
|
||||
// Example: <params>{indirect=null, name=testcookie, nocache=null, domain=www.yahoo.com:www.google.com, postonly=null}</params>
|
||||
@ -98,6 +104,7 @@ public class LBStickinessPolicyResponse extends BaseResponse {
|
||||
List<Pair<String, String>> paramsList = stickinesspolicy.getParams();
|
||||
this.methodName = stickinesspolicy.getMethodName();
|
||||
this.description = stickinesspolicy.getDescription();
|
||||
this.forDisplay = stickinesspolicy.isDisplay();
|
||||
if (stickinesspolicy.isRevoke()) {
|
||||
this.setState("Revoked");
|
||||
}
|
||||
@ -126,4 +133,8 @@ public class LBStickinessPolicyResponse extends BaseResponse {
|
||||
this.params = tempParamList;
|
||||
setObjectName("stickinesspolicy");
|
||||
}
|
||||
|
||||
public void setForDisplay(Boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,11 +167,13 @@ deleteLoadBalancerRule=15
|
||||
removeFromLoadBalancerRule=15
|
||||
assignToLoadBalancerRule=15
|
||||
createLBStickinessPolicy=15
|
||||
updateLBStickinessPolicy=15
|
||||
deleteLBStickinessPolicy=15
|
||||
listLoadBalancerRules=15
|
||||
listLBStickinessPolicies=15
|
||||
listLBHealthCheckPolicies=15
|
||||
createLBHealthCheckPolicy=15
|
||||
updateLBHealthCheckPolicy=15
|
||||
deleteLBHealthCheckPolicy=15
|
||||
listLoadBalancerRuleInstances=15
|
||||
updateLoadBalancerRule=15
|
||||
|
||||
@ -64,6 +64,9 @@ public class LBHealthCheckPolicyVO implements HealthCheckPolicy {
|
||||
@Column(name = "revoke")
|
||||
private boolean revoke = false;
|
||||
|
||||
@Column(name = "display", updatable = true, nullable = false)
|
||||
protected boolean display = true;
|
||||
|
||||
protected LBHealthCheckPolicyVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
@ -157,4 +160,13 @@ public class LBHealthCheckPolicyVO implements HealthCheckPolicy {
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ public interface LBHealthCheckPolicyDao extends GenericDao<LBHealthCheckPolicyVO
|
||||
|
||||
void remove(long loadBalancerId, Boolean pending);
|
||||
|
||||
List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId);
|
||||
List<LBHealthCheckPolicyVO> listByLoadBalancerIdAndDisplayFlag(long loadBalancerId, Boolean forDisplay);
|
||||
|
||||
List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId, boolean revoke);
|
||||
}
|
||||
|
||||
@ -48,9 +48,12 @@ public class LBHealthCheckPolicyDaoImpl extends GenericDaoBase<LBHealthCheckPoli
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LBHealthCheckPolicyVO> listByLoadBalancerId(long loadBalancerId) {
|
||||
public List<LBHealthCheckPolicyVO> listByLoadBalancerIdAndDisplayFlag(long loadBalancerId, Boolean forDisplay) {
|
||||
SearchCriteria<LBHealthCheckPolicyVO> sc = createSearchCriteria();
|
||||
sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
|
||||
if (forDisplay != null) {
|
||||
sc.addAnd("display", SearchCriteria.Op.EQ, forDisplay);
|
||||
}
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ public interface LBStickinessPolicyDao extends GenericDao<LBStickinessPolicyVO,
|
||||
|
||||
void remove(long loadBalancerId, Boolean pending);
|
||||
|
||||
List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId);
|
||||
List<LBStickinessPolicyVO> listByLoadBalancerIdAndDisplayFlag(long loadBalancerId, boolean forDisplay);
|
||||
|
||||
List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId, boolean revoke);
|
||||
}
|
||||
|
||||
@ -47,9 +47,10 @@ public class LBStickinessPolicyDaoImpl extends GenericDaoBase<LBStickinessPolicy
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LBStickinessPolicyVO> listByLoadBalancerId(long loadBalancerId) {
|
||||
public List<LBStickinessPolicyVO> listByLoadBalancerIdAndDisplayFlag(long loadBalancerId, boolean forDisplay) {
|
||||
SearchCriteria<LBStickinessPolicyVO> sc = createSearchCriteria();
|
||||
sc.addAnd("loadBalancerId", SearchCriteria.Op.EQ, loadBalancerId);
|
||||
sc.addAnd("display", SearchCriteria.Op.EQ, forDisplay);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@ -64,6 +64,9 @@ public class LBStickinessPolicyVO implements StickinessPolicy {
|
||||
@Column(name = "revoke")
|
||||
private boolean revoke = false;
|
||||
|
||||
@Column(name = "display", updatable = true, nullable = false)
|
||||
protected boolean display = true;
|
||||
|
||||
protected LBStickinessPolicyVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
@ -150,4 +153,13 @@ public class LBStickinessPolicyVO implements StickinessPolicy {
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public void setDisplay(boolean display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplay() {
|
||||
return display;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,11 +30,6 @@ import java.util.Set;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBHealthCheckPolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.CreateLBStickinessPolicyCmd;
|
||||
@ -50,6 +45,7 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe
|
||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||
import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
|
||||
import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.to.LoadBalancerTO;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
@ -169,6 +165,8 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.NicSecondaryIpDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@Local(value = {LoadBalancingRulesManager.class, LoadBalancingRulesService.class})
|
||||
public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements LoadBalancingRulesManager, LoadBalancingRulesService {
|
||||
@ -557,6 +555,10 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
/* Finally Insert into DB */
|
||||
LBStickinessPolicyVO policy =
|
||||
new LBStickinessPolicyVO(loadBalancer.getId(), cmd.getLBStickinessPolicyName(), cmd.getStickinessMethodName(), cmd.getparamList(), cmd.getDescription());
|
||||
Boolean forDisplay = cmd.getDisplay();
|
||||
if (forDisplay != null) {
|
||||
policy.setDisplay(forDisplay);
|
||||
}
|
||||
policy = _lb2stickinesspoliciesDao.persist(policy);
|
||||
|
||||
return policy;
|
||||
@ -621,6 +623,11 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
new LBHealthCheckPolicyVO(loadBalancer.getId(), cmd.getPingPath(), cmd.getDescription(), cmd.getResponsTimeOut(), cmd.getHealthCheckInterval(),
|
||||
cmd.getHealthyThreshold(), cmd.getUnhealthyThreshold());
|
||||
|
||||
Boolean forDisplay = cmd.getDisplay();
|
||||
if (forDisplay != null) {
|
||||
policy.setDisplay(forDisplay);
|
||||
}
|
||||
|
||||
policy = _lb2healthcheckDao.persist(policy);
|
||||
return policy;
|
||||
}
|
||||
@ -1494,7 +1501,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
}
|
||||
}
|
||||
|
||||
List<LBHealthCheckPolicyVO> hcPolicies = _lb2healthcheckDao.listByLoadBalancerId(loadBalancerId);
|
||||
List<LBHealthCheckPolicyVO> hcPolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, null);
|
||||
for (LBHealthCheckPolicyVO lbHealthCheck : hcPolicies) {
|
||||
lbHealthCheck.setRevoke(true);
|
||||
_lb2healthcheckDao.persist(lbHealthCheck);
|
||||
@ -2008,7 +2015,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
@Override
|
||||
public List<LbHealthCheckPolicy> getHealthCheckPolicies(long lbId) {
|
||||
List<LbHealthCheckPolicy> healthCheckPolicies = new ArrayList<LbHealthCheckPolicy>();
|
||||
List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerId(lbId);
|
||||
List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(lbId, null);
|
||||
|
||||
for (LBHealthCheckPolicyVO policy : hcDbpolicies) {
|
||||
String pingpath = policy.getpingpath();
|
||||
@ -2206,6 +2213,8 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
public List<LBStickinessPolicyVO> searchForLBStickinessPolicies(ListLBStickinessPoliciesCmd cmd) throws PermissionDeniedException {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Long loadBalancerId = cmd.getLbRuleId();
|
||||
boolean forDisplay = cmd.getDisplay();
|
||||
|
||||
LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
|
||||
if (loadBalancer == null) {
|
||||
return null;
|
||||
@ -2213,7 +2222,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
|
||||
_accountMgr.checkAccess(caller, null, loadBalancer);
|
||||
|
||||
List<LBStickinessPolicyVO> sDbpolicies = _lb2stickinesspoliciesDao.listByLoadBalancerId(cmd.getLbRuleId());
|
||||
List<LBStickinessPolicyVO> sDbpolicies = _lb2stickinesspoliciesDao.listByLoadBalancerIdAndDisplayFlag(cmd.getLbRuleId(), forDisplay);
|
||||
|
||||
return sDbpolicies;
|
||||
}
|
||||
@ -2222,12 +2231,14 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
public List<LBHealthCheckPolicyVO> searchForLBHealthCheckPolicies(ListLBHealthCheckPoliciesCmd cmd) throws PermissionDeniedException {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Long loadBalancerId = cmd.getLbRuleId();
|
||||
boolean forDisplay = cmd.getDisplay();
|
||||
|
||||
LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
|
||||
if (loadBalancer == null) {
|
||||
return null;
|
||||
}
|
||||
_accountMgr.checkAccess(caller, null, loadBalancer);
|
||||
List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerId(cmd.getLbRuleId());
|
||||
List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(cmd.getLbRuleId(), forDisplay);
|
||||
return hcDbpolicies;
|
||||
}
|
||||
|
||||
@ -2456,4 +2467,58 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
|
||||
this._lbProviders = lbProviders;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_LB_STICKINESSPOLICY_UPDATE, eventDescription = "updating lb stickiness policy", async = true)
|
||||
public StickinessPolicy updateLBStickinessPolicy(long id, String customId, Boolean forDisplay) {
|
||||
LBStickinessPolicyVO policy = _lb2stickinesspoliciesDao.findById(id);
|
||||
if (policy == null) {
|
||||
throw new InvalidParameterValueException("Fail to find stickiness policy with " + id);
|
||||
}
|
||||
|
||||
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(policy.getLoadBalancerId()));
|
||||
if (loadBalancer == null) {
|
||||
throw new InvalidParameterException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
|
||||
}
|
||||
|
||||
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, loadBalancer);
|
||||
|
||||
if (customId != null) {
|
||||
policy.setUuid(customId);
|
||||
}
|
||||
|
||||
if (forDisplay != null) {
|
||||
policy.setDisplay(forDisplay);
|
||||
}
|
||||
|
||||
_lb2stickinesspoliciesDao.update(id, policy);
|
||||
return _lb2stickinesspoliciesDao.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_LB_HEALTHCHECKPOLICY_UPDATE, eventDescription = "updating lb healthcheck policy", async = true)
|
||||
public HealthCheckPolicy updateLBHealthCheckPolicy(long id, String customId, Boolean forDisplay) {
|
||||
LBHealthCheckPolicyVO policy = _lb2healthcheckDao.findById(id);
|
||||
if (policy == null) {
|
||||
throw new InvalidParameterValueException("Fail to find stickiness policy with " + id);
|
||||
}
|
||||
|
||||
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(policy.getLoadBalancerId()));
|
||||
if (loadBalancer == null) {
|
||||
throw new InvalidParameterException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
|
||||
}
|
||||
|
||||
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, loadBalancer);
|
||||
|
||||
if (customId != null) {
|
||||
policy.setUuid(customId);
|
||||
}
|
||||
|
||||
if (forDisplay != null) {
|
||||
policy.setDisplay(forDisplay);
|
||||
}
|
||||
|
||||
_lb2healthcheckDao.update(id, policy);
|
||||
return _lb2healthcheckDao.findById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,9 +38,6 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
|
||||
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
||||
@ -346,6 +343,8 @@ import org.apache.cloudstack.api.command.user.loadbalancer.ListSslCertsCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.RemoveCertFromLoadBalancerCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.RemoveFromLoadBalancerRuleCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UpdateApplicationLoadBalancerCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UpdateLBHealthCheckPolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UpdateLBStickinessPolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UpdateLoadBalancerRuleCmd;
|
||||
import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
|
||||
import org.apache.cloudstack.api.command.user.nat.CreateIpForwardingRuleCmd;
|
||||
@ -508,6 +507,8 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.utils.identity.ManagementServerNode;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.GetVncPortAnswer;
|
||||
@ -2991,6 +2992,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
cmdList.add(CreateVPCCmdByAdmin.class);
|
||||
cmdList.add(ListVPCsCmdByAdmin.class);
|
||||
cmdList.add(UpdateVPCCmdByAdmin.class);
|
||||
cmdList.add(UpdateLBStickinessPolicyCmd.class);
|
||||
cmdList.add(UpdateLBHealthCheckPolicyCmd.class);
|
||||
|
||||
return cmdList;
|
||||
}
|
||||
|
||||
|
||||
@ -453,20 +453,20 @@ CREATE VIEW `cloud`.`user_vm_view` AS
|
||||
left join
|
||||
`cloud`.`user_vm_details` `custom_ram_size` ON (((`custom_ram_size`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_ram_size`.`name` = 'memory')));
|
||||
|
||||
-- ACL DB schema
|
||||
-- ACL DB schema
|
||||
CREATE TABLE `cloud`.`iam_group` (
|
||||
`id` bigint unsigned NOT NULL UNIQUE auto_increment,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`description` varchar(255) default NULL,
|
||||
`uuid` varchar(40),
|
||||
`path` varchar(255) NOT NULL,
|
||||
`path` varchar(255) NOT NULL,
|
||||
`account_id` bigint unsigned NOT NULL,
|
||||
`view` varchar(40) default 'User' COMMENT 'response review this group account should see for result',
|
||||
`removed` datetime COMMENT 'date the group was removed',
|
||||
`created` datetime COMMENT 'date the group was created',
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `i_iam_group__removed`(`removed`),
|
||||
CONSTRAINT `uc_iam_group__uuid` UNIQUE (`uuid`)
|
||||
CONSTRAINT `uc_iam_group__uuid` UNIQUE (`uuid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`iam_group_account_map` (
|
||||
@ -474,11 +474,11 @@ CREATE TABLE `cloud`.`iam_group_account_map` (
|
||||
`group_id` bigint unsigned NOT NULL,
|
||||
`account_id` bigint unsigned NOT NULL,
|
||||
`removed` datetime COMMENT 'date the account was removed from the group',
|
||||
`created` datetime COMMENT 'date the account was assigned to the group',
|
||||
`created` datetime COMMENT 'date the account was assigned to the group',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_iam_group_vm_map__group_id` FOREIGN KEY(`group_id`) REFERENCES `iam_group` (`id`) ON DELETE CASCADE,
|
||||
CONSTRAINT `fk_iam_group_vm_map__account_id` FOREIGN KEY(`account_id`) REFERENCES `account` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE `cloud`.`iam_policy` (
|
||||
@ -487,7 +487,7 @@ CREATE TABLE `cloud`.`iam_policy` (
|
||||
`description` varchar(255) DEFAULT NULL,
|
||||
`uuid` varchar(40) DEFAULT NULL,
|
||||
`path` varchar(255) NOT NULL,
|
||||
`account_id` bigint unsigned NOT NULL,
|
||||
`account_id` bigint unsigned NOT NULL,
|
||||
`removed` datetime DEFAULT NULL COMMENT 'date the role was removed',
|
||||
`created` datetime DEFAULT NULL COMMENT 'date the role was created',
|
||||
`policy_type` varchar(64) DEFAULT 'Static' COMMENT 'Static or Dynamic',
|
||||
@ -1662,3 +1662,8 @@ CREATE TABLE `cloud`.`network_acl_item_cidrs` (
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_network_acl_item_id` FOREIGN KEY `fk_network_acl_item_id`(`network_acl_item_id`) REFERENCES `network_acl_item`(`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
ALTER TABLE `cloud`.`load_balancer_healthcheck_policies` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the policy can be displayed to the end user';
|
||||
ALTER TABLE `cloud`.`load_balancer_stickiness_policies` ADD COLUMN `display` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'True if the policy can be displayed to the end user';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user