mirror of https://github.com/apache/cloudstack.git
Added csurl as param in CreateAutoScaleVmProfileCmd
This commit is contained in:
parent
fa9282add1
commit
8bbc8ee0ec
|
|
@ -12,7 +12,6 @@
|
|||
// Automatically generated by addcopyright.py at 04/03/2012
|
||||
package com.cloud.agent.api.to;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -29,7 +28,6 @@ import com.cloud.network.lb.LoadBalancingRule.LbDestination;
|
|||
import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
|
||||
public class LoadBalancerTO {
|
||||
Long id;
|
||||
String srcIp;
|
||||
|
|
@ -43,7 +41,7 @@ public class LoadBalancerTO {
|
|||
private AutoScaleVmGroupTO autoScaleVmGroupTO;
|
||||
final static int MAX_STICKINESS_POLICIES = 1;
|
||||
|
||||
public LoadBalancerTO (Long id, String srcIp, int srcPort, String protocol, String algorithm, boolean revoked, boolean alreadyAdded, List<LbDestination> destinations) {
|
||||
public LoadBalancerTO(Long id, String srcIp, int srcPort, String protocol, String algorithm, boolean revoked, boolean alreadyAdded, List<LbDestination> destinations) {
|
||||
this.id = id;
|
||||
this.srcIp = srcIp;
|
||||
this.srcPort = srcPort;
|
||||
|
|
@ -59,10 +57,10 @@ public class LoadBalancerTO {
|
|||
}
|
||||
}
|
||||
|
||||
public LoadBalancerTO (Long id, String srcIp, int srcPort, String protocol, String algorithm, boolean revoked, boolean alreadyAdded, List<LbDestination> arg_destinations, List<LbStickinessPolicy> stickinessPolicies) {
|
||||
public LoadBalancerTO(Long id, String srcIp, int srcPort, String protocol, String algorithm, boolean revoked, boolean alreadyAdded, List<LbDestination> arg_destinations, List<LbStickinessPolicy> stickinessPolicies) {
|
||||
this(id, srcIp, srcPort, protocol, algorithm, revoked, alreadyAdded, arg_destinations);
|
||||
this.stickinessPolicies = null;
|
||||
if (stickinessPolicies != null && stickinessPolicies.size()>0) {
|
||||
if (stickinessPolicies != null && stickinessPolicies.size() > 0) {
|
||||
this.stickinessPolicies = new StickinessPolicyTO[MAX_STICKINESS_POLICIES];
|
||||
int index = 0;
|
||||
for (LbStickinessPolicy stickinesspolicy : stickinessPolicies) {
|
||||
|
|
@ -80,7 +78,6 @@ public class LoadBalancerTO {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected LoadBalancerTO() {
|
||||
}
|
||||
|
||||
|
|
@ -155,6 +152,7 @@ public class LoadBalancerTO {
|
|||
int destPort;
|
||||
boolean revoked;
|
||||
boolean alreadyAdded;
|
||||
|
||||
public DestinationTO(String destIp, int destPort, boolean revoked, boolean alreadyAdded) {
|
||||
this.destIp = destIp;
|
||||
this.destPort = destPort;
|
||||
|
|
@ -206,7 +204,7 @@ public class LoadBalancerTO {
|
|||
}
|
||||
}
|
||||
|
||||
public static class ConditionTO{
|
||||
public static class ConditionTO {
|
||||
private final long threshold;
|
||||
private final String relationalOperator;
|
||||
private final CounterTO counter;
|
||||
|
|
@ -273,7 +271,6 @@ public class LoadBalancerTO {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static class AutoScaleVmProfileTO {
|
||||
private final Long zoneId;
|
||||
private final Long domainId;
|
||||
|
|
@ -287,7 +284,7 @@ public class LoadBalancerTO {
|
|||
private final String autoScaleUserApiKey;
|
||||
private final String autoScaleUserSecretKey;
|
||||
|
||||
public AutoScaleVmProfileTO(Long zoneId, Long domainId, String cloudStackApiUrl, String autoScaleUserApiKey, String autoScaleUserSecretKey,Long serviceOfferingId, Long templateId,
|
||||
public AutoScaleVmProfileTO(Long zoneId, Long domainId, String cloudStackApiUrl, String autoScaleUserApiKey, String autoScaleUserSecretKey, Long serviceOfferingId, Long templateId,
|
||||
String otherDeployParams, String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod) {
|
||||
this.zoneId = zoneId;
|
||||
this.domainId = domainId;
|
||||
|
|
@ -301,36 +298,47 @@ public class LoadBalancerTO {
|
|||
this.autoScaleUserApiKey = autoScaleUserApiKey;
|
||||
this.autoScaleUserSecretKey = autoScaleUserSecretKey;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public Long getDomainId() {
|
||||
return domainId;
|
||||
}
|
||||
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public Long getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public String getOtherDeployParams() {
|
||||
return otherDeployParams;
|
||||
}
|
||||
|
||||
public String getSnmpCommunity() {
|
||||
return snmpCommunity;
|
||||
}
|
||||
|
||||
public Integer getSnmpPort() {
|
||||
return snmpPort;
|
||||
}
|
||||
|
||||
public Integer getDestroyVmGraceperiod() {
|
||||
return destroyVmGraceperiod;
|
||||
}
|
||||
|
||||
public String getCloudStackApiUrl() {
|
||||
return cloudStackApiUrl;
|
||||
}
|
||||
|
||||
public String getAutoScaleUserApiKey() {
|
||||
return autoScaleUserApiKey;
|
||||
}
|
||||
|
||||
public String getAutoScaleUserSecretKey() {
|
||||
return autoScaleUserSecretKey;
|
||||
}
|
||||
|
|
@ -407,13 +415,13 @@ public class LoadBalancerTO {
|
|||
LbAutoScaleVmProfile lbAutoScaleVmProfile = lbAutoScaleVmGroup.getProfile();
|
||||
AutoScaleVmProfile autoScaleVmProfile = lbAutoScaleVmProfile.getProfile();
|
||||
AutoScaleVmProfileTO autoScaleVmProfileTO = new AutoScaleVmProfileTO(autoScaleVmProfile.getZoneId(), autoScaleVmProfile.getDomainId(),
|
||||
lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(), lbAutoScaleVmProfile.getCloudStackApiUrl(),
|
||||
lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(), autoScaleVmProfile.getCsUrl(),
|
||||
autoScaleVmProfile.getServiceOfferingId(), autoScaleVmProfile.getTemplateId(), autoScaleVmProfile.getOtherDeployParams(),
|
||||
autoScaleVmProfile.getSnmpCommunity(), autoScaleVmProfile.getSnmpPort(), autoScaleVmProfile.getDestroyVmGraceperiod());
|
||||
|
||||
AutoScaleVmGroup autoScaleVmGroup = lbAutoScaleVmGroup.getVmGroup();
|
||||
autoScaleVmGroupTO = new AutoScaleVmGroupTO(autoScaleVmGroup.getMinMembers(), autoScaleVmGroup.getMaxMembers(), autoScaleVmGroup.getMemberPort(),
|
||||
autoScaleVmGroup.getInterval(),autoScalePolicyTOs, autoScaleVmProfileTO, autoScaleVmGroup.getState());
|
||||
autoScaleVmGroup.getInterval(), autoScalePolicyTOs, autoScaleVmProfileTO, autoScaleVmGroup.getState());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ public class ApiConstants {
|
|||
public static final String BIND_DN = "binddn";
|
||||
public static final String BIND_PASSWORD = "bindpass";
|
||||
public static final String CATEGORY = "category";
|
||||
public static final String CERTIFICATE = "certificate";
|
||||
public static final String PRIVATE_KEY = "privatekey";
|
||||
public static final String DOMAIN_SUFFIX = "domainsuffix";
|
||||
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
|
||||
public static final String CERTIFICATE = "certificate";
|
||||
public static final String PRIVATE_KEY = "privatekey";
|
||||
public static final String DOMAIN_SUFFIX = "domainsuffix";
|
||||
public static final String DNS_SEARCH_ORDER = "dnssearchorder";
|
||||
public static final String CIDR = "cidr";
|
||||
public static final String CIDR_LIST = "cidrlist";
|
||||
public static final String CLEANUP = "cleanup";
|
||||
|
|
@ -100,7 +100,7 @@ public class ApiConstants {
|
|||
public static final String JOB_STATUS = "jobstatus";
|
||||
public static final String LASTNAME = "lastname";
|
||||
public static final String LEVEL = "level";
|
||||
public static final String LIMIT_CPU_USE = "limitcpuuse";
|
||||
public static final String LIMIT_CPU_USE = "limitcpuuse";
|
||||
public static final String LOCK = "lock";
|
||||
public static final String LUN = "lun";
|
||||
public static final String LBID = "lbruleid";
|
||||
|
|
@ -132,9 +132,9 @@ public class ApiConstants {
|
|||
public static final String PORTAL = "portal";
|
||||
public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid";
|
||||
public static final String PRIVATE_INTERFACE = "privateinterface";
|
||||
public static final String PRIVATE_IP = "privateip";
|
||||
public static final String PRIVATE_IP = "privateip";
|
||||
public static final String PRIVATE_PORT = "privateport";
|
||||
public static final String PRIVATE_START_PORT = "privateport";
|
||||
public static final String PRIVATE_START_PORT = "privateport";
|
||||
public static final String PRIVATE_END_PORT = "privateendport";
|
||||
public static final String PRIVATE_ZONE = "privatezone";
|
||||
public static final String PROTOCOL = "protocol";
|
||||
|
|
@ -142,7 +142,7 @@ public class ApiConstants {
|
|||
public static final String PUBLIC_IP_ID = "publicipid";
|
||||
public static final String PUBLIC_IP = "publicip";
|
||||
public static final String PUBLIC_PORT = "publicport";
|
||||
public static final String PUBLIC_START_PORT = "publicport";
|
||||
public static final String PUBLIC_START_PORT = "publicport";
|
||||
public static final String PUBLIC_END_PORT = "publicendport";
|
||||
public static final String PUBLIC_ZONE = "publiczone";
|
||||
public static final String RECEIVED_BYTES = "receivedbytes";
|
||||
|
|
@ -166,7 +166,7 @@ public class ApiConstants {
|
|||
public static final String SNAPSHOT_ID = "snapshotid";
|
||||
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
|
||||
public static final String SNAPSHOT_TYPE = "snapshottype";
|
||||
public static final String SOURCE_ZONE_ID = "sourcezoneid";
|
||||
public static final String SOURCE_ZONE_ID = "sourcezoneid";
|
||||
public static final String START_DATE = "startdate";
|
||||
public static final String START_IP = "startip";
|
||||
public static final String START_PORT = "startport";
|
||||
|
|
@ -237,13 +237,13 @@ public class ApiConstants {
|
|||
public static final String PRIVATE_NETWORK_ID = "privatenetworkid";
|
||||
public static final String ALLOCATION_STATE = "allocationstate";
|
||||
public static final String MANAGED_STATE = "managedstate";
|
||||
public static final String STORAGE_ID="storageid";
|
||||
public static final String STORAGE_ID = "storageid";
|
||||
public static final String PING_STORAGE_SERVER_IP = "pingstorageserverip";
|
||||
public static final String PING_DIR = "pingdir";
|
||||
public static final String TFTP_DIR = "tftpdir";
|
||||
public static final String PING_CIFS_USERNAME = "pingcifsusername";
|
||||
public static final String PING_CIFS_PASSWORD = "pingcifspassword";
|
||||
public static final String CHECKSUM="checksum";
|
||||
public static final String CHECKSUM = "checksum";
|
||||
public static final String NETWORK_DEVICE_TYPE = "networkdevicetype";
|
||||
public static final String NETWORK_DEVICE_PARAMETER_LIST = "networkdeviceparameterlist";
|
||||
public static final String ZONE_TOKEN = "zonetoken";
|
||||
|
|
@ -259,8 +259,8 @@ public class ApiConstants {
|
|||
public static final String IP_NETWORK_LIST = "iptonetworklist";
|
||||
public static final String PARAM_LIST = "param";
|
||||
public static final String FOR_LOAD_BALANCING = "forloadbalancing";
|
||||
public static final String KEYBOARD="keyboard";
|
||||
public static final String OPEN_FIREWALL="openfirewall";
|
||||
public static final String KEYBOARD = "keyboard";
|
||||
public static final String OPEN_FIREWALL = "openfirewall";
|
||||
public static final String TEMPLATE_TAG = "templatetag";
|
||||
public static final String HYPERVISOR_VERSION = "hypervisorversion";
|
||||
public static final String MAX_GUESTS_LIMIT = "maxguestslimit";
|
||||
|
|
@ -296,8 +296,8 @@ public class ApiConstants {
|
|||
public static final String SERVICE_LIST = "servicelist";
|
||||
public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice";
|
||||
public static final String SUPPORTED_SERVICES = "supportedservices";
|
||||
public static final String NSP_ID= "nspid";
|
||||
public static final String ACL_TYPE= "acltype";
|
||||
public static final String NSP_ID = "nspid";
|
||||
public static final String ACL_TYPE = "acltype";
|
||||
public static final String SUBDOMAIN_ACCESS = "subdomainaccess";
|
||||
public static final String LOAD_BALANCER_DEVICE_ID = "lbdeviceid";
|
||||
public static final String LOAD_BALANCER_DEVICE_NAME = "lbdevicename";
|
||||
|
|
@ -386,6 +386,7 @@ public class ApiConstants {
|
|||
public static final String AUTOSCALE_VM_DESTROY_TIME = "destroyvmgraceperiod";
|
||||
public static final String VMPROFILE_ID = "vmprofileid";
|
||||
public static final String VMGROUP_ID = "vmgroupid";
|
||||
public static final String CS_URL = "csurl";
|
||||
public static final String SCALEUP_POLICY_IDS = "scaleuppolicyids";
|
||||
public static final String SCALEDOWN_POLICY_IDS = "scaledownpolicyids";
|
||||
public static final String INTERVAL = "interval";
|
||||
|
|
@ -394,20 +395,20 @@ public class ApiConstants {
|
|||
public static final String CONDITION_ID = "conditionid";
|
||||
public static final String CONDITION_IDS = "conditionids";
|
||||
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
|
||||
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
}
|
||||
|
||||
|
||||
public enum VMDetails {
|
||||
all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min;
|
||||
}
|
||||
|
||||
|
||||
public enum LDAPParams {
|
||||
hostname, port, usessl, queryfilter, searchbase, dn, passwd, truststore, truststorepass;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
public String toString() {
|
||||
return "ldap." + name();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name = ApiConstants.AUTOSCALE_USER_ID, type = CommandType.LONG, description = "the ID of the user used to launch and destroy the VMs")
|
||||
private Long autoscaleUserId;
|
||||
|
||||
@Parameter(name = ApiConstants.CS_URL, type = CommandType.STRING, description = "the URL including port of the CloudStack Management Server example: http://server.cloud.com:8080")
|
||||
private String csUrl;
|
||||
|
||||
private Map<String, String> otherDeployParamMap;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
@ -117,8 +120,12 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
return otherDeployParams;
|
||||
}
|
||||
|
||||
public String getCsUrl() {
|
||||
return csUrl;
|
||||
}
|
||||
|
||||
public Long getAutoscaleUserId() {
|
||||
if(autoscaleUserId != null) {
|
||||
if (autoscaleUserId != null) {
|
||||
return autoscaleUserId;
|
||||
} else {
|
||||
return UserContext.current().getCaller().getId();
|
||||
|
|
@ -130,11 +137,11 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
|
||||
public long getAccountId() {
|
||||
if(accountId != null) {
|
||||
if (accountId != null) {
|
||||
return accountId;
|
||||
}
|
||||
Account account = null;
|
||||
if(autoscaleUserId != null) {
|
||||
if (autoscaleUserId != null) {
|
||||
User user = _entityMgr.findById(User.class, autoscaleUserId);
|
||||
account = _entityMgr.findById(Account.class, user.getAccountId());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -35,4 +35,6 @@ public interface AutoScaleVmProfile extends ControlledEntity {
|
|||
public Integer getDestroyVmGraceperiod();
|
||||
|
||||
public long getAutoScaleUserId();
|
||||
|
||||
public String getCsUrl();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import com.cloud.network.rules.FirewallRule;
|
|||
import com.cloud.network.rules.LoadBalancer;
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
||||
public class LoadBalancingRule implements FirewallRule, LoadBalancer {
|
||||
private final LoadBalancer lb;
|
||||
private final List<LbDestination> destinations;
|
||||
private final List<LbStickinessPolicy> stickinessPolicies;
|
||||
|
|
@ -127,11 +127,13 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
|||
return stickinessPolicies;
|
||||
}
|
||||
|
||||
|
||||
public interface Destination {
|
||||
String getIpAddress();
|
||||
|
||||
int getDestinationPortStart();
|
||||
|
||||
int getDestinationPortEnd();
|
||||
|
||||
boolean isRevoked();
|
||||
}
|
||||
|
||||
|
|
@ -182,10 +184,12 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
|||
public String getIpAddress() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDestinationPortStart() {
|
||||
return portStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDestinationPortEnd() {
|
||||
return portEnd;
|
||||
|
|
@ -243,17 +247,19 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
|||
this.autoScaleVmGroup = autoScaleVmGroup;
|
||||
}
|
||||
|
||||
|
||||
public static class LbCondition {
|
||||
private final Condition condition;
|
||||
private final Counter counter;
|
||||
|
||||
public LbCondition(Counter counter, Condition condition) {
|
||||
this.condition = condition;
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Counter getCounter() {
|
||||
return counter;
|
||||
}
|
||||
|
|
@ -263,14 +269,17 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
|||
private final List<LbCondition> conditions;
|
||||
private final AutoScalePolicy policy;
|
||||
private boolean revoked;
|
||||
|
||||
public LbAutoScalePolicy(AutoScalePolicy policy, List<LbCondition> conditions)
|
||||
{
|
||||
this.policy = policy;
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public List<LbCondition> getConditions() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
public AutoScalePolicy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
|
@ -278,6 +287,7 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
|||
public boolean isRevoked() {
|
||||
return revoked;
|
||||
}
|
||||
|
||||
public void setRevoked(boolean revoked) {
|
||||
this.revoked = revoked;
|
||||
}
|
||||
|
|
@ -285,25 +295,23 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
|||
|
||||
public static class LbAutoScaleVmProfile {
|
||||
AutoScaleVmProfile profile;
|
||||
private final String cloudStackApiUrl;
|
||||
private final String autoScaleUserApiKey;
|
||||
private final String autoScaleUserSecretKey;
|
||||
|
||||
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String cloudStackApiUrl, String autoScaleUserApiKey, String autoScaleUserSecretKey) {
|
||||
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey, String autoScaleUserSecretKey) {
|
||||
this.profile = profile;
|
||||
this.cloudStackApiUrl = cloudStackApiUrl;
|
||||
this.autoScaleUserApiKey = autoScaleUserApiKey;
|
||||
this.autoScaleUserSecretKey = autoScaleUserSecretKey;
|
||||
}
|
||||
|
||||
public AutoScaleVmProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
public String getCloudStackApiUrl() {
|
||||
return cloudStackApiUrl;
|
||||
}
|
||||
|
||||
public String getAutoScaleUserApiKey() {
|
||||
return autoScaleUserApiKey;
|
||||
}
|
||||
|
||||
public String getAutoScaleUserSecretKey() {
|
||||
return autoScaleUserSecretKey;
|
||||
}
|
||||
|
|
@ -332,112 +340,4 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer{
|
|||
return profile;
|
||||
}
|
||||
}
|
||||
//public static class LbCounter{
|
||||
//private String name;
|
||||
//private String source;
|
||||
//private String value;
|
||||
//
|
||||
//public LbCounter(String name, String source, String value)
|
||||
//{
|
||||
// this.name = name;
|
||||
// this.source = source;
|
||||
// this.value = value;
|
||||
//}
|
||||
//
|
||||
//public String getName() {
|
||||
// return name;
|
||||
//}
|
||||
//public String getSource() {
|
||||
// return source;
|
||||
//}
|
||||
//public String getValue() {
|
||||
// return value;
|
||||
//}
|
||||
//}
|
||||
//
|
||||
//public static class LbCondition{
|
||||
//private long threshold;
|
||||
//private String relationalOperator;
|
||||
//private LbCounter counter;
|
||||
//public LbCondition(int threshold, String relationalOperator, LbCounter counter)
|
||||
//{
|
||||
// this.threshold = threshold;
|
||||
// this.relationalOperator = relationalOperator;
|
||||
// this.counter = counter;
|
||||
//}
|
||||
//public long getThreshold() {
|
||||
// return threshold;
|
||||
//}
|
||||
//public String getRelationalOperator() {
|
||||
// return relationalOperator;
|
||||
//}
|
||||
//public LbCounter getCounter() {
|
||||
// return counter;
|
||||
//}
|
||||
//}
|
||||
//
|
||||
//public static class AutoScaleVmGroup {
|
||||
//private int minMembers;
|
||||
//private int maxMembers;
|
||||
//private List<AutoscalePolicy> scaleUpPolicies;
|
||||
//private List<AutoscalePolicy> scaleDownPolicies;
|
||||
//private List<AutoScaleVmProfile> profile;
|
||||
//private boolean revoked;
|
||||
//
|
||||
//public boolean isRevoked() {
|
||||
// return revoked;
|
||||
//}
|
||||
//
|
||||
//public void setRevoked(boolean revoked) {
|
||||
// this.revoked = revoked;
|
||||
//}
|
||||
//}
|
||||
//
|
||||
//public static class AutoScaleVmProfile {
|
||||
//private Long zoneId;
|
||||
//private long domainId;
|
||||
//private long accountId;
|
||||
//private Long serviceOfferingId;
|
||||
//private Long templateId;
|
||||
//private String otherDeployParams;
|
||||
//private String snmpCommunity;
|
||||
//private Integer snmpPort;
|
||||
//
|
||||
//}
|
||||
//
|
||||
//public static class AutoscalePolicy {
|
||||
//private int interval;
|
||||
//
|
||||
//private int duration;
|
||||
//private int quietTime;
|
||||
//private String action;
|
||||
//private List<LbCondition> conditions;
|
||||
//
|
||||
//public AutoscalePolicy(int interval, int duration, int quietTime, String action, List<LbCondition> conditions) {
|
||||
// this.interval = interval;
|
||||
// this.duration = duration;
|
||||
// this.quietTime = quietTime;
|
||||
// this.conditions = conditions;
|
||||
//}
|
||||
//
|
||||
//public int getInterval() {
|
||||
// return interval;
|
||||
//}
|
||||
//
|
||||
//public int getDuration() {
|
||||
// return duration;
|
||||
//}
|
||||
//
|
||||
//public int getQuietTime() {
|
||||
// return quietTime;
|
||||
//}
|
||||
//
|
||||
//public String getAction() {
|
||||
// return action;
|
||||
//}
|
||||
//
|
||||
//public List<LbCondition> getConditions() {
|
||||
// return conditions;
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -43,7 +43,9 @@ import com.cloud.api.commands.ListCountersCmd;
|
|||
import com.cloud.api.commands.UpdateAutoScalePolicyCmd;
|
||||
import com.cloud.api.commands.UpdateAutoScaleVmGroupCmd;
|
||||
import com.cloud.api.commands.UpdateAutoScaleVmProfileCmd;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
|
|
@ -87,7 +89,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
|
|||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@Local(value = { AutoScaleService.class })
|
||||
@Local(value = { AutoScaleService.class })
|
||||
public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
||||
private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class);
|
||||
|
||||
|
|
@ -128,6 +130,8 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
UserDao _userDao;
|
||||
@Inject
|
||||
IPAddressDao _ipAddressDao;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
|
|
@ -168,7 +172,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
for (Counter counter : counters) {
|
||||
if (!supportedCounters.contains(counter.getSource())) {
|
||||
throw new InvalidParameterException("AutoScale counter with source='" + counter.getSource() + "' is not supported " +
|
||||
"in the network where lb is configured");
|
||||
"in the network where lb is configured");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -293,10 +297,17 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
autoscaleUserId = UserContext.current().getCallerUserId();
|
||||
}
|
||||
|
||||
// TODO check template is present or not.
|
||||
String csUrl = cmd.getCsUrl();
|
||||
if (csUrl == null) {
|
||||
String mgmtIP = _configDao.getValue(Config.ManagementHostIPAdr.key());
|
||||
csUrl = "http://" + mgmtIP + ":8080/client/api?";
|
||||
}
|
||||
else {
|
||||
csUrl += "/client/api?";
|
||||
}
|
||||
|
||||
AutoScaleVmProfileVO profileVO = new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
|
||||
cmd.getSnmpCommunity(), cmd.getSnmpPort(), cmd.getDestroyVmGraceperiod(), autoscaleUserId);
|
||||
cmd.getSnmpCommunity(), cmd.getSnmpPort(), cmd.getDestroyVmGraceperiod(), autoscaleUserId, csUrl);
|
||||
_autoScaleVmProfileDao.persist(profileVO);
|
||||
return profileVO;
|
||||
}
|
||||
|
|
@ -347,7 +358,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
AutoScaleVmProfileVO vmProfile = getEntityInDatabase("Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
|
||||
AutoScaleVmProfileVO bakUpProfile = getEntityInDatabase("Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
|
||||
|
||||
if(templateId == null && otherDeployParams == null) {
|
||||
if (templateId == null && otherDeployParams == null) {
|
||||
throw new InvalidParameterValueException("Atleast one parameter should be passed for update");
|
||||
}
|
||||
|
||||
|
|
@ -394,36 +405,36 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
autoScalePolicyVO = _autoScalePolicyDao.persist(autoScalePolicyVO);
|
||||
|
||||
if(conditionIds != null) {
|
||||
if (conditionIds != null) {
|
||||
SearchBuilder<ConditionVO> conditionsSearch = _conditionDao.createSearchBuilder();
|
||||
conditionsSearch.and("ids", conditionsSearch.entity().getId(), Op.IN);
|
||||
conditionsSearch.done();
|
||||
SearchCriteria<ConditionVO> sc = conditionsSearch.create();
|
||||
|
||||
sc.setParameters("ids", conditionIds.toArray(new Object[0]));
|
||||
List<ConditionVO> conditions = _conditionDao.search(sc, null);
|
||||
sc.setParameters("ids", conditionIds.toArray(new Object[0]));
|
||||
List<ConditionVO> conditions = _conditionDao.search(sc, null);
|
||||
|
||||
ControlledEntity[] sameOwnerEntities = conditions.toArray(new ControlledEntity[conditions.size() + 1]);
|
||||
sameOwnerEntities[sameOwnerEntities.length - 1] = autoScalePolicyVO;
|
||||
_accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEntities);
|
||||
ControlledEntity[] sameOwnerEntities = conditions.toArray(new ControlledEntity[conditions.size() + 1]);
|
||||
sameOwnerEntities[sameOwnerEntities.length - 1] = autoScalePolicyVO;
|
||||
_accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEntities);
|
||||
|
||||
if (conditionIds.size() != conditions.size()) {
|
||||
// TODO report the condition id which could not be found
|
||||
throw new InvalidParameterValueException("Unable to find a condition specified");
|
||||
}
|
||||
|
||||
ArrayList<Long> counterIds = new ArrayList<Long>();
|
||||
for (ConditionVO condition : conditions) {
|
||||
if (counterIds.contains(condition.getCounterid())) {
|
||||
throw new InvalidParameterValueException("atleast two conditions in the conditionids have the same counter. It is not right to apply two different conditions for the same counter");
|
||||
if (conditionIds.size() != conditions.size()) {
|
||||
// TODO report the condition id which could not be found
|
||||
throw new InvalidParameterValueException("Unable to find a condition specified");
|
||||
}
|
||||
counterIds.add(condition.getCounterid());
|
||||
}
|
||||
|
||||
for (Long conditionId : conditionIds) {
|
||||
AutoScalePolicyConditionMapVO policyConditionMapVO = new AutoScalePolicyConditionMapVO(autoScalePolicyVO.getId(), conditionId);
|
||||
_autoScalePolicyConditionMapDao.persist(policyConditionMapVO);
|
||||
}
|
||||
ArrayList<Long> counterIds = new ArrayList<Long>();
|
||||
for (ConditionVO condition : conditions) {
|
||||
if (counterIds.contains(condition.getCounterid())) {
|
||||
throw new InvalidParameterValueException("atleast two conditions in the conditionids have the same counter. It is not right to apply two different conditions for the same counter");
|
||||
}
|
||||
counterIds.add(condition.getCounterid());
|
||||
}
|
||||
|
||||
for (Long conditionId : conditionIds) {
|
||||
AutoScalePolicyConditionMapVO policyConditionMapVO = new AutoScalePolicyConditionMapVO(autoScalePolicyVO.getId(), conditionId);
|
||||
_autoScalePolicyConditionMapDao.persist(policyConditionMapVO);
|
||||
}
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
|
|
@ -450,7 +461,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
AutoScalePolicyVO policyVO = new AutoScalePolicyVO(cmd.getDomainId(), cmd.getAccountId(), duration, quietTime, action);
|
||||
|
||||
policyVO = checkValidityAndPersist(policyVO, cmd.getConditionIds());
|
||||
policyVO = checkValidityAndPersist(policyVO, cmd.getConditionIds());
|
||||
|
||||
return policyVO;
|
||||
}
|
||||
|
|
@ -475,12 +486,12 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
s_logger.warn("Failed to remove AutoScale Policy db object");
|
||||
return false;
|
||||
}
|
||||
success = _autoScalePolicyConditionMapDao.removeByAutoScalePolicyId(id);
|
||||
success = _autoScalePolicyConditionMapDao.removeByAutoScalePolicyId(id);
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to remove AutoScale Policy Condition mappings");
|
||||
return false;
|
||||
}
|
||||
txn.commit();
|
||||
txn.commit();
|
||||
return success; // successful
|
||||
}
|
||||
|
||||
|
|
@ -517,7 +528,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
Account caller = UserContext.current().getCaller();
|
||||
|
||||
Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
|
||||
ListProjectResourcesCriteria>(domainId, isRecursive, null);
|
||||
ListProjectResourcesCriteria>(domainId, isRecursive, null);
|
||||
_accountMgr.buildACLSearchParameters(caller, id, accountName, null, permittedAccounts, domainIdRecursiveListProject,
|
||||
listAll, false);
|
||||
domainId = domainIdRecursiveListProject.first();
|
||||
|
|
@ -580,7 +591,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
List<Long> conditionIds = cmd.getConditionIds();
|
||||
AutoScalePolicyVO policy = getEntityInDatabase("Auto Scale Policy", policyId, _autoScalePolicyDao);
|
||||
|
||||
if(duration == null && quietTime == null && conditionIds == null) {
|
||||
if (duration == null && quietTime == null && conditionIds == null) {
|
||||
throw new InvalidParameterValueException("Atleast one parameter should be passed for update");
|
||||
}
|
||||
|
||||
|
|
@ -598,10 +609,10 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
|
||||
throw new InvalidParameterValueException("The AutoScale Policy can be updated only if the Vm Group it is associated with is disabled in state");
|
||||
}
|
||||
if(vmGroupVO.getInterval() < duration) {
|
||||
if (vmGroupVO.getInterval() < duration) {
|
||||
throw new InvalidParameterValueException("duration is less than the associated AutoScaleVmGroup's interval");
|
||||
}
|
||||
if(vmGroupVO.getInterval() < quietTime) {
|
||||
if (vmGroupVO.getInterval() < quietTime) {
|
||||
throw new InvalidParameterValueException("quietTime is less than the associated AutoScaleVmGroup's interval");
|
||||
}
|
||||
}
|
||||
|
|
@ -610,7 +621,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
s_logger.debug("Updated Auto Scale Policy id:" + policyId);
|
||||
|
||||
return policy;
|
||||
return policy;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -621,7 +632,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
int maxMembers = cmd.getMaxMembers();
|
||||
Integer interval = cmd.getInterval();
|
||||
|
||||
if(interval == null) {
|
||||
if (interval == null) {
|
||||
interval = NetUtils.DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME;
|
||||
}
|
||||
|
||||
|
|
@ -633,7 +644,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
Long zoneId = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId()).getDataCenterId();
|
||||
|
||||
if(_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancer.getId())) {
|
||||
if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancer.getId())) {
|
||||
throw new InvalidParameterValueException("an AutoScaleVmGroup is already attached to the lb rule, the existing vm group has to be first deleted");
|
||||
}
|
||||
|
||||
|
|
@ -661,7 +672,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
public boolean configureAutoScaleVmGroup(long vmGroupid) {
|
||||
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
|
||||
|
||||
if(isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
|
||||
if (isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
|
||||
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid);
|
||||
}
|
||||
|
||||
|
|
@ -675,7 +686,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
public boolean deleteAutoScaleVmGroup(long id) {
|
||||
AutoScaleVmGroupVO autoScaleVmGroupVO = getEntityInDatabase("AutoScale Vm Group", id, _autoScaleVmGroupDao);
|
||||
|
||||
if(autoScaleVmGroupVO.getState().equals(AutoScaleVmGroup.State_New)) {
|
||||
if (autoScaleVmGroupVO.getState().equals(AutoScaleVmGroup.State_New)) {
|
||||
/* This condition is for handling failures during creation command */
|
||||
return _autoScaleVmGroupDao.remove(id);
|
||||
}
|
||||
|
|
@ -687,7 +698,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
try {
|
||||
success = configureAutoScaleVmGroup(id);
|
||||
} finally {
|
||||
if(!success) {
|
||||
if (!success) {
|
||||
s_logger.warn("Could not delete AutoScale Vm Group id : " + id);
|
||||
autoScaleVmGroupVO.setState(bakupState);
|
||||
_autoScaleVmGroupDao.persist(autoScaleVmGroupVO);
|
||||
|
|
@ -704,13 +715,13 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
return false;
|
||||
}
|
||||
|
||||
success = _autoScaleVmGroupPolicyMapDao.removeByGroupId(id);
|
||||
success = _autoScaleVmGroupPolicyMapDao.removeByGroupId(id);
|
||||
if (!success) {
|
||||
s_logger.warn("Failed to remove AutoScale Group Policy mappings");
|
||||
return false;
|
||||
}
|
||||
|
||||
txn.commit();
|
||||
txn.commit();
|
||||
return success; // Successfull
|
||||
}
|
||||
|
||||
|
|
@ -778,11 +789,11 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
throw new InvalidParameterValueException("interval is an invalid value: " + interval);
|
||||
}
|
||||
|
||||
if(scaleUpPolicyIds != null) {
|
||||
if (scaleUpPolicyIds != null) {
|
||||
policies.addAll(getAutoScalePolicies("scaleuppolicyid", scaleUpPolicyIds, counters, interval, true));
|
||||
}
|
||||
|
||||
if(scaleDownPolicyIds != null) {
|
||||
if (scaleDownPolicyIds != null) {
|
||||
policies.addAll(getAutoScalePolicies("scaledownpolicyid", scaleDownPolicyIds, counters, interval, false));
|
||||
}
|
||||
|
||||
|
|
@ -820,7 +831,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
List<Long> scaleUpPolicyIds = cmd.getScaleUpPolicyIds();
|
||||
List<Long> scaleDownPolicyIds = cmd.getScaleDownPolicyIds();
|
||||
|
||||
if(minMembers == null && maxMembers == null && interval == null && scaleUpPolicyIds == null && scaleDownPolicyIds == null) {
|
||||
if (minMembers == null && maxMembers == null && interval == null && scaleUpPolicyIds == null && scaleDownPolicyIds == null) {
|
||||
throw new InvalidParameterValueException("Atleast one parameter should be passed for update");
|
||||
}
|
||||
|
||||
|
|
@ -845,18 +856,18 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
|
||||
boolean success = true;
|
||||
List<Long> bakupPolicyIds = new ArrayList<Long>();
|
||||
if(scaleUpPolicyIds != null || scaleDownPolicyIds != null) {
|
||||
if (scaleUpPolicyIds != null || scaleDownPolicyIds != null) {
|
||||
List<Long> bakupScaleUpPolicyIds = new ArrayList<Long>();
|
||||
List<Long> bakupScaleDownPolicyIds = new ArrayList<Long>();
|
||||
ApiDBUtils.getAutoScaleVmGroupPolicyIds(vmGroupId, bakupScaleUpPolicyIds, bakupScaleDownPolicyIds);
|
||||
if(scaleUpPolicyIds != null) {
|
||||
if (scaleUpPolicyIds != null) {
|
||||
bakupPolicyIds.addAll(bakupScaleUpPolicyIds);
|
||||
}
|
||||
if(scaleDownPolicyIds != null) {
|
||||
if (scaleDownPolicyIds != null) {
|
||||
bakupPolicyIds.addAll(bakupScaleDownPolicyIds);
|
||||
}
|
||||
success = _autoScaleVmGroupPolicyMapDao.removeByGroupAndPolicies(vmGroupId, bakupPolicyIds);
|
||||
if(!success) {
|
||||
if (!success) {
|
||||
s_logger.warn("Removal of existing policy mappings for vmgroup failed");
|
||||
return null;
|
||||
}
|
||||
|
|
@ -865,16 +876,15 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
vmGroupVO = checkValidityAndPersist(vmGroupVO, scaleUpPolicyIds, scaleDownPolicyIds);
|
||||
try {
|
||||
success = configureAutoScaleVmGroup(vmGroupVO.getId());
|
||||
}
|
||||
finally {
|
||||
if (!success) {
|
||||
Transaction.currentTxn().start();
|
||||
} finally {
|
||||
if (!success) {
|
||||
Transaction.currentTxn().start();
|
||||
for (Long backUpPolicyId : bakupPolicyIds) {
|
||||
_autoScaleVmGroupPolicyMapDao.persist(new AutoScaleVmGroupPolicyMapVO(vmGroupId, backUpPolicyId));
|
||||
}
|
||||
_autoScaleVmGroupDao.update(bakUpVmGroupVO.getId(), bakUpVmGroupVO);
|
||||
Transaction.currentTxn().commit();
|
||||
}
|
||||
_autoScaleVmGroupDao.update(bakUpVmGroupVO.getId(), bakUpVmGroupVO);
|
||||
Transaction.currentTxn().commit();
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
s_logger.debug("Updated Auto Scale VmGroup id:" + vmGroupId);
|
||||
|
|
@ -894,18 +904,18 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
}
|
||||
|
||||
try {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Enabled);
|
||||
vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Enabled);
|
||||
vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
|
||||
success = _lbRulesMgr.configureLbAutoScaleVmGroup(id);
|
||||
|
||||
} finally {
|
||||
if (!success) {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Disabled);
|
||||
_autoScaleVmGroupDao.persist(vmGroup);
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Disabled);
|
||||
_autoScaleVmGroupDao.persist(vmGroup);
|
||||
s_logger.warn("Failed to enable AutoScale Vm Group id : " + id);
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vmGroup;
|
||||
}
|
||||
|
||||
|
|
@ -920,18 +930,18 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
}
|
||||
|
||||
try {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Disabled);
|
||||
vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Disabled);
|
||||
vmGroup = _autoScaleVmGroupDao.persist(vmGroup);
|
||||
|
||||
success = _lbRulesMgr.configureLbAutoScaleVmGroup(id);
|
||||
} finally {
|
||||
if (!success) {
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Enabled);
|
||||
_autoScaleVmGroupDao.persist(vmGroup);
|
||||
vmGroup.setState(AutoScaleVmGroup.State_Enabled);
|
||||
_autoScaleVmGroupDao.persist(vmGroup);
|
||||
s_logger.warn("Failed to disable AutoScale Vm Group id : " + id);
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return vmGroup;
|
||||
}
|
||||
|
||||
|
|
@ -994,7 +1004,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
|
|||
String name = cmd.getName();
|
||||
Long id = cmd.getId();
|
||||
String source = cmd.getSource();
|
||||
if(source != null )
|
||||
if (source != null)
|
||||
source = source.toLowerCase();
|
||||
|
||||
Filter searchFilter = new Filter(CounterVO.class, "created", false, cmd.getStartIndex(), cmd.getPageSizeVal());
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
@Column(name = "other_deploy_params", updatable = true, length = 1024)
|
||||
private String otherDeployParams;
|
||||
|
||||
@Column(name = "cs_url")
|
||||
private String csUrl;
|
||||
|
||||
@Column(name = "destroy_vm_grace_period", updatable = true)
|
||||
private Integer destroyVmGraceperiod = NetUtils.DEFAULT_AUTOSCALE_VM_DESTROY_TIME;
|
||||
|
||||
|
|
@ -81,7 +84,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
}
|
||||
|
||||
public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod,
|
||||
long autoscaleUserId) {
|
||||
long autoscaleUserId, String csUrl) {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
setZoneId(zoneId);
|
||||
setDomainId(domainId);
|
||||
|
|
@ -90,6 +93,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
setTemplateId(templateId);
|
||||
setOtherDeployParams(otherDeployParams);
|
||||
setAutoscaleUserId(autoscaleUserId);
|
||||
setCsUrl(csUrl);
|
||||
if (destroyVmGraceperiod != null) {
|
||||
setDestroyVmGraceperiod(destroyVmGraceperiod);
|
||||
}
|
||||
|
|
@ -138,6 +142,14 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
|
|||
return snmpCommunity;
|
||||
}
|
||||
|
||||
public String getCsUrl() {
|
||||
return csUrl;
|
||||
}
|
||||
|
||||
public void setCsUrl(String csUrl) {
|
||||
this.csUrl = csUrl;
|
||||
}
|
||||
|
||||
public void setSnmpCommunity(String snmpCommunity) {
|
||||
this.snmpCommunity = snmpCommunity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.network.lb;
|
||||
|
||||
|
|
@ -16,7 +16,6 @@ import java.security.InvalidParameterException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Formatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -188,7 +187,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
TemplateManager _templateMgr;
|
||||
@Inject
|
||||
ExternalLoadBalancerUsageManager _externalLBUsageMgr;
|
||||
@Inject
|
||||
@Inject
|
||||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
ResourceTagDao _resourceTagDao;
|
||||
|
|
@ -221,7 +220,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
serviceResponse.setName(service.getName());
|
||||
if ("Lb".equalsIgnoreCase(service.getName())) {
|
||||
Map<Capability, String> serviceCapabilities = serviceCapabilitiesMap
|
||||
.get(service);
|
||||
.get(service);
|
||||
if (serviceCapabilities != null) {
|
||||
for (Capability capability : serviceCapabilities
|
||||
.keySet()) {
|
||||
|
|
@ -251,19 +250,12 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
autoScalePolicies.add(new LbAutoScalePolicy(autoScalePolicy, lbConditions));
|
||||
}
|
||||
ApiServer apiserver = ApiServer.getInstance();
|
||||
String apiIpAddress = apiserver.getServerIpAddress();
|
||||
String apiPort = apiserver.getServerPort();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
Formatter formatter = new Formatter(sb, java.util.Locale.US);
|
||||
formatter.format("https://%s:%s/client/api?", apiIpAddress, apiPort);
|
||||
String csurl = sb.toString();
|
||||
AutoScaleVmProfile autoScaleVmProfile = _autoScaleVmProfileDao.findById(vmGroup.getProfileId());
|
||||
Long autoscaleUserId = autoScaleVmProfile.getAutoScaleUserId();
|
||||
User user = _userDao.findById(autoscaleUserId);
|
||||
String apiKey = user.getApiKey();
|
||||
String secretKey = user.getSecretKey();
|
||||
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, csurl, apiKey, secretKey);
|
||||
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, apiKey, secretKey);
|
||||
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile);
|
||||
}
|
||||
|
||||
|
|
@ -537,7 +529,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRollBackAllowedForProvider(LoadBalancerVO loadBalancer) {
|
||||
Network network = _networkDao.findById(loadBalancer.getNetworkId());
|
||||
|
|
@ -557,7 +549,6 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
throw new InvalidParameterValueException("Failed to assign to load balancer; the load balancer was not found.", null);
|
||||
}
|
||||
|
||||
|
||||
List<LoadBalancerVMMapVO> mappedInstances = _lb2VmMapDao.listByLoadBalancerId(loadBalancerId, false);
|
||||
Set<Long> mappedInstanceIds = new HashSet<Long>();
|
||||
for (LoadBalancerVMMapVO mappedInstance : mappedInstances) {
|
||||
|
|
@ -649,8 +640,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
if(!success){
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to add specified loadbalancerruleid for vms " + instanceIds);
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
// TBD: Also pack in the instanceIds in the exception using the right VO object or table name.
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
// TBD: Also pack in the instanceIds in the exception using the right VO object or table name.
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -695,7 +686,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
if (!applyLoadBalancerConfig(loadBalancerId)) {
|
||||
s_logger.warn("Failed to remove load balancer rule id " + loadBalancerId + " for vms " + instanceIds);
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to remove specified load balancer rule id for vms " + instanceIds);
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
throw ex;
|
||||
}
|
||||
success = true;
|
||||
|
|
@ -717,7 +708,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
}
|
||||
if(!success){
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to remove specified load balancer rule id for vms " + instanceIds);
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
throw ex;
|
||||
}
|
||||
return success;
|
||||
|
|
@ -911,23 +902,23 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
try {
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
boolean assignToVpcNtwk = network.getVpcId() != null
|
||||
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
|
||||
if (assignToVpcNtwk) {
|
||||
//set networkId just for verification purposes
|
||||
//set networkId just for verification purposes
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
|
||||
|
||||
s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
|
||||
ipVO = _networkMgr.associateIPToGuestNetwork(ipAddrId, lb.getNetworkId(), false);
|
||||
performedIpAssoc = true;
|
||||
performedIpAssoc = true;
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
_networkMgr.checkIpForService(ipVO, Service.Lb, null);
|
||||
}
|
||||
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
}
|
||||
|
||||
if (ipVO.getAssociatedWithNetworkId() == null) {
|
||||
throw new InvalidParameterValueException("Ip address " + ipVO + " is not assigned to the network " + network);
|
||||
}
|
||||
}
|
||||
|
||||
if (lb.getSourceIpAddressId() == null) {
|
||||
throw new CloudRuntimeException("No ip address is defined to assign the LB to");
|
||||
|
|
@ -972,15 +963,15 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
// make sure ip address exists
|
||||
if (ipAddr == null || !ipAddr.readyToUse()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id specified", null);
|
||||
ex.addProxyObject(ipAddr, sourceIpId, "sourceIpId");
|
||||
ex.addProxyObject(ipAddr, sourceIpId, "sourceIpId");
|
||||
throw ex;
|
||||
} else if (ipAddr.isOneToOneNat()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to create load balancer rule; specified sourceip id has static nat enabled", null);
|
||||
ex.addProxyObject(ipAddr, sourceIpId, "sourceIpId");
|
||||
ex.addProxyObject(ipAddr, sourceIpId, "sourceIpId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
_firewallMgr.validateFirewallRule(caller.getCaller(), ipAddr, srcPortStart, srcPortEnd, lb.getProtocol(),
|
||||
_firewallMgr.validateFirewallRule(caller.getCaller(), ipAddr, srcPortStart, srcPortEnd, lb.getProtocol(),
|
||||
Purpose.LoadBalancing, FirewallRuleType.User);
|
||||
|
||||
Long networkId = ipAddr.getAssociatedWithNetworkId();
|
||||
|
|
@ -1010,7 +1001,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
newRule = _lbDao.persist(newRule);
|
||||
|
||||
if (openFirewall) {
|
||||
_firewallMgr.createRuleForAllCidrs(sourceIpId, caller.getCaller(), lb.getSourcePortStart(),
|
||||
_firewallMgr.createRuleForAllCidrs(sourceIpId, caller.getCaller(), lb.getSourcePortStart(),
|
||||
lb.getSourcePortEnd(), lb.getProtocol(), null, null, newRule.getId(), networkId);
|
||||
}
|
||||
|
||||
|
|
@ -1050,7 +1041,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
public boolean applyLoadBalancerConfig(long lbRuleId) throws ResourceUnavailableException {
|
||||
LoadBalancerVO lb = _lbDao.findById(lbRuleId);
|
||||
List<LoadBalancerVO> lbs;
|
||||
if (isRollBackAllowedForProvider(lb)) {
|
||||
if (isRollBackAllowedForProvider(lb)) {
|
||||
// this is for Netscalar type of devices. if their is failure the db entries will be rollbacked.
|
||||
lbs = Arrays.asList(lb);
|
||||
} else {
|
||||
|
|
@ -1313,13 +1304,13 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
* update if there is no change in the object.
|
||||
*/
|
||||
if (lbBackup.getName() != null) {
|
||||
lb.setName(lbBackup.getName());
|
||||
lb.setName(lbBackup.getName());
|
||||
}
|
||||
if (lbBackup.getDescription() != null) {
|
||||
lb.setDescription(lbBackup.getDescription());
|
||||
}
|
||||
if (lbBackup.getAlgorithm() != null){
|
||||
lb.setAlgorithm(lbBackup.getAlgorithm());
|
||||
lb.setAlgorithm(lbBackup.getAlgorithm());
|
||||
}
|
||||
lb.setState(lbBackup.getState());
|
||||
_lbDao.update(lb.getId(), lb);
|
||||
|
|
|
|||
|
|
@ -2375,6 +2375,7 @@ CREATE TABLE `cloud`.`autoscale_vmprofiles` (
|
|||
`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',
|
||||
`cs_url` varchar(255) NOT NULL COMMENT 'the URL including port of the CloudStack Management Server e.g. http://server.cloud.com:8080',
|
||||
`created` datetime NOT NULL COMMENT 'date created',
|
||||
`removed` datetime COMMENT 'date removed if not null',
|
||||
PRIMARY KEY (`id`),
|
||||
|
|
|
|||
Loading…
Reference in New Issue