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){
return Float.parseFloat(cpuovercommitratio);
}
return 1.0f;
return null;
}
public Float getMemoryOvercommitRaito (){
if (memoryovercommitratio != null){
return Float.parseFloat(memoryovercommitratio);
}
return 1.0f;
return null;
}
@Override
@ -127,9 +127,16 @@ public class UpdateClusterCmd extends BaseCmd {
if (cluster == null) {
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)) {
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should be greater than one");
if (getCpuOvercommitRatio() !=null){
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());

View File

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