enable Autoscale VMs to be named as Autoscale-LB-<lbname>

This commit is contained in:
Vijay Vekatachalam 2012-09-27 20:17:09 +05:30 committed by Vijay Venkatachalam
parent 57416188a2
commit 35b0e086d4
5 changed files with 30 additions and 14 deletions

View File

@ -288,10 +288,11 @@ public class LoadBalancerTO {
private final String cloudStackApiUrl;
private final String autoScaleUserApiKey;
private final String autoScaleUserSecretKey;
private final String vmName;
private final String networkId;
public AutoScaleVmProfileTO(String zoneId, String domainId, String cloudStackApiUrl, String autoScaleUserApiKey, String autoScaleUserSecretKey, String serviceOfferingId,
String templateId, String networkId, String otherDeployParams, String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod) {
String templateId, String vmName, String networkId, String otherDeployParams, String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod) {
this.zoneId = zoneId;
this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId;
@ -303,6 +304,7 @@ public class LoadBalancerTO {
this.cloudStackApiUrl = cloudStackApiUrl;
this.autoScaleUserApiKey = autoScaleUserApiKey;
this.autoScaleUserSecretKey = autoScaleUserSecretKey;
this.vmName = vmName;
this.networkId = networkId;
}
@ -350,6 +352,10 @@ public class LoadBalancerTO {
return autoScaleUserSecretKey;
}
public String getVmName() {
return vmName;
}
public String getNetworkId() {
return networkId;
}
@ -434,9 +440,9 @@ public class LoadBalancerTO {
AutoScaleVmProfileTO autoScaleVmProfileTO = new AutoScaleVmProfileTO(lbAutoScaleVmProfile.getZoneId(), lbAutoScaleVmProfile.getDomainId(),
lbAutoScaleVmProfile.getCsUrl(), lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(),
lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(), lbAutoScaleVmProfile.getNetworkId(),
autoScaleVmProfile.getOtherDeployParams(), autoScaleVmProfile.getSnmpCommunity(), autoScaleVmProfile.getSnmpPort(),
autoScaleVmProfile.getDestroyVmGraceperiod());
lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(), lbAutoScaleVmProfile.getVmName(),
lbAutoScaleVmProfile.getNetworkId(),autoScaleVmProfile.getOtherDeployParams(), autoScaleVmProfile.getSnmpCommunity(),
autoScaleVmProfile.getSnmpPort(), autoScaleVmProfile.getDestroyVmGraceperiod());
AutoScaleVmGroup autoScaleVmGroup = lbAutoScaleVmGroup.getVmGroup();
autoScaleVmGroupTO = new AutoScaleVmGroupTO(autoScaleVmGroup.getMinMembers(), autoScaleVmGroup.getMaxMembers(), autoScaleVmGroup.getMemberPort(),

View File

@ -307,8 +307,9 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
private final String serviceOfferingId;
private final String templateId;
private final String networkId;
private final String vmName;
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey, String autoScaleUserSecretKey, String csUrl, String zoneId, String domainId, String serviceOfferingId, String templateId, String networkId) {
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey, String autoScaleUserSecretKey, String csUrl, String zoneId, String domainId, String serviceOfferingId, String templateId, String vmName, String networkId) {
this.profile = profile;
this.autoScaleUserApiKey = autoScaleUserApiKey;
this.autoScaleUserSecretKey = autoScaleUserSecretKey;
@ -317,6 +318,7 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId;
this.templateId = templateId;
this.vmName = vmName;
this.networkId = networkId;
}
@ -352,6 +354,10 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
return templateId;
}
public String getVmName() {
return vmName;
}
public String getNetworkId() {
return networkId;
}

View File

@ -240,11 +240,11 @@ public class NetscalerResource implements ServerResource {
private void logout() throws ExecutionException {
try {
if (!_isSdx) {
if (_netscalerService != null) {
if(_netscalerService != null) {
_netscalerService.logout();
}
} else {
if (_netscalerSdxService != null) {
if(_netscalerSdxService != null) {
_netscalerSdxService.logout();
}
}
@ -1569,11 +1569,11 @@ public class NetscalerResource implements ServerResource {
String nsVirtualServerName = generateNSVirtualServerName(srcIp, srcPort);
String serviceGroupName = generateAutoScaleServiceGroupName(vmGroupIdentifier);
if (loadBalancerTO.getAutoScaleVmGroupTO().getCurrentState().equals("enabled")) {
if(loadBalancerTO.getAutoScaleVmGroupTO().getCurrentState().equals("enabled")) {
disableAutoScaleConfig(loadBalancerTO, false);
}
if (isServiceGroupBoundToVirtualServer(nsVirtualServerName, serviceGroupName)) {
if(isServiceGroupBoundToVirtualServer(nsVirtualServerName, serviceGroupName)) {
// UnBind autoscale service group
// unbind lb vserver lb lb_autoscaleGroup
lbvserver_servicegroup_binding vserver_servicegroup_binding = new lbvserver_servicegroup_binding();
@ -1713,6 +1713,7 @@ public class NetscalerResource implements ServerResource {
ApiConstants.ZONE_ID + "=" + profileTO.getZoneId()+ "&" +
ApiConstants.SERVICE_OFFERING_ID + "=" + profileTO.getServiceOfferingId()+ "&" +
ApiConstants.TEMPLATE_ID + "=" + profileTO.getTemplateId()+ "&" +
ApiConstants.DISPLAY_NAME + "=" + profileTO.getVmName()+ "&" +
((profileTO.getNetworkId() == null)? "" : (ApiConstants.NETWORK_IDS + "=" + profileTO.getNetworkId()+ "&")) +
((profileTO.getOtherDeployParams() == null)? "" : (profileTO.getOtherDeployParams() + "&")) +
"lbruleid=" + loadBalancerTO.getUuid();

View File

@ -251,7 +251,9 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
}
return null;
}
private LbAutoScaleVmGroup getLbAutoScaleVmGroup(AutoScaleVmGroupVO vmGroup, String currentState, long networkId) {
private LbAutoScaleVmGroup getLbAutoScaleVmGroup(AutoScaleVmGroupVO vmGroup, String currentState, LoadBalancerVO lb) {
long lbNetworkId = lb.getNetworkId();
String lbName = lb.getName();
List<AutoScaleVmGroupPolicyMapVO> vmGroupPolicyMapList = _autoScaleVmGroupPolicyMapDao.listByVmGroupId(vmGroup.getId());
List<LbAutoScalePolicy> autoScalePolicies = new ArrayList<LbAutoScalePolicy>();
for (AutoScaleVmGroupPolicyMapVO vmGroupPolicyMap : vmGroupPolicyMapList) {
@ -275,6 +277,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
String domainId = _domainDao.findById(autoScaleVmProfile.getDomainId()).getUuid();
String serviceOfferingId = _offeringsDao.findById(autoScaleVmProfile.getServiceOfferingId()).getUuid();
String templateId = _templateDao.findById(autoScaleVmProfile.getTemplateId()).getUuid();
String vmName = "AutoScale-LB-" + lbName;
String lbNetworkUuid = null;
DataCenter zone = _configMgr.getZone(vmGroup.getZoneId());
@ -284,7 +287,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
throw new InvalidParameterValueException("Unable to find zone");
} else {
if (zone.getNetworkType() == NetworkType.Advanced) {
NetworkVO lbNetwork = _networkDao.findById(networkId);
NetworkVO lbNetwork = _networkDao.findById(lbNetworkId);
lbNetworkUuid = lbNetwork.getUuid();
}
}
@ -303,12 +306,12 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
}
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, apiKey, secretKey, csUrl, zoneId, domainId, serviceOfferingId, templateId, lbNetworkUuid);
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, apiKey, secretKey, csUrl, zoneId, domainId, serviceOfferingId, templateId, vmName, lbNetworkUuid);
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile, currentState);
}
private boolean applyAutoScaleConfig(LoadBalancerVO lb, AutoScaleVmGroupVO vmGroup, String currentState) throws ResourceUnavailableException {
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, currentState, lb.getNetworkId());
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, currentState, lb);
/* Regular config like destinations need not be packed for applying autoscale config as of today.*/
LoadBalancingRule rule = new LoadBalancingRule(lb, null, null);
rule.setAutoScaleVmGroup(lbAutoScaleVmGroup);

View File

@ -2508,6 +2508,6 @@ CREATE TABLE `cloud`.`autoscale_vmgroup_policy_map` (
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (1,'snmp','Linux User CPU - percentage', '1.3.6.1.4.1.2021.11.9.0', now());
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (2,'snmp','Linux System CPU - percentage', '1.3.6.1.4.1.2021.11.10.0', now());
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (3,'snmp','Linux CPU Idle - percentage', '1.3.6.1.4.1.2021.11.11.0', now());
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (100,'netscaler','Response Time - microseconds)', 'RESPTIME', now());
INSERT INTO `cloud`.`counter` (id, source, name, value,created) VALUES (100,'netscaler','Response Time - microseconds', 'RESPTIME', now());
SET foreign_key_checks = 1;