AutoScale. ALenas Final Review Comments. 2nd Cut. Remove csurl from profile,

This commit is contained in:
Vijay 2012-07-19 03:09:53 +05:30
parent f9bcf3186c
commit 30cb0e74d2
12 changed files with 43 additions and 102 deletions

View File

@ -418,7 +418,7 @@ public class LoadBalancerTO {
LbAutoScaleVmProfile lbAutoScaleVmProfile = lbAutoScaleVmGroup.getProfile();
AutoScaleVmProfile autoScaleVmProfile = lbAutoScaleVmProfile.getProfile();
AutoScaleVmProfileTO autoScaleVmProfileTO = new AutoScaleVmProfileTO(autoScaleVmProfile.getZoneId(), autoScaleVmProfile.getDomainId(),
lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(), autoScaleVmProfile.getCsUrl(),
lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(), lbAutoScaleVmProfile.getCsUrl(),
autoScaleVmProfile.getServiceOfferingId(), autoScaleVmProfile.getTemplateId(), autoScaleVmProfile.getOtherDeployParams(),
autoScaleVmProfile.getSnmpCommunity(), autoScaleVmProfile.getSnmpPort(), autoScaleVmProfile.getDestroyVmGraceperiod());

View File

@ -72,9 +72,6 @@ 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 API URL including port of the CloudStack Management Server example: http://server.cloud.com:8080/client/api?")
private String csUrl;
private Map<String, String> otherDeployParamMap;
// ///////////////////////////////////////////////////
@ -120,10 +117,6 @@ public class CreateAutoScaleVmProfileCmd extends BaseAsyncCreateCmd {
return otherDeployParams;
}
public String getCsUrl() {
return csUrl;
}
public Long getAutoscaleUserId() {
if (autoscaleUserId != null) {
return autoscaleUserId;

View File

@ -36,7 +36,7 @@ public class ConditionResponse extends BaseResponse implements ControlledEntityR
@Param(description = "Relational Operator to be used with threshold.")
private String relationalOperator;
@SerializedName(value = ApiConstants.COUNTER_ID)
@SerializedName("counter")
@Param(description = "Details of the Counter.")
private CounterResponse counter;

View File

@ -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.
//
//
package com.cloud.network.as;
import com.cloud.acl.ControlledEntity;
@ -35,6 +35,4 @@ public interface AutoScaleVmProfile extends ControlledEntity {
public Integer getDestroyVmGraceperiod();
public long getAutoScaleUserId();
public String getCsUrl();
}

View File

@ -297,11 +297,13 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
AutoScaleVmProfile profile;
private final String autoScaleUserApiKey;
private final String autoScaleUserSecretKey;
private final String csUrl;
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey, String autoScaleUserSecretKey) {
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey, String autoScaleUserSecretKey, String csUrl) {
this.profile = profile;
this.autoScaleUserApiKey = autoScaleUserApiKey;
this.autoScaleUserSecretKey = autoScaleUserSecretKey;
this.csUrl = csUrl;
}
public AutoScaleVmProfile getProfile() {
@ -315,6 +317,9 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
public String getAutoScaleUserSecretKey() {
return autoScaleUserSecretKey;
}
public String getCsUrl() {
return csUrl;
}
}
public static class LbAutoScaleVmGroup {

View File

@ -3795,7 +3795,6 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setSnmpPort(profile.getSnmpPort());
response.setDestroyVmGraceperiod(profile.getDestroyVmGraceperiod());
response.setAutoscaleUserId(profile.getAutoScaleUserId());
response.setCsUrl(profile.getCsUrl());
response.setObjectName("autoscalevmprofile");
// Populates the account information in the response

View File

@ -43,9 +43,7 @@ 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;
@ -130,8 +128,6 @@ 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 {
@ -247,7 +243,6 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
return policies;
}
@DB
protected AutoScaleVmProfileVO checkValidityAndPersist(AutoScaleVmProfileVO vmProfile) {
long templateId = vmProfile.getTemplateId();
long autoscaleUserId = vmProfile.getAutoScaleUserId();
@ -274,7 +269,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_CREATE, eventDescription = "creating autoscale vm profile")
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_CREATE, eventDescription = "creating autoscale vm profile", create = true)
public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd cmd) {
Account owner = _accountDao.findById(cmd.getAccountId());
@ -309,17 +304,8 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
autoscaleUserId = UserContext.current().getCallerUserId();
}
String csUrl = cmd.getCsUrl();
if (csUrl == null) {
String mgmtIP = _configDao.getValue(Config.ManagementHostIPAdr.key());
csUrl = "http://" + mgmtIP + ":8080/client/api?";
} else {
if(!csUrl.endsWith("?"))
csUrl += "?";
}
AutoScaleVmProfileVO profileVO = new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
cmd.getSnmpCommunity(), cmd.getSnmpPort(), cmd.getDestroyVmGraceperiod(), autoscaleUserId, csUrl);
cmd.getSnmpCommunity(), cmd.getSnmpPort(), cmd.getDestroyVmGraceperiod(), autoscaleUserId);
profileVO = checkValidityAndPersist(profileVO);
s_logger.info("Successfully create AutoScale Vm Profile with Id: " + profileVO.getId());
@ -372,7 +358,6 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
}
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_DELETE, eventDescription = "deleting autoscale vm profile")
public boolean deleteAutoScaleVmProfile(long id) {
/* Check if entity is in database */
@ -414,7 +399,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
}
@DB
private AutoScalePolicyVO checkValidityAndPersist(AutoScalePolicyVO autoScalePolicyVO, List<Long> conditionIds) {
protected AutoScalePolicyVO checkValidityAndPersist(AutoScalePolicyVO autoScalePolicyVO, List<Long> conditionIds) {
int duration = autoScalePolicyVO.getDuration();
int quietTime = autoScalePolicyVO.getQuietTime();
@ -471,7 +456,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_CREATE, eventDescription = "creating autoscale policy")
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_CREATE, eventDescription = "creating autoscale policy", create = true)
public AutoScalePolicy createAutoScalePolicy(CreateAutoScalePolicyCmd cmd) {
int duration = cmd.getDuration();
@ -647,7 +632,7 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE, eventDescription = "creating autoscale vm group")
@ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_CREATE, eventDescription = "creating autoscale vm group", create = true)
public AutoScaleVmGroup createAutoScaleVmGroup(CreateAutoScaleVmGroupCmd cmd) {
int minMembers = cmd.getMinMembers();
int maxMembers = cmd.getMaxMembers();
@ -973,7 +958,6 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
@Override
@ActionEvent(eventType = EventTypes.EVENT_CONDITION_CREATE, eventDescription = "Condition", create = true)
@DB
public Condition createCondition(CreateConditionCmd cmd) {
checkCallerAccess(cmd.getAccountName(), cmd.getDomainId());
String opr = cmd.getRelationalOperator().toUpperCase();

View File

@ -62,9 +62,6 @@ 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;
@ -84,24 +81,23 @@ 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, String csUrl) {
long autoscaleUserId) {
this.uuid = UUID.randomUUID().toString();
setZoneId(zoneId);
setDomainId(domainId);
setAccountId(accountId);
setServiceOfferingId(serviceOfferingId);
setTemplateId(templateId);
setOtherDeployParams(otherDeployParams);
setAutoscaleUserId(autoscaleUserId);
setCsUrl(csUrl);
this.zoneId = zoneId;
this.domainId = domainId;
this.accountId = accountId;
this.serviceOfferingId = serviceOfferingId;
this.templateId = templateId;
this.otherDeployParams = otherDeployParams;
this.autoscaleUserId = autoscaleUserId;
if (destroyVmGraceperiod != null) {
setDestroyVmGraceperiod(destroyVmGraceperiod);
this.destroyVmGraceperiod = destroyVmGraceperiod;
}
if (snmpCommunity != null) {
setSnmpCommunity(snmpCommunity);
this.snmpCommunity = snmpCommunity;
}
if (snmpPort != null) {
setSnmpPort(snmpPort);
this.snmpPort = snmpPort;
}
}
@ -124,10 +120,6 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
return serviceOfferingId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
@Override
public String getOtherDeployParams() {
return otherDeployParams;
@ -142,14 +134,6 @@ 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;
}
@ -168,14 +152,6 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setZoneId(long zoneId) {
this.zoneId = zoneId;
}
public void setAutoscaleUserId(long autoscaleUserId) {
this.autoscaleUserId = autoscaleUserId;
}
@ -185,19 +161,11 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity {
return zoneId;
}
public void setAccountId(long accountId) {
this.accountId = accountId;
}
@Override
public long getAccountId() {
return accountId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
@Override
public long getDomainId() {
return domainId;

View File

@ -92,10 +92,6 @@ public class ConditionVO implements Condition, Identity {
return new StringBuilder("Condition[").append("id-").append(id).append("]").toString();
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@Override
public long getCounterid() {
return counterid;

View File

@ -100,10 +100,6 @@ public class CounterVO implements Counter, Identity {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Date getRemoved() {
return removed;
}

View File

@ -28,7 +28,6 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import com.cloud.api.ApiServer;
import com.cloud.api.commands.CreateLBStickinessPolicyCmd;
import com.cloud.api.commands.CreateLoadBalancerRuleCmd;
import com.cloud.api.commands.ListLBStickinessPoliciesCmd;
@ -36,7 +35,9 @@ import com.cloud.api.commands.ListLoadBalancerRuleInstancesCmd;
import com.cloud.api.commands.ListLoadBalancerRulesCmd;
import com.cloud.api.commands.UpdateLoadBalancerRuleCmd;
import com.cloud.api.response.ServiceResponse;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.domain.dao.DomainDao;
@ -206,6 +207,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
@Inject
AutoScaleVmGroupPolicyMapDao _autoScaleVmGroupPolicyMapDao;
@Inject
ConfigurationDao _configDao;
@Inject
DataCenterDao _dcDao = null;
@Inject
UserDao _userDao;
@ -249,13 +252,14 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
}
autoScalePolicies.add(new LbAutoScalePolicy(autoScalePolicy, lbConditions));
}
ApiServer apiserver = ApiServer.getInstance();
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, apiKey, secretKey);
String csUrl = _configDao.getValue(Config.EndpointeUrl.key());
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, apiKey, secretKey, csUrl);
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile);
}
@ -279,7 +283,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
@DB
public boolean configureLbAutoScaleVmGroup(long vmGroupid) {
AutoScaleVmGroupVO vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
boolean success = true;
boolean success = false;
LoadBalancerVO loadBalancer = _lbDao.findById(vmGroup.getLoadBalancerId());
@ -289,7 +293,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
loadBalancer.setState(FirewallRule.State.Add);
_lbDao.persist(loadBalancer);
}
if (loadBalancer.getState() == FirewallRule.State.Active &&
else if (loadBalancer.getState() == FirewallRule.State.Active &&
vmGroup.getState().equals(AutoScaleVmGroup.State_Revoke)) {
loadBalancer.setState(FirewallRule.State.Add);
_lbDao.persist(loadBalancer);
@ -307,12 +311,11 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
if (!success) {
s_logger.warn("Failed to configure LB Auto Scale Vm Group with Id:" + vmGroupid);
if (isRollBackAllowedForProvider(loadBalancer)) {
loadBalancer.setState(backupState);
_lbDao.persist(loadBalancer);
s_logger.debug("LB Rollback rule id: " + loadBalancer.getId() + " lb state rolback while creating AutoscaleVmGroup");
loadBalancer.setState(backupState);
_lbDao.persist(loadBalancer);
s_logger.debug("LB Rollback rule id: " + loadBalancer.getId() + " lb state rolback while creating AutoscaleVmGroup");
}
}
}
success = false;
}
if (success) {
@ -883,7 +886,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
if (ipAddrId != null) {
ipVO = _ipAddressDao.findById(ipAddrId);
}
Network network = _networkMgr.getNetwork(lb.getNetworkId());
LoadBalancer result = _elbMgr.handleCreateLoadBalancerRule(lb, lbOwner, lb.getNetworkId());
@ -896,7 +899,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
lb.setSourceIpAddressId(systemIp.getId());
ipVO = _ipAddressDao.findById(systemIp.getId());
}
// Validate ip address
if (ipVO == null) {
throw new InvalidParameterValueException("Unable to create load balance rule; can't find/allocate source IP", null);
@ -906,13 +909,13 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
try {
if (ipVO.getAssociatedWithNetworkId() == null) {
boolean assignToVpcNtwk = network.getVpcId() != null
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");
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;
}

View File

@ -2375,7 +2375,6 @@ 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`),