Merge branch '3.0.x' of ssh://git.cloud.com/var/lib/git/cloudstack-oss into 3.0.x

This commit is contained in:
Pranav Saxena 2012-08-08 18:07:49 +05:30
commit 1dab5371cd
7 changed files with 61 additions and 50 deletions

View File

@ -301,5 +301,5 @@ public class EventTypes {
public static final String EVENT_AUTOSCALEVMGROUP_DELETE = "AUTOSCALEVMGROUP.DELETE";
public static final String EVENT_AUTOSCALEVMGROUP_UPDATE = "AUTOSCALEVMGROUP.UPDATE";
public static final String EVENT_AUTOSCALEVMGROUP_ENABLE = "AUTOSCALEVMGROUP.ENABLE";
public static final String EVENT_AUTOSCALEVMGROUP_DISABLE = "AUTOSCALEVMGROUP.DIABLE";
public static final String EVENT_AUTOSCALEVMGROUP_DISABLE = "AUTOSCALEVMGROUP.DISABLE";
}

View File

@ -42,8 +42,8 @@ import com.citrix.netscaler.nitro.resource.config.network.vlan_nsip_binding;
import com.citrix.netscaler.nitro.resource.config.ns.nsconfig;
import com.citrix.netscaler.nitro.resource.config.ns.nshardware;
import com.citrix.netscaler.nitro.resource.config.ns.nsip;
import com.citrix.netscaler.nitro.resource.config.timer.timerpolicy;
import com.citrix.netscaler.nitro.resource.config.timer.timertrigger_timerpolicy_binding;
import com.citrix.netscaler.nitro.resource.config.ns.nstimer;
import com.citrix.netscaler.nitro.resource.config.ns.nstimer_autoscalepolicy_binding;
import com.citrix.netscaler.nitro.resource.config.autoscale.*;
import com.citrix.netscaler.nitro.resource.stat.lb.lbvserver_stats;
import com.citrix.netscaler.nitro.service.nitro_service;
@ -238,7 +238,7 @@ public class NetscalerResource implements ServerResource {
if (!_isSdx) {
_netscalerService = new com.citrix.netscaler.nitro.service.nitro_service(_ip, "https");
_netscalerService.set_credential(_username, _password);
// _netscalerService.set_timeout(_timeout);
_netscalerService.set_timeout(_timeout);
apiCallResult = _netscalerService.login();
if (apiCallResult.errorcode != 0) {
throw new ExecutionException ("Failed to log in to Netscaler device at " + _ip + " due to error " + apiCallResult.errorcode + " and message " + apiCallResult.message);
@ -701,7 +701,7 @@ public class NetscalerResource implements ServerResource {
try {
nitro_service _netscalerService = new nitro_service(cmd.getLoadBalancerIP(), "https");
_netscalerService.set_credential(username, password);
// _netscalerService.set_timeout(_timeout);
_netscalerService.set_timeout(_timeout);
apiCallResult = _netscalerService.login();
if (apiCallResult.errorcode == 0) {
nsServiceUp = true;
@ -1367,15 +1367,15 @@ public class NetscalerResource implements ServerResource {
boolean vserverExisis = false;
lbvserver vserver = getVirtualServerIfExisits(virtualServerName);
if (vserver == null) {
vserver = new lbvserver();
} else {
if (vserver != null) {
if (!vserver.get_servicetype().equalsIgnoreCase(protocol)) {
throw new ExecutionException("Can not update virtual server:" + virtualServerName + " as current protocol:" + vserver.get_servicetype() + " of virtual server is different from the "
+ " intended protocol:" + protocol);
}
vserverExisis = true;
}
// Use new vserver always for configuration
vserver = new lbvserver();
vserver.set_name(virtualServerName);
vserver.set_ipv46(publicIp);
vserver.set_port(publicPort);
@ -1419,16 +1419,8 @@ public class NetscalerResource implements ServerResource {
// set session persistence timeout
vserver.set_timeout(timeout);
} else {
if (vserver.get_persistencetype() != null) {
// delete the LB stickyness policy
vserver.set_persistencetype("NONE");
}
}
if(vmGroupTO != null) {
vserver.set_mysqlcharacterset(null);
vserver.set_mysqlprotocolversion(null);
vserver.set_mysqlservercapabilities(null);
vserver.set_mysqlserverversion(null);
// delete the LB stickyness policy
vserver.set_persistencetype("NONE");
}
@ -1557,7 +1549,9 @@ public class NetscalerResource implements ServerResource {
String nsVirtualServerName = generateNSVirtualServerName(srcIp, srcPort);
String serviceGroupName = generateAutoScaleServiceGroupName(srcIp, srcPort);
disableAutoScaleConfig(loadBalancerTO, false);
if(loadBalancerTO.getAutoScaleVmGroupTO().getState().equals("enabled")) {
disableAutoScaleConfig(loadBalancerTO, false);
}
if(isServiceGroupBoundToVirtualServer(nsVirtualServerName, serviceGroupName)) {
// UnBind autoscale service group
@ -1648,7 +1642,7 @@ public class NetscalerResource implements ServerResource {
}
// Add Timer
com.citrix.netscaler.nitro.resource.config.timer.timertrigger timer = new com.citrix.netscaler.nitro.resource.config.timer.timertrigger();
nstimer timer = new nstimer();
try {
timer.set_name(timerName);
timer.set_interval(interval);
@ -1945,7 +1939,7 @@ public class NetscalerResource implements ServerResource {
}
// Delete Timer
com.citrix.netscaler.nitro.resource.config.timer.timertrigger timer = new com.citrix.netscaler.nitro.resource.config.timer.timertrigger();
nstimer timer = new nstimer();
try {
timer.set_name(timerName);
timer.delete(_netscalerService, timer);
@ -2017,7 +2011,7 @@ public class NetscalerResource implements ServerResource {
// Adding a autoscale policy
// add timer policy lb_policy_scaleUp_cpu_mem -rule - (SYS.CUR_VSERVER.METRIC_TABLE(cpu).AVG_VAL.GT(80)-
// -action lb_scaleUpAction
timerpolicy timerPolicy = new timerpolicy();
autoscalepolicy timerPolicy = new autoscalepolicy();
try {
timerPolicy.set_name(policyName);
timerPolicy.set_action(action);
@ -2033,7 +2027,7 @@ public class NetscalerResource implements ServerResource {
// bind timer trigger lb_astimer -policyName lb_policy_scaleUp -vserver lb -priority 1 -samplesize 5
// TODO: later bind to lbvserver. bind timer trigger lb_astimer -policyName lb_policy_scaleUp -vserver lb -priority 1 -samplesize 5
// -thresholdsize 5
timertrigger_timerpolicy_binding timer_policy_binding = new timertrigger_timerpolicy_binding();
nstimer_autoscalepolicy_binding timer_policy_binding = new nstimer_autoscalepolicy_binding();
int sampleSize = duration/interval;
try {
timer_policy_binding.set_name(timerName);
@ -2053,7 +2047,7 @@ public class NetscalerResource implements ServerResource {
private void removeAutoScalePolicy(String timerName, String policyName, boolean isCleanUp) throws Exception {
// unbind timer policy
// unbbind timer trigger lb_astimer -policyName lb_policy_scaleUp
com.citrix.netscaler.nitro.resource.config.timer.timertrigger_timerpolicy_binding timer_policy_binding = new com.citrix.netscaler.nitro.resource.config.timer.timertrigger_timerpolicy_binding();
nstimer_autoscalepolicy_binding timer_policy_binding = new nstimer_autoscalepolicy_binding();
try {
timer_policy_binding.set_name(timerName);
timer_policy_binding.set_policyname(policyName);
@ -2066,7 +2060,7 @@ public class NetscalerResource implements ServerResource {
// Removing Timer policy
// rm timer policy lb_policy_scaleUp_cpu_mem
com.citrix.netscaler.nitro.resource.config.timer.timerpolicy timerPolicy = new com.citrix.netscaler.nitro.resource.config.timer.timerpolicy();
autoscalepolicy timerPolicy = new autoscalepolicy();
try {
timerPolicy.set_name(policyName);
timerPolicy.delete(_netscalerService, timerPolicy);
@ -2278,8 +2272,4 @@ public class NetscalerResource implements ServerResource {
public void disconnected() {
return;
}
}

Binary file not shown.

View File

@ -250,7 +250,7 @@ def setLinkLocalIP(session, args):
except:
return 'can not cat network.conf'
if result.lower() == "bridge":
if result.lower().strip() == "bridge":
try:
cmd = ["brctl", "addbr", brName]
txt = util.pread2(cmd)

View File

@ -719,14 +719,15 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
return vmGroup.getLoadBalancerId() != null;
}
public boolean configureAutoScaleVmGroup(long vmGroupid) {
private boolean configureAutoScaleVmGroup(long vmGroupid) throws InvalidParameterValueException {
AutoScaleVmGroup vmGroup = _autoScaleVmGroupDao.findById(vmGroupid);
if (isLoadBalancerBasedAutoScaleVmGroup(vmGroup)) {
try {
return _lbRulesMgr.configureLbAutoScaleVmGroup(vmGroupid);
} catch (RuntimeException re) {
s_logger.warn("Exception during configureLbAutoScaleVmGrouop in lb rules manager", re);
} catch (Exception e) {
s_logger.warn("Exception during configureLbAutoScaleVmGroup in lb rules manager", e);
return false;
}
}

View File

@ -216,6 +216,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
@Inject
VpcManager _vpcMgr;
// Will return a string. For LB Stickiness this will be a json, for autoscale this will be "," separated values
@Override
public String getLBCapability(long networkid, String capabilityName) {
@ -226,7 +227,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
serviceResponse.setName(service.getName());
if ("Lb".equalsIgnoreCase(service.getName())) {
Map<Capability, String> serviceCapabilities = serviceCapabilitiesMap
.get(service);
.get(service);
if (serviceCapabilities != null) {
for (Capability capability : serviceCapabilities
.keySet()) {
@ -278,7 +279,12 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
return new LbAutoScaleVmGroup(vmGroup, autoScalePolicies, lbAutoScaleVmProfile);
}
private boolean applyAutoScaleConfig(LoadBalancerVO lb, LoadBalancingRule rule) throws ResourceUnavailableException {
private boolean applyAutoScaleConfig(LoadBalancerVO lb, AutoScaleVmGroupVO vmGroup) throws ResourceUnavailableException {
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup);
/* 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.
return false;
@ -314,12 +320,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
_lbDao.persist(loadBalancer);
}
// LBTODO
try {
LbAutoScaleVmGroup lbAutoScaleVmGroup = getLbAutoScaleVmGroup(vmGroup);
LoadBalancingRule rule = new LoadBalancingRule(loadBalancer, null, null);
rule.setAutoScaleVmGroup(lbAutoScaleVmGroup);
success = applyAutoScaleConfig(loadBalancer, rule);
success = applyAutoScaleConfig(loadBalancer, vmGroup);
} catch (ResourceUnavailableException e) {
s_logger.warn("Unable to configure AutoScaleVmGroup to the lb rule: " + loadBalancer.getId() + " because resource is unavaliable:", e);
} finally {
@ -839,9 +841,18 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
if (apply) {
try {
if (!applyLoadBalancerConfig(loadBalancerId)) {
s_logger.warn("Unable to apply the load balancer config");
return false;
if (_autoScaleVmGroupDao.isAutoScaleLoadBalancer(loadBalancerId)) {
// Get the associated VmGroup
AutoScaleVmGroupVO vmGroup = _autoScaleVmGroupDao.listByAll(loadBalancerId, null).get(0);
if (!applyAutoScaleConfig(lb, vmGroup)) {
s_logger.warn("Unable to apply the autoscale config");
return false;
}
} else {
if (!applyLoadBalancerConfig(loadBalancerId)) {
s_logger.warn("Unable to apply the load balancer config");
return false;
}
}
} catch (ResourceUnavailableException e) {
if (rollBack && isRollBackAllowedForProvider(lb)) {
@ -925,7 +936,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
try {
if (ipVO.getAssociatedWithNetworkId() == null) {
boolean assignToVpcNtwk = network.getVpcId() != null
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
&& ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
if (assignToVpcNtwk) {
// set networkId just for verification purposes
_networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());

View File

@ -639,6 +639,9 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
Pair<VolumeVO, String> volumeDetails = createVolumeFromSnapshot(volume, snapshot);
if (volumeDetails != null) {
createdVolume = volumeDetails.first();
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, createdVolume.getAccountId(), createdVolume.getDataCenterId(), createdVolume.getId(), createdVolume.getName(),
createdVolume.getDiskOfferingId(), null, createdVolume.getSize());
_usageEventDao.persist(usageEvent);
}
return createdVolume;
}
@ -1993,8 +1996,11 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
volume.setDomainId((caller == null) ? Domain.ROOT_DOMAIN : caller.getDomainId());
volume = _volsDao.persist(volume);
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId, null, size);
_usageEventDao.persist(usageEvent);
if(cmd.getSnapshotId() == null){
//for volume created from snapshot, create usage event after volume creation
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_CREATE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(), volume.getName(), diskOfferingId, null, size);
_usageEventDao.persist(usageEvent);
}
UserContext.current().setEventDetails("Volume Id: " + volume.getId());
@ -3220,7 +3226,8 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
if (s_logger.isDebugEnabled()) {
s_logger.debug("Mismatch in storage pool " + assignedPool + " assigned by deploymentPlanner and the one associated with volume " + vol);
}
if (vm.getServiceOffering().getUseLocalStorage())
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId());
if (diskOffering.getUseLocalStorage())
{
if (s_logger.isDebugEnabled()) {
s_logger.debug("Local volume " + vol + " will be recreated on storage pool " + assignedPool + " assigned by deploymentPlanner");
@ -3231,10 +3238,12 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner");
}
try {
Volume migratedVol = migrateVolume(vol.getId(), assignedPool.getId());
vm.addDisk(new VolumeTO(migratedVol, assignedPool));
List<Volume> volumesToMigrate = new ArrayList<Volume>();
volumesToMigrate.add(vol);
migrateVolumes(volumesToMigrate, assignedPool);
vm.addDisk(new VolumeTO(vol, assignedPool));
} catch (ConcurrentOperationException e) {
throw new StorageUnavailableException("Volume migration failed for " + vol, Volume.class, vol.getId());
throw new CloudRuntimeException("Migration of volume " + vol + " to storage pool " + assignedPool + " failed", e);
}
}
} else {