mirror of https://github.com/apache/cloudstack.git
BUG: CS-16209. AutoScale. Supporting network element independent counter parameters in AutoScaleVmProfile.
Reviewed-By: Devdeep, Rajesh B.
This commit is contained in:
parent
e0fd1a26d0
commit
c3232cff8d
|
|
@ -281,8 +281,7 @@ public class LoadBalancerTO implements Serializable {
|
|||
private final String serviceOfferingId;
|
||||
private final String templateId;
|
||||
private final String otherDeployParams;
|
||||
private final String snmpCommunity;
|
||||
private final Integer snmpPort;
|
||||
private final List<Pair<String, String>> counterParamList;
|
||||
private final Integer destroyVmGraceperiod;
|
||||
private final String cloudStackApiUrl;
|
||||
private final String autoScaleUserApiKey;
|
||||
|
|
@ -291,14 +290,13 @@ public class LoadBalancerTO implements Serializable {
|
|||
private final String networkId;
|
||||
|
||||
public AutoScaleVmProfileTO(String zoneId, String domainId, String cloudStackApiUrl, String autoScaleUserApiKey, String autoScaleUserSecretKey, String serviceOfferingId,
|
||||
String templateId, String vmName, String networkId, String otherDeployParams, String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod) {
|
||||
String templateId, String vmName, String networkId, String otherDeployParams, List<Pair<String, String>> counterParamList, Integer destroyVmGraceperiod) {
|
||||
this.zoneId = zoneId;
|
||||
this.domainId = domainId;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.templateId = templateId;
|
||||
this.otherDeployParams = otherDeployParams;
|
||||
this.snmpCommunity = snmpCommunity;
|
||||
this.snmpPort = snmpPort;
|
||||
this.counterParamList = counterParamList;
|
||||
this.destroyVmGraceperiod = destroyVmGraceperiod;
|
||||
this.cloudStackApiUrl = cloudStackApiUrl;
|
||||
this.autoScaleUserApiKey = autoScaleUserApiKey;
|
||||
|
|
@ -327,12 +325,8 @@ public class LoadBalancerTO implements Serializable {
|
|||
return otherDeployParams;
|
||||
}
|
||||
|
||||
public String getSnmpCommunity() {
|
||||
return snmpCommunity;
|
||||
}
|
||||
|
||||
public Integer getSnmpPort() {
|
||||
return snmpPort;
|
||||
public List<Pair<String, String>> getCounterParamList() {
|
||||
return counterParamList;
|
||||
}
|
||||
|
||||
public Integer getDestroyVmGraceperiod() {
|
||||
|
|
@ -446,8 +440,8 @@ public class LoadBalancerTO implements Serializable {
|
|||
AutoScaleVmProfileTO autoScaleVmProfileTO = new AutoScaleVmProfileTO(lbAutoScaleVmProfile.getZoneId(), lbAutoScaleVmProfile.getDomainId(),
|
||||
lbAutoScaleVmProfile.getCsUrl(), lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(),
|
||||
lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(), lbAutoScaleVmProfile.getVmName(),
|
||||
lbAutoScaleVmProfile.getNetworkId(),autoScaleVmProfile.getOtherDeployParams(), autoScaleVmProfile.getSnmpCommunity(),
|
||||
autoScaleVmProfile.getSnmpPort(), autoScaleVmProfile.getDestroyVmGraceperiod());
|
||||
lbAutoScaleVmProfile.getNetworkId(),autoScaleVmProfile.getOtherDeployParams(), autoScaleVmProfile.getCounterParams(),
|
||||
autoScaleVmProfile.getDestroyVmGraceperiod());
|
||||
|
||||
AutoScaleVmGroup autoScaleVmGroup = lbAutoScaleVmGroup.getVmGroup();
|
||||
autoScaleVmGroupTO = new AutoScaleVmGroupTO(autoScaleVmGroup.getUuid(), autoScaleVmGroup.getMinMembers(), autoScaleVmGroup.getMaxMembers(), autoScaleVmGroup.getMemberPort(),
|
||||
|
|
|
|||
|
|
@ -383,8 +383,6 @@ public class ApiConstants {
|
|||
public static final String AGGR_VALUE = "aggrvalue";
|
||||
public static final String THRESHOLD = "threshold";
|
||||
public static final String RELATIONAL_OPERATOR = "relationaloperator";
|
||||
public static final String SNMP_COMMUNITY = "snmpcommunity";
|
||||
public static final String SNMP_PORT = "snmpport";
|
||||
public static final String OTHER_DEPLOY_PARAMS = "otherdeployparams";
|
||||
public static final String MIN_MEMBERS = "minmembers";
|
||||
public static final String MAX_MEMBERS = "maxmembers";
|
||||
|
|
@ -401,6 +399,7 @@ public class ApiConstants {
|
|||
public static final String ACTION = "action";
|
||||
public static final String CONDITION_ID = "conditionid";
|
||||
public static final String CONDITION_IDS = "conditionids";
|
||||
public static final String COUNTERPARAM_LIST = "counterparam";
|
||||
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
|
||||
|
||||
public enum HostDetails {
|
||||
|
|
@ -410,7 +409,7 @@ public class ApiConstants {
|
|||
public enum VMDetails {
|
||||
all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min;
|
||||
}
|
||||
|
||||
|
||||
public enum VolumeDetails {
|
||||
all, vm, account, storage_type, disk_offering, min;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.user.User;
|
|||
import com.cloud.user.UserContext;
|
||||
|
||||
@Implementation(description = "Creates a profile that contains information about the virtual machine which will be provisioned automatically by autoscale feature.", responseObject = AutoScaleVmProfileResponse.class)
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateAutoScaleVmProfileCmd.class.getName());
|
||||
|
||||
|
|
@ -62,11 +63,8 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name = ApiConstants.AUTOSCALE_VM_DESTROY_TIME, type = CommandType.INTEGER, description = "the time allowed for existing connections to get closed before a vm is destroyed")
|
||||
private Integer destroyVmGraceperiod;
|
||||
|
||||
@Parameter(name = ApiConstants.SNMP_COMMUNITY, type = CommandType.STRING, description = "snmp community string to be used to contact a virtual machine deployed by this profile")
|
||||
private String snmpCommunity;
|
||||
|
||||
@Parameter(name = ApiConstants.SNMP_PORT, type = CommandType.INTEGER, description = "port at which snmp agent is listening in a virtual machine deployed by this profile")
|
||||
private Integer snmpPort;
|
||||
@Parameter(name = ApiConstants.COUNTERPARAM_LIST, type = CommandType.MAP, description = "counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161")
|
||||
private Map counterParamList;
|
||||
|
||||
@IdentityMapper(entityTableName = "user")
|
||||
@Parameter(name = ApiConstants.AUTOSCALE_USER_ID, type = CommandType.LONG, description = "the ID of the user used to launch and destroy the VMs")
|
||||
|
|
@ -105,12 +103,8 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
return templateId;
|
||||
}
|
||||
|
||||
public Integer getSnmpPort() {
|
||||
return snmpPort;
|
||||
}
|
||||
|
||||
public String getSnmpCommunity() {
|
||||
return snmpCommunity;
|
||||
public Map getCounterParamList() {
|
||||
return counterParamList;
|
||||
}
|
||||
|
||||
public String getOtherDeployParams() {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
|
|
@ -54,11 +56,8 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
|
|||
@Parameter(name = ApiConstants.AUTOSCALE_VM_DESTROY_TIME, type = CommandType.INTEGER, description = "the time allowed for existing connections to get closed before a vm is destroyed")
|
||||
private Integer destroyVmGraceperiod;
|
||||
|
||||
@Parameter(name = ApiConstants.SNMP_COMMUNITY, type = CommandType.STRING, description = "snmp community string to be used to contact a virtual machine deployed by this profile")
|
||||
private String snmpCommunity;
|
||||
|
||||
@Parameter(name = ApiConstants.SNMP_PORT, type = CommandType.INTEGER, description = "port at which snmp agent is listening in a virtual machine deployed by this profile")
|
||||
private Integer snmpPort;
|
||||
@Parameter(name = ApiConstants.COUNTERPARAM_LIST, type = CommandType.MAP, description = "counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161")
|
||||
private Map counterParamList;
|
||||
|
||||
@IdentityMapper(entityTableName = "user")
|
||||
@Parameter(name = ApiConstants.AUTOSCALE_USER_ID, type = CommandType.LONG, description = "the ID of the user used to launch and destroy the VMs")
|
||||
|
|
@ -93,12 +92,8 @@ public class UpdateAutoScaleVmProfileCmd extends BaseAsyncCmd {
|
|||
return templateId;
|
||||
}
|
||||
|
||||
public Integer getSnmpPort() {
|
||||
return snmpPort;
|
||||
}
|
||||
|
||||
public String getSnmpCommunity() {
|
||||
return snmpCommunity;
|
||||
public Map getCounterParamList() {
|
||||
return counterParamList;
|
||||
}
|
||||
|
||||
public Long getAutoscaleUserId() {
|
||||
|
|
|
|||
|
|
@ -8,15 +8,20 @@
|
|||
// 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 com.cloud.api.response;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class AutoScaleVmProfileResponse extends BaseResponse implements ControlledEntityResponse {
|
||||
|
|
@ -48,13 +53,9 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
|
|||
private Integer destroyVmGraceperiod;
|
||||
|
||||
/* Parameters related to a running virtual machine - monitoring aspects */
|
||||
@SerializedName(ApiConstants.SNMP_COMMUNITY)
|
||||
@Param(description = "snmp community string to be used to contact a virtual machine deployed by this profile")
|
||||
private String snmpCommunity;
|
||||
|
||||
@SerializedName(ApiConstants.SNMP_PORT)
|
||||
@Param(description = "port at which the snmp agent is listening in a virtual machine deployed by this profile")
|
||||
private Integer snmpPort;
|
||||
@SerializedName(ApiConstants.COUNTERPARAM_LIST)
|
||||
@Parameter(name = ApiConstants.COUNTERPARAM_LIST, type = CommandType.MAP, description = "counterparam list. Example: counterparam[0].name=snmpcommunity&counterparam[0].value=public&counterparam[1].name=snmpport&counterparam[1].value=161")
|
||||
private Map<String, String> counterParams;
|
||||
|
||||
@SerializedName(ApiConstants.AUTOSCALE_USER_ID)
|
||||
@Param(description = "the ID of the user used to launch and destroy the VMs")
|
||||
|
|
@ -107,12 +108,13 @@ public class AutoScaleVmProfileResponse extends BaseResponse implements Controll
|
|||
this.otherDeployParams = otherDeployParams;
|
||||
}
|
||||
|
||||
public void setSnmpCommunity(String snmpCommunity) {
|
||||
this.snmpCommunity = snmpCommunity;
|
||||
}
|
||||
|
||||
public void setSnmpPort(Integer snmpPort) {
|
||||
this.snmpPort = snmpPort;
|
||||
public void setCounterParams(List<Pair<String, String>> counterParams) {
|
||||
this.counterParams = new HashMap<String, String>();
|
||||
for(Pair<String,String> paramKV :counterParams){
|
||||
String key = paramKV.first();
|
||||
String value = paramKV.second();
|
||||
this.counterParams.put(key,value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,117 @@
|
|||
// 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 com.cloud.network.as;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
public class AutoScaleCounter {
|
||||
public static class AutoScaleCounterType {
|
||||
private String _name;
|
||||
|
||||
public static final AutoScaleCounterType Snmp = new AutoScaleCounterType("snmp");
|
||||
public static final AutoScaleCounterType Netscaler = new AutoScaleCounterType("netscaler");
|
||||
public AutoScaleCounterType(String name) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoScaleCounterParam {
|
||||
@SerializedName("paramname")
|
||||
private String _paramName;
|
||||
|
||||
@SerializedName("required")
|
||||
private Boolean _required;
|
||||
|
||||
@SerializedName("isflag")
|
||||
private Boolean _isFlag;
|
||||
|
||||
@SerializedName("description")
|
||||
private String _description;
|
||||
|
||||
public AutoScaleCounterParam(String name, Boolean required,
|
||||
String description, Boolean flag) {
|
||||
this._paramName = name;
|
||||
this._required = required;
|
||||
this._description = description;
|
||||
this._isFlag = flag;
|
||||
}
|
||||
|
||||
public String getParamName() {
|
||||
return _paramName;
|
||||
}
|
||||
|
||||
public void setParamName(String paramName) {
|
||||
this._paramName = paramName;
|
||||
}
|
||||
|
||||
public Boolean getIsflag() {
|
||||
return _isFlag;
|
||||
}
|
||||
|
||||
public void setIsflag(Boolean isFlag) {
|
||||
this._isFlag = isFlag;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return _required;
|
||||
}
|
||||
|
||||
public void setRequired(Boolean required) {
|
||||
this._required = required;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return _description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this._description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("methodname")
|
||||
private String _counterName;
|
||||
|
||||
@SerializedName("paramlist")
|
||||
private List<AutoScaleCounterParam> _paramList;
|
||||
|
||||
public AutoScaleCounter(AutoScaleCounterType methodType) {
|
||||
this._counterName = methodType.getName();
|
||||
this._paramList = new ArrayList<AutoScaleCounterParam>(1);
|
||||
}
|
||||
|
||||
public void addParam(String name, Boolean required, String description, Boolean isFlag) {
|
||||
AutoScaleCounterParam param = new AutoScaleCounterParam(name,required, description, isFlag);
|
||||
_paramList.add(param);
|
||||
return;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return _counterName;
|
||||
}
|
||||
|
||||
public List<AutoScaleCounterParam> getParamList() {
|
||||
return _paramList;
|
||||
}
|
||||
|
||||
public void setParamList(List<AutoScaleCounterParam> paramList) {
|
||||
this._paramList = paramList;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,10 @@
|
|||
//
|
||||
package com.cloud.network.as;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.acl.ControlledEntity;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
/**
|
||||
* AutoScaleVmProfile
|
||||
|
|
@ -28,11 +31,10 @@ public interface AutoScaleVmProfile extends ControlledEntity {
|
|||
|
||||
public String getOtherDeployParams();
|
||||
|
||||
public String getSnmpCommunity();
|
||||
|
||||
public Integer getSnmpPort();
|
||||
List<Pair<String, String>> getCounterParams();
|
||||
|
||||
public Integer getDestroyVmGraceperiod();
|
||||
|
||||
public long getAutoScaleUserId();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class NitroError {
|
|||
|
||||
public class NetscalerResource implements ServerResource {
|
||||
|
||||
public final static int DEFAULT_SNMP_PORT = 161;
|
||||
// deployment configuration
|
||||
private String _name;
|
||||
private String _zoneId;
|
||||
|
|
@ -1624,10 +1625,21 @@ public class NetscalerResource implements ServerResource {
|
|||
AutoScaleVmProfileTO profileTO = vmGroupTO.getProfile();
|
||||
List<AutoScalePolicyTO> policies = vmGroupTO.getPolicies();
|
||||
int interval = vmGroupTO.getInterval();
|
||||
int snmpPort = profileTO.getSnmpPort();
|
||||
String snmpCommunity = profileTO.getSnmpCommunity();
|
||||
List<Pair<String, String>> counterParams = profileTO.getCounterParamList();
|
||||
String snmpCommunity = null;
|
||||
int snmpPort = DEFAULT_SNMP_PORT;
|
||||
long cur_prirotiy = 1;
|
||||
|
||||
// get the session persistence parameters
|
||||
List<Pair<String, String>> paramsList = profileTO.getCounterParamList();
|
||||
for(Pair<String,String> param : paramsList) {
|
||||
if ("snmpcommunity".equalsIgnoreCase(param.first())) {
|
||||
snmpCommunity = param.second();
|
||||
} else if ("snmpport".equalsIgnoreCase(param.first())) {
|
||||
snmpPort = Integer.parseInt(param.second());
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Set min and max autoscale members;
|
||||
|
|
@ -1654,7 +1666,7 @@ public class NetscalerResource implements ServerResource {
|
|||
String secretKey = profileTO.getAutoScaleUserSecretKey();
|
||||
String url = profileTO.getCloudStackApiUrl();
|
||||
|
||||
com.citrix.netscaler.nitro.resource.config.autoscale.autoscaleprofile autoscaleProfile = new com.citrix.netscaler.nitro.resource.config.autoscale.autoscaleprofile();
|
||||
autoscaleprofile autoscaleProfile = new autoscaleprofile();
|
||||
try {
|
||||
autoscaleProfile.set_name(profileName);
|
||||
autoscaleProfile.set_type("CLOUDSTACK");
|
||||
|
|
@ -1995,7 +2007,7 @@ public class NetscalerResource implements ServerResource {
|
|||
}
|
||||
|
||||
// Delete AutoScale Profile
|
||||
com.citrix.netscaler.nitro.resource.config.autoscale.autoscaleprofile autoscaleProfile = new com.citrix.netscaler.nitro.resource.config.autoscale.autoscaleprofile();
|
||||
autoscaleprofile autoscaleProfile = new autoscaleprofile();
|
||||
try {
|
||||
autoscaleProfile.set_name(profileName);
|
||||
autoscaleProfile.delete(_netscalerService, autoscaleProfile);
|
||||
|
|
|
|||
|
|
@ -3841,8 +3841,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
response.setServiceOfferingId(profile.getServiceOfferingId());
|
||||
response.setTemplateId(profile.getTemplateId());
|
||||
response.setOtherDeployParams(profile.getOtherDeployParams());
|
||||
response.setSnmpCommunity(profile.getSnmpCommunity());
|
||||
response.setSnmpPort(profile.getSnmpPort());
|
||||
response.setCounterParams(profile.getCounterParams());
|
||||
response.setDestroyVmGraceperiod(profile.getDestroyVmGraceperiod());
|
||||
response.setAutoscaleUserId(profile.getAutoScaleUserId());
|
||||
response.setObjectName("autoscalevmprofile");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ package com.cloud.network.as;
|
|||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -55,6 +54,7 @@ import com.cloud.exception.ResourceInUseException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.LoadBalancerVO;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.as.AutoScaleCounter.AutoScaleCounterParam;
|
||||
import com.cloud.network.as.dao.AutoScalePolicyConditionMapDao;
|
||||
import com.cloud.network.as.dao.AutoScalePolicyDao;
|
||||
import com.cloud.network.as.dao.AutoScaleVmGroupDao;
|
||||
|
|
@ -78,6 +78,7 @@ import com.cloud.user.UserContext;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
|
@ -90,6 +91,8 @@ import com.cloud.utils.db.SearchCriteria;
|
|||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@Local(value = { AutoScaleService.class, AutoScaleManager.class })
|
||||
public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleService, Manager {
|
||||
|
|
@ -156,25 +159,51 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleSe
|
|||
return _name;
|
||||
}
|
||||
|
||||
public List<String> getSupportedAutoScaleCounters(long networkid)
|
||||
public List<AutoScaleCounter> getSupportedAutoScaleCounters(long networkid)
|
||||
{
|
||||
String autoScaleCapability = _lbRulesMgr.getLBCapability(networkid, Capability.AutoScaleCounters.getName());
|
||||
if (autoScaleCapability == null || autoScaleCapability.length() == 0) {
|
||||
String capability = _lbRulesMgr.getLBCapability(networkid, Capability.AutoScaleCounters.getName());
|
||||
if (capability == null) {
|
||||
return null;
|
||||
}
|
||||
return Arrays.asList(autoScaleCapability.split(","));
|
||||
Gson gson = new Gson();
|
||||
java.lang.reflect.Type listType = new TypeToken<List<AutoScaleCounter>>() {
|
||||
}.getType();
|
||||
List<AutoScaleCounter> result = gson.fromJson(capability, listType);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void validateAutoScaleCounters(long networkid, List<Counter> counters)
|
||||
{
|
||||
List<String> supportedCounters = getSupportedAutoScaleCounters(networkid);
|
||||
public void validateAutoScaleCounters(long networkid, List<Counter> counters, List<Pair<String, String>> counterParamPassed) {
|
||||
List<AutoScaleCounter> supportedCounters = getSupportedAutoScaleCounters(networkid);
|
||||
if (supportedCounters == null) {
|
||||
throw new InvalidParameterException("AutoScale is not supported in the network");
|
||||
}
|
||||
for (Counter counter : counters) {
|
||||
if (!supportedCounters.contains(counter.getSource().name().toString())) {
|
||||
throw new InvalidParameterException("AutoScale counter with source='" + counter.getSource() + "' is not supported " +
|
||||
"in the network where lb is configured");
|
||||
String counterName = counter.getSource().name().toString();
|
||||
boolean isCounterSupported = false;
|
||||
for (AutoScaleCounter autoScaleCounter : supportedCounters) {
|
||||
if(autoScaleCounter.getName().equals(counterName)) {
|
||||
isCounterSupported = true;
|
||||
List<AutoScaleCounterParam> counterParams = autoScaleCounter.getParamList();
|
||||
for (AutoScaleCounterParam autoScaleCounterParam : counterParams) {
|
||||
boolean isRequiredParameter = autoScaleCounterParam.getRequired();
|
||||
if(isRequiredParameter) {
|
||||
boolean isRequiredParamPresent = false;
|
||||
for (Pair<String, String> pair : counterParamPassed) {
|
||||
if(pair.first().equals(autoScaleCounterParam.getParamName()))
|
||||
isRequiredParamPresent = true;
|
||||
|
||||
}
|
||||
if(!isRequiredParamPresent) {
|
||||
throw new InvalidParameterException("Parameter " + autoScaleCounterParam.getParamName() + " has to be set in AutoScaleVmProfile's "
|
||||
+ ApiConstants.COUNTERPARAM_LIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isCounterSupported) {
|
||||
throw new InvalidParameterException("AutoScale counter with source='" + counter.getSource().name() + "' is not supported " +
|
||||
"in the network");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -329,8 +358,9 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleSe
|
|||
autoscaleUserId = UserContext.current().getCallerUserId();
|
||||
}
|
||||
|
||||
// TODO: Donot checkin
|
||||
AutoScaleVmProfileVO profileVO = new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
|
||||
cmd.getSnmpCommunity(), cmd.getSnmpPort(), cmd.getDestroyVmGraceperiod(), autoscaleUserId);
|
||||
cmd.getCounterParamList(), cmd.getDestroyVmGraceperiod(), autoscaleUserId);
|
||||
profileVO = checkValidityAndPersist(profileVO);
|
||||
s_logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId());
|
||||
|
||||
|
|
@ -343,8 +373,8 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleSe
|
|||
Long profileId = cmd.getId();
|
||||
Long templateId = cmd.getTemplateId();
|
||||
Long autoscaleUserId = cmd.getAutoscaleUserId();
|
||||
Integer snmpPort = cmd.getSnmpPort();
|
||||
String snmpCommunity = cmd.getSnmpCommunity();
|
||||
Map counterParamList = cmd.getCounterParamList();
|
||||
|
||||
Integer destroyVmGraceperiod = cmd.getDestroyVmGraceperiod();
|
||||
|
||||
AutoScaleVmProfileVO vmProfile = getEntityInDatabase(UserContext.current().getCaller(), "Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
|
||||
|
|
@ -357,12 +387,8 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleSe
|
|||
vmProfile.setAutoscaleUserId(autoscaleUserId);
|
||||
}
|
||||
|
||||
if (snmpCommunity != null) {
|
||||
vmProfile.setSnmpCommunity(snmpCommunity);
|
||||
}
|
||||
|
||||
if (snmpPort != null) {
|
||||
vmProfile.setSnmpPort(snmpPort);
|
||||
if (counterParamList != null) {
|
||||
vmProfile.setCounterParams(counterParamList);
|
||||
}
|
||||
|
||||
if (destroyVmGraceperiod != null) {
|
||||
|
|
@ -876,11 +902,11 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleManager, AutoScaleSe
|
|||
getAutoScalePolicies("scaledownpolicyid", bakupScaleDownPolicyIds, counters, interval, true);
|
||||
policyIds.addAll(bakupScaleDownPolicyIds);
|
||||
}
|
||||
AutoScaleVmProfileVO profileVO = getEntityInDatabase(UserContext.current().getCaller(), ApiConstants.VMPROFILE_ID, vmGroup.getProfileId(), _autoScaleVmProfileDao);
|
||||
|
||||
LoadBalancerVO loadBalancer = getEntityInDatabase(UserContext.current().getCaller(), ApiConstants.LBID, vmGroup.getLoadBalancerId(), _lbDao);
|
||||
validateAutoScaleCounters(loadBalancer.getNetworkId(), counters);
|
||||
validateAutoScaleCounters(loadBalancer.getNetworkId(), counters, profileVO.getCounterParams());
|
||||
|
||||
AutoScaleVmProfileVO profileVO = getEntityInDatabase(UserContext.current().getCaller(), ApiConstants.VMPROFILE_ID, vmGroup.getProfileId(), _autoScaleVmProfileDao);
|
||||
|
||||
ControlledEntity[] sameOwnerEntities = policies.toArray(new ControlledEntity[policies.size() + 2]);
|
||||
sameOwnerEntities[sameOwnerEntities.length - 2] = loadBalancer;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,12 @@
|
|||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.network.as;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -25,6 +30,7 @@ import javax.persistence.InheritanceType;
|
|||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
|
|
@ -65,11 +71,8 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
@Column(name = "destroy_vm_grace_period", updatable = true)
|
||||
private Integer destroyVmGraceperiod = NetUtils.DEFAULT_AUTOSCALE_VM_DESTROY_TIME;
|
||||
|
||||
@Column(name = "snmp_community", updatable = true)
|
||||
private String snmpCommunity = NetUtils.DEFAULT_SNMP_COMMUNITY;
|
||||
|
||||
@Column(name = "snmp_port", updatable = true)
|
||||
private Integer snmpPort = NetUtils.DEFAULT_SNMP_PORT;
|
||||
@Column(name = "counter_params", updatable = true)
|
||||
private String counterParams;
|
||||
|
||||
@Column(name = GenericDao.REMOVED_COLUMN)
|
||||
protected Date removed;
|
||||
|
|
@ -80,7 +83,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
public AutoScaleVmProfileVO() {
|
||||
}
|
||||
|
||||
public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod,
|
||||
public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, Map counterParamList, Integer destroyVmGraceperiod,
|
||||
long autoscaleUserId) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.zoneId = zoneId;
|
||||
|
|
@ -93,12 +96,8 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
if (destroyVmGraceperiod != null) {
|
||||
this.destroyVmGraceperiod = destroyVmGraceperiod;
|
||||
}
|
||||
if (snmpCommunity != null) {
|
||||
this.snmpCommunity = snmpCommunity;
|
||||
}
|
||||
if (snmpPort != null) {
|
||||
this.snmpPort = snmpPort;
|
||||
}
|
||||
setCounterParams(counterParamList);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -130,21 +129,36 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSnmpCommunity() {
|
||||
return snmpCommunity;
|
||||
public List<Pair<String, String>> getCounterParams() {
|
||||
List<Pair<String, String>> paramsList = new ArrayList<Pair<String, String>>();
|
||||
if(counterParams != null)
|
||||
{
|
||||
String[] params = counterParams.split("[=&]");
|
||||
for (int i = 0; i < (params.length - 1); i = i + 2) {
|
||||
paramsList.add(new Pair<String, String>(params[i], params[i + 1]));
|
||||
}
|
||||
}
|
||||
return paramsList;
|
||||
}
|
||||
|
||||
public void setSnmpCommunity(String snmpCommunity) {
|
||||
this.snmpCommunity = snmpCommunity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSnmpPort() {
|
||||
return snmpPort;
|
||||
}
|
||||
|
||||
public void setSnmpPort(Integer snmpPort) {
|
||||
this.snmpPort = snmpPort;
|
||||
public void setCounterParams(Map counterParamList) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
boolean isFirstParam = true;
|
||||
if (counterParamList != null) {
|
||||
Iterator<HashMap<String, String>> iter = counterParamList.values().iterator();
|
||||
while (iter.hasNext()) {
|
||||
HashMap<String, String> paramKVpair = iter.next();
|
||||
if(!isFirstParam) {
|
||||
sb.append("&");
|
||||
}
|
||||
String paramName = paramKVpair.get("name");
|
||||
String paramValue = paramKVpair.get("value");
|
||||
sb.append(paramName + "=" + paramValue);
|
||||
isFirstParam = false;
|
||||
}
|
||||
}
|
||||
counterParams = sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
||||
import com.cloud.network.PhysicalNetworkVO;
|
||||
import com.cloud.network.PublicIpAddress;
|
||||
import com.cloud.network.as.AutoScaleCounter;
|
||||
import com.cloud.network.as.AutoScaleCounter.AutoScaleCounterType;
|
||||
import com.cloud.network.dao.ExternalLoadBalancerDeviceDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkExternalLoadBalancerDao;
|
||||
|
|
@ -99,7 +101,7 @@ import com.google.gson.Gson;
|
|||
|
||||
@Local(value = NetworkElement.class)
|
||||
public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl implements LoadBalancingServiceProvider, NetscalerLoadBalancerElementService, ExternalLoadBalancerDeviceManager, IpDeployer,
|
||||
StaticNatServiceProvider {
|
||||
StaticNatServiceProvider {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(NetscalerElement.class);
|
||||
|
||||
|
|
@ -150,7 +152,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
|
||||
@Override
|
||||
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException {
|
||||
InsufficientNetworkCapacityException {
|
||||
|
||||
if (!canHandle(guestConfig, Service.Lb)) {
|
||||
return false;
|
||||
|
|
@ -176,7 +178,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
|
||||
@Override
|
||||
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
||||
InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
InsufficientNetworkCapacityException, ResourceUnavailableException {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -249,8 +251,20 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
// Specifies that load balancing rules can only be made with public IPs that aren't source NAT IPs
|
||||
lbCapabilities.put(Capability.LoadBalancingSupportedIps, "additional");
|
||||
|
||||
// Specifies that load balancing rules can support autoscaling
|
||||
lbCapabilities.put(Capability.AutoScaleCounters, "snmp,netscaler");
|
||||
// Specifies that load balancing rules can support autoscaling and the list of counters it supports
|
||||
AutoScaleCounter counter;
|
||||
List<AutoScaleCounter> counterList = new ArrayList<AutoScaleCounter>();
|
||||
counter = new AutoScaleCounter(AutoScaleCounterType.Snmp);
|
||||
counterList.add(counter);
|
||||
counter.addParam("snmpcommunity", true, "the community string that has to be used to do a SNMP GET on the AutoScaled Vm", false);
|
||||
counter.addParam("snmpport", false, "the port at which SNMP agent is running on the AutoScaled Vm", false);
|
||||
|
||||
counter = new AutoScaleCounter(AutoScaleCounterType.Netscaler);
|
||||
counterList.add(counter);
|
||||
|
||||
Gson gson = new Gson();
|
||||
String autoScaleCounterList = gson.toJson(counterList);
|
||||
lbCapabilities.put(Capability.AutoScaleCounters, autoScaleCounterList);
|
||||
|
||||
LbStickinessMethod method;
|
||||
List<LbStickinessMethod> methodList = new ArrayList<LbStickinessMethod>();
|
||||
|
|
@ -266,7 +280,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
methodList.add(method);
|
||||
method.addParam("holdtime", false, "time period for which persistence is in effect.", false);
|
||||
|
||||
Gson gson = new Gson();
|
||||
gson = new Gson();
|
||||
String stickyMethodList = gson.toJson(methodList);
|
||||
lbCapabilities.put(Capability.SupportedStickinessMethods, stickyMethodList);
|
||||
|
||||
|
|
@ -523,7 +537,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
|
|||
|
||||
@Override
|
||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
ResourceUnavailableException {
|
||||
// TODO reset the configuration on all of the netscaler devices in this physical network
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1432,14 +1432,6 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
return loadBalancerInstances;
|
||||
}
|
||||
|
||||
public List<String> getSupportedAutoScaleCounters(long networkid)
|
||||
{
|
||||
String capability = getLBCapability(networkid, Capability.AutoScaleCounters.getName());
|
||||
if (capability == null || capability.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
return Arrays.asList(capability.split(","));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LbStickinessMethod> getStickinessMethods(long networkid)
|
||||
|
|
|
|||
|
|
@ -2382,8 +2382,7 @@ CREATE TABLE `cloud`.`autoscale_vmprofiles` (
|
|||
`template_id` bigint unsigned NOT NULL,
|
||||
`other_deploy_params` varchar(1024) COMMENT 'other deployment parameters that is in addition to zoneid,serviceofferingid,domainid',
|
||||
`destroy_vm_grace_period` int unsigned COMMENT 'the time allowed for existing connections to get closed before a vm is destroyed',
|
||||
`snmp_community` varchar(255) COMMENT 'the community string to be used to reach out to the VM deployed by this profile',
|
||||
`snmp_port` int unsigned COMMENT 'the snmp port to be used to reach out to the VM deployed by this profile',
|
||||
`counter_params` varchar(1024) COMMENT 'the parameters for the counter to be used to get metric information from VMs',
|
||||
`created` datetime NOT NULL COMMENT 'date created',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
|
|||
|
|
@ -216,8 +216,7 @@ CREATE TABLE `cloud`.`autoscale_vmprofiles` (
|
|||
`template_id` bigint unsigned NOT NULL,
|
||||
`other_deploy_params` varchar(1024) COMMENT 'other deployment parameters that is in addition to zoneid,serviceofferingid,domainid',
|
||||
`destroy_vm_grace_period` int unsigned COMMENT 'the time allowed for existing connections to get closed before a vm is destroyed',
|
||||
`snmp_community` varchar(255) COMMENT 'the community string to be used to reach out to the VM deployed by this profile',
|
||||
`snmp_port` int unsigned COMMENT 'the snmp port to be used to reach out to the VM deployed by this profile',
|
||||
`counter_params` varchar(1024) COMMENT 'the parameters for the counter to be used to get metric information from VMs',
|
||||
`created` datetime NOT NULL COMMENT 'date created',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
// 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 com.cloud.utils.net;
|
||||
|
||||
|
|
@ -55,9 +55,6 @@ public class NetUtils {
|
|||
|
||||
public final static String ALL_CIDRS = "0.0.0.0/0";
|
||||
|
||||
public final static String DEFAULT_SNMP_COMMUNITY = "public";
|
||||
public final static int DEFAULT_SNMP_PORT = 161;
|
||||
|
||||
public final static int DEFAULT_AUTOSCALE_VM_DESTROY_TIME = 2 * 60; // Grace period before Vm is destroyed
|
||||
public final static int DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME = 30;
|
||||
public final static int DEFAULT_AUTOSCALE_POLICY_QUIET_TIME = 5 * 60;
|
||||
|
|
@ -159,7 +156,7 @@ public class NetUtils {
|
|||
try {
|
||||
Process result = Runtime.getRuntime().exec("route print -4");
|
||||
BufferedReader output = new BufferedReader
|
||||
(new InputStreamReader(result.getInputStream()));
|
||||
(new InputStreamReader(result.getInputStream()));
|
||||
|
||||
String line = output.readLine();
|
||||
while(line != null){
|
||||
|
|
@ -169,8 +166,8 @@ public class NetUtils {
|
|||
}
|
||||
line = output.readLine();
|
||||
}
|
||||
} catch( Exception e ) {
|
||||
}
|
||||
} catch( Exception e ) {
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
NetworkInterface nic = null;
|
||||
|
|
@ -741,7 +738,7 @@ public class NetUtils {
|
|||
long result = ipAddr | (~subnet);
|
||||
return long2Ip(result);
|
||||
}
|
||||
|
||||
|
||||
public static String getCidrSubNet(String ip, long cidrSize) {
|
||||
long numericNetmask = (0xffffffff >> (32 - cidrSize)) << (32 - cidrSize);
|
||||
String netmask = NetUtils.long2Ip(numericNetmask);
|
||||
|
|
@ -793,7 +790,7 @@ public class NetUtils {
|
|||
long shift = 32 - cidrBLong[1];
|
||||
return ((cidrALong[0] >> shift) == (cidrBLong[0] >> shift));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isNetworksOverlap(String cidrA, String cidrB) {
|
||||
Long[] cidrALong = cidrToLong(cidrA);
|
||||
Long[] cidrBLong = cidrToLong(cidrB);
|
||||
|
|
@ -1096,7 +1093,7 @@ public class NetUtils {
|
|||
if (instanceName.contains("-") || instanceName.contains(" ") || instanceName.contains("+")) {
|
||||
s_logger.warn("Instance name can not contain hyphen, spaces and \"+\" char");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1144,7 +1141,7 @@ public class NetUtils {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean validateIcmpType(long icmpType) {
|
||||
//Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html
|
||||
if(!(icmpType >=0 && icmpType <=255)) {
|
||||
|
|
@ -1153,15 +1150,15 @@ public class NetUtils {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean validateIcmpCode(long icmpCode) {
|
||||
|
||||
|
||||
//Source - http://www.erg.abdn.ac.uk/~gorry/course/inet-pages/icmp-code.html
|
||||
if(!(icmpCode >=0 && icmpCode <=15)) {
|
||||
s_logger.warn("Icmp code should be within 0-15 range");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue