Skip to content

Commit 580731c

Browse files
bvbharatAbhinandan Prateek
authored andcommitted
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>
1 parent cbcb83b commit 580731c

2 files changed

Lines changed: 16 additions & 21 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ public Float getCpuOvercommitRatio (){
111111
if(cpuovercommitratio != null){
112112
return Float.parseFloat(cpuovercommitratio);
113113
}
114-
return 1.0f;
114+
return null;
115115
}
116116

117117
public Float getMemoryOvercommitRaito (){
118118
if (memoryovercommitratio != null){
119119
return Float.parseFloat(memoryovercommitratio);
120120
}
121-
return 1.0f;
121+
return null;
122122
}
123123

124124
@Override
@@ -127,9 +127,16 @@ public void execute(){
127127
if (cluster == null) {
128128
throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
129129
}
130+
if (getMemoryOvercommitRaito() !=null){
131+
if ((getMemoryOvercommitRaito().compareTo(1f) < 0)) {
132+
throw new InvalidParameterValueException("Memory overcommit ratio should be greater than or equal to one");
133+
}
134+
}
130135

131-
if ((getMemoryOvercommitRaito().compareTo(1f) < 0) | (getCpuOvercommitRatio().compareTo(1f) < 0)) {
132-
throw new InvalidParameterValueException("Cpu and ram overcommit ratios should be greater than one");
136+
if (getCpuOvercommitRatio() !=null){
137+
if (getCpuOvercommitRatio().compareTo(1f) < 0) {
138+
throw new InvalidParameterValueException("Cpu overcommit ratio should be greater than or equal to one");
139+
}
133140
}
134141

135142
Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate(), getMemoryOvercommitRaito(), getCpuOvercommitRatio());

‎server/src/com/cloud/resource/ResourceManagerImpl.java‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,29 +1181,17 @@ public Cluster updateCluster(Cluster clusterToUpdate, String clusterType,
11811181
}
11821182
}
11831183

1184-
ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio");
1185-
if( memory_detail == null){
1186-
if (memoryovercommitratio.compareTo(1f) > 0){
1187-
memory_detail = new ClusterDetailsVO(cluster.getId(),"memoryOvercommitRatio",Float.toString(memoryovercommitratio));
1188-
_clusterDetailsDao.persist(memory_detail);
1189-
}
1190-
}
1191-
else {
1184+
if (memoryovercommitratio != null) {
1185+
ClusterDetailsVO memory_detail = _clusterDetailsDao.findDetail(cluster.getId(),"memoryOvercommitRatio");
11921186
memory_detail.setValue(Float.toString(memoryovercommitratio));
11931187
_clusterDetailsDao.update(memory_detail.getId(),memory_detail);
11941188
}
11951189

1196-
ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio");
1197-
if( cpu_detail == null){
1198-
if (cpuovercommitratio.compareTo(1f) > 0){
1199-
cpu_detail = new ClusterDetailsVO(cluster.getId(),"cpuOvercommitRatio",Float.toString(cpuovercommitratio));
1200-
_clusterDetailsDao.persist(cpu_detail);
1201-
}
1202-
}
1203-
else {
1190+
if (cpuovercommitratio != null) {
1191+
ClusterDetailsVO cpu_detail = _clusterDetailsDao.findDetail(cluster.getId(),"cpuOvercommitRatio");
12041192
cpu_detail.setValue(Float.toString(cpuovercommitratio));
12051193
_clusterDetailsDao.update(cpu_detail.getId(),cpu_detail);
1206-
}
1194+
}
12071195

12081196

12091197
if (doUpdate) {

0 commit comments

Comments
 (0)