mirror of https://github.com/apache/cloudstack.git
CS-15927 : Able to add autoscale VMs to static LB rule
First Part: AutoScale Vms are named as "AutoScale-LB-<lbname>"
This could be used by UI and have filter mechanism to not display
autoscale vms during the "Add Vms" dialog for a non autoscaled
lb rule.
This commit is contained in:
parent
4eb88fc686
commit
f2aeb9351f
|
|
@ -287,10 +287,11 @@ public class LoadBalancerTO implements Serializable {
|
|||
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;
|
||||
|
|
@ -302,6 +303,7 @@ public class LoadBalancerTO implements Serializable {
|
|||
this.cloudStackApiUrl = cloudStackApiUrl;
|
||||
this.autoScaleUserApiKey = autoScaleUserApiKey;
|
||||
this.autoScaleUserSecretKey = autoScaleUserSecretKey;
|
||||
this.vmName = vmName;
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
|
|
@ -349,6 +351,10 @@ public class LoadBalancerTO implements Serializable {
|
|||
return autoScaleUserSecretKey;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public String getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
|
@ -433,9 +439,9 @@ public class LoadBalancerTO implements Serializable {
|
|||
|
||||
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(),
|
||||
|
|
|
|||
|
|
@ -308,8 +308,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;
|
||||
|
|
@ -318,6 +319,7 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
|
|||
this.domainId = domainId;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
this.templateId = templateId;
|
||||
this.vmName = vmName;
|
||||
this.networkId = networkId;
|
||||
}
|
||||
|
||||
|
|
@ -353,6 +355,10 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
|
|||
return templateId;
|
||||
}
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
public String getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1717,6 +1717,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();
|
||||
|
|
|
|||
|
|
@ -250,7 +250,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) {
|
||||
|
|
@ -274,6 +276,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());
|
||||
|
|
@ -281,7 +284,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
throw new InvalidParameterValueException("Unable to find zone by id", null);
|
||||
} else {
|
||||
if (zone.getNetworkType() == NetworkType.Advanced) {
|
||||
NetworkVO lbNetwork = _networkDao.findById(networkId);
|
||||
NetworkVO lbNetwork = _networkDao.findById(lbNetworkId);
|
||||
lbNetworkUuid = lbNetwork.getUuid();
|
||||
}
|
||||
}
|
||||
|
|
@ -300,12 +303,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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue