CS-15938. Support for multiple guest networks with autoscale

The loadbalancers network and the VM's network are the same.
Hence not getting the input from user and passing the loadbalancers network
for the AutoScale VMs (for advanced network).
This commit is contained in:
Vijay 2012-08-14 16:30:44 +05:30
parent e5710e953a
commit d9b843ed9d
5 changed files with 42 additions and 9 deletions

View File

@ -287,9 +287,10 @@ public class LoadBalancerTO implements Serializable {
private final String cloudStackApiUrl;
private final String autoScaleUserApiKey;
private final String autoScaleUserSecretKey;
private final String networkId;
public AutoScaleVmProfileTO(String zoneId, String domainId, String cloudStackApiUrl, String autoScaleUserApiKey, String autoScaleUserSecretKey, String serviceOfferingId, String templateId,
String otherDeployParams, String snmpCommunity, Integer snmpPort, Integer destroyVmGraceperiod) {
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) {
this.zoneId = zoneId;
this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId;
@ -301,6 +302,7 @@ public class LoadBalancerTO implements Serializable {
this.cloudStackApiUrl = cloudStackApiUrl;
this.autoScaleUserApiKey = autoScaleUserApiKey;
this.autoScaleUserSecretKey = autoScaleUserSecretKey;
this.networkId = networkId;
}
public String getZoneId() {
@ -346,6 +348,10 @@ public class LoadBalancerTO implements Serializable {
public String getAutoScaleUserSecretKey() {
return autoScaleUserSecretKey;
}
public String getNetworkId() {
return networkId;
}
}
public static class AutoScaleVmGroupTO implements Serializable {
@ -427,8 +433,9 @@ public class LoadBalancerTO implements Serializable {
AutoScaleVmProfileTO autoScaleVmProfileTO = new AutoScaleVmProfileTO(lbAutoScaleVmProfile.getZoneId(), lbAutoScaleVmProfile.getDomainId(),
lbAutoScaleVmProfile.getCsUrl(), lbAutoScaleVmProfile.getAutoScaleUserApiKey(), lbAutoScaleVmProfile.getAutoScaleUserSecretKey(),
lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(), autoScaleVmProfile.getOtherDeployParams(),
autoScaleVmProfile.getSnmpCommunity(), autoScaleVmProfile.getSnmpPort(), autoScaleVmProfile.getDestroyVmGraceperiod());
lbAutoScaleVmProfile.getServiceOfferingId(), lbAutoScaleVmProfile.getTemplateId(), 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 domainId;
private final String serviceOfferingId;
private final String templateId;
private final String networkId;
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey, String autoScaleUserSecretKey, String csUrl, String zoneId, String domainId, String serviceOfferingId, String templateId) {
public LbAutoScaleVmProfile(AutoScaleVmProfile profile, String autoScaleUserApiKey, String autoScaleUserSecretKey, String csUrl, String zoneId, String domainId, String serviceOfferingId, String templateId, 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.networkId = networkId;
}
public AutoScaleVmProfile getProfile() {
@ -350,6 +352,10 @@ public class LoadBalancingRule implements FirewallRule, LoadBalancer {
public String getTemplateId() {
return templateId;
}
public String getNetworkId() {
return networkId;
}
}
public static class LbAutoScaleVmGroup {

View File

@ -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()+ "&" +
((profileTO.getNetworkId() == null)? "" : (ApiConstants.NETWORK_IDS + "=" + profileTO.getNetworkId()+ "&")) +
((profileTO.getOtherDeployParams() == null)? "" : (profileTO.getOtherDeployParams() + "&")) +
"lbruleid=" + loadBalancerTO.getUuid();
scaleUpAction.set_parameters(scaleUpParameters);

View File

@ -315,6 +315,9 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
// validations
HashMap<String, String> deployParams = cmd.getDeployParamMap();
if(deployParams.containsKey("networks") && deployParams.get("networks").length() > 0) {
throw new InvalidParameterValueException("'networks' is not a valid parameter, network for an AutoScaled VM is chosen automatically. An autoscaled VM is deployed in the loadbalancer's network", null);
}
/*
* Just for making sure the values are right in other deploy params.
* For ex. if projectId is given as a string instead of an long value, this

View File

@ -38,6 +38,8 @@ 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.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.domain.dao.DomainDao;
@ -248,7 +250,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
return null;
}
private LbAutoScaleVmGroup getLbAutoScaleVmGroup(AutoScaleVmGroup vmGroup, String currentState) {
private LbAutoScaleVmGroup getLbAutoScaleVmGroup(AutoScaleVmGroupVO vmGroup, String currentState, long networkId) {
List<AutoScaleVmGroupPolicyMapVO> vmGroupPolicyMapList = _autoScaleVmGroupPolicyMapDao.listByVmGroupId(vmGroup.getId());
List<LbAutoScalePolicy> autoScalePolicies = new ArrayList<LbAutoScalePolicy>();
for (AutoScaleVmGroupPolicyMapVO vmGroupPolicyMap : vmGroupPolicyMapList) {
@ -272,6 +274,18 @@ 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 lbNetworkUuid = null;
DataCenter zone = _configMgr.getZone(vmGroup.getZoneId());
if (zone == null) {
throw new InvalidParameterValueException("Unable to find zone by id", null);
} else {
if (zone.getNetworkType() == NetworkType.Advanced) {
NetworkVO lbNetwork = _networkDao.findById(networkId);
lbNetworkUuid = lbNetwork.getUuid();
}
}
if (apiKey == null) {
throw new InvalidParameterValueException("apiKey for user: " + user.getUsername() + " is empty. Please generate it", null);
@ -285,18 +299,19 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
throw new InvalidParameterValueException("Global setting endpointe.url has to be set to the Management Server's API end point", null);
}
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, apiKey, secretKey, csUrl, zoneId, domainId, serviceOfferingId, templateId);
LbAutoScaleVmProfile lbAutoScaleVmProfile = new LbAutoScaleVmProfile(autoScaleVmProfile, apiKey, secretKey, csUrl, zoneId, domainId, serviceOfferingId, templateId, lbNetworkUuid);
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile, currentState);
}
private boolean applyAutoScaleConfig(LoadBalancerVO lb, AutoScaleVmGroupVO vmGroup, String currentState) throws ResourceUnavailableException {
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, currentState);
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup, currentState, lb.getNetworkId());
/* 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);
if (!isRollBackAllowedForProvider(lb)) {
// this is for Netscalar type of devices. if their is failure the db entries will be rollbacked.
// this is for Netscaler type of devices. if their is failure the db entries will be rollbacked.
return false;
}
@ -714,6 +729,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancerId)) {
// Nothing needs to be done for an autoscaled loadbalancer,
// just persist and proceed.
_lb2VmMapDao.remove(loadBalancer.getId(), instanceIds, null);
return true;
}