mirror of https://github.com/apache/cloudstack.git
Merge branch '3.0.x' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 3.0.x
This commit is contained in:
commit
e4e425067c
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -548,7 +548,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
throw new Exception(" vpc network usage plugin call failed ");
|
||||
}
|
||||
|
||||
if (option.equals("get")) {
|
||||
if (option.equals("get") || option.equals("vpn")) {
|
||||
String result = resultPair.second();
|
||||
if (result == null || result.isEmpty()) {
|
||||
throw new Exception(" vpc network usage get returns empty ");
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public class XenServer56Resource extends CitrixResourceBase {
|
|||
}
|
||||
|
||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||
if (option.equals("get")) {
|
||||
if (option.equals("get") || option.equals("vpn")) {
|
||||
long[] stats = new long[2];
|
||||
if (result != null) {
|
||||
String[] splitResult = result.split(":");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ create_usage_rules () {
|
|||
then
|
||||
iptables -N NETWORK_STATS_$ethDev > /dev/null;
|
||||
iptables -I FORWARD -j NETWORK_STATS_$ethDev > /dev/null;
|
||||
iptables -A NETWORK_STATS_$ethDev -i $ethDev -d $vcidr > /dev/null;
|
||||
iptables -A NETWORK_STATS_$ethDev -o $ethDev -s $vcidr > /dev/null;
|
||||
iptables -A NETWORK_STATS_$ethDev -i $ethDev -d $vcidr > /dev/null;
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
|
@ -46,8 +46,8 @@ create_vpn_usage_rules () {
|
|||
then
|
||||
iptables -t mangle -N VPN_STATS_$ethDev > /dev/null;
|
||||
iptables -t mangle -I FORWARD -j VPN_STATS_$ethDev > /dev/null;
|
||||
iptables -t mangle -A VPN_STATS_$ethDev -i $ethDev -m mark --mark $vpninmark > /dev/null;
|
||||
iptables -t mangle -A VPN_STATS_$ethDev -o $ethDev -m mark --mark $vpnoutmark > /dev/null;
|
||||
iptables -t mangle -A VPN_STATS_$ethDev -i $ethDev -m mark --mark $vpninmark > /dev/null;
|
||||
fi
|
||||
return $?
|
||||
}
|
||||
|
|
@ -69,8 +69,10 @@ get_usage () {
|
|||
then
|
||||
# flush rules and remove chain
|
||||
iptables -F NETWORK_STATS_$i > /dev/null;
|
||||
iptables -D FORWARD -j NETWORK_STATS_$i > /dev/null;
|
||||
iptables -X NETWORK_STATS_$i > /dev/null;
|
||||
iptables -t mangle -F VPN_STATS_$i > /dev/null;
|
||||
iptables -t mangle -D FORWARD -j VPN_STATS_$i > /dev/null;
|
||||
iptables -t mangle -X VPN_STATS_$i > /dev/null;
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue