CLOUDSTACK-1534 Disable/Enable-unmanaged/manage cluster is setting CPU overcommit and memory overcommit ratio to 1 (defalut value).

Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
This commit is contained in:
Bharat Kumar 2013-04-09 10:27:05 +05:30 committed by Abhinandan Prateek
parent cbcb83b086
commit 580731ccc0
2 changed files with 16 additions and 21 deletions

View File

@ -111,14 +111,14 @@ public class UpdateClusterCmd extends BaseCmd {
if(cpuovercommitratio != null){ if(cpuovercommitratio != null){
return Float.parseFloat(cpuovercommitratio); return Float.parseFloat(cpuovercommitratio);
} }
return 1.0f; return null;
} }
public Float getMemoryOvercommitRaito (){ public Float getMemoryOvercommitRaito (){
if (memoryovercommitratio != null){ if (memoryovercommitratio != null){
return Float.parseFloat(memoryovercommitratio); return Float.parseFloat(memoryovercommitratio);
} }
return 1.0f; return null;
} }
@Override @Override
@ -127,9 +127,16 @@ public class UpdateClusterCmd extends BaseCmd {
if (cluster == null) { if (cluster == null) {
throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId()); throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
} }
if (getMemoryOvercommitRaito() !=null){
if ((getMemoryOvercommitRaito().compareTo(1f) < 0)) {
throw new InvalidParameterValueException("Memory overcommit ratio should be greater than or equal to one");
}
}
if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) { if (getCpuOvercommitRatio() !=null){
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should be greater than one"); if (getCpuOvercommitRatio().compareTo(1f) < 0) {
throw new InvalidParameterValueException("Cpu overcommit ratio should be greater than or equal to one");
}
} }
Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate(), getMemoryOvercommitRaito(), getCpuOvercommitRatio()); Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate(), getMemoryOvercommitRaito(), getCpuOvercommitRatio());

View File

@ -1181,29 +1181,17 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
} }
} }
ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio"); if (memoryovercommitratio != null) {
if( memory_detail == null){ ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio");
if (memoryovercommitratio.compareTo(1f) > 0){
memory_detail = new ClusterDetailsVO(cluster.getId(),"memoryOvercommitRatio",Float.toString(memoryovercommitratio));
_clusterDetailsDao.persist(memory_detail);
}
}
else {
memory_detail.setValue(Float.toString(memoryovercommitratio)); memory_detail.setValue(Float.toString(memoryovercommitratio));
_clusterDetailsDao.update(memory_detail.getId(),memory_detail); _clusterDetailsDao.update(memory_detail.getId(),memory_detail);
} }
ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio"); if (cpuovercommitratio != null) {
if( cpu_detail == null){ ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio");
if (cpuovercommitratio.compareTo(1f) > 0){
cpu_detail = new ClusterDetailsVO(cluster.getId(),"cpuOvercommitRatio",Float.toString(cpuovercommitratio));
_clusterDetailsDao.persist(cpu_detail);
}
}
else {
cpu_detail.setValue(Float.toString(cpuovercommitratio)); cpu_detail.setValue(Float.toString(cpuovercommitratio));
_clusterDetailsDao.update(cpu_detail.getId(),cpu_detail); _clusterDetailsDao.update(cpu_detail.getId(),cpu_detail);
} }
if (doUpdate) { if (doUpdate) {