@@ -496,6 +496,17 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd)
496496
497497 _clusterDetailsDao .persist (cluster_detail_cpu );
498498 _clusterDetailsDao .persist (cluster_detail_ram );
499+ //create a new entry only if the overcommit ratios are greater than 1.
500+ if (cmd .getCpuOvercommitRatio ().compareTo (1f ) > 0 ) {
501+ cluster_detail_cpu = new ClusterDetailsVO (clusterId , "cpuOvercommitRatio" , Float .toString (cmd .getCpuOvercommitRatio ()));
502+ _clusterDetailsDao .persist (cluster_detail_cpu );
503+ }
504+
505+
506+ if (cmd .getMemoryOvercommitRaito ().compareTo (1f ) > 0 ) {
507+ cluster_detail_ram = new ClusterDetailsVO (clusterId , "memoryOvercommitRatio" , Float .toString (cmd .getMemoryOvercommitRaito ()));
508+ _clusterDetailsDao .persist (cluster_detail_ram );
509+ }
499510
500511
501512 boolean success = false ;
@@ -1065,7 +1076,7 @@ public boolean deleteCluster(DeleteClusterCmd cmd) {
10651076 @ Override
10661077 @ DB
10671078 public Cluster updateCluster (Cluster clusterToUpdate , String clusterType ,
1068- String hypervisor , String allocationState , String managedstate , Float memoryOvercommitRaito , Float cpuOvercommitRatio ) {
1079+ String hypervisor , String allocationState , String managedstate ,Float memoryovercommitratio , Float cpuovercommitratio ) {
10691080
10701081 ClusterVO cluster = (ClusterVO ) clusterToUpdate ;
10711082 // Verify cluster information and update the cluster if needed
@@ -1148,6 +1159,31 @@ public Cluster updateCluster(Cluster clusterToUpdate, String clusterType,
11481159 }
11491160 }
11501161
1162+ ClusterDetailsVO memory_detail = _clusterDetailsDao .findDetail (cluster .getId (),"memoryOvercommitRatio" );
1163+ if ( memory_detail == null ){
1164+ if (memoryovercommitratio .compareTo (1f ) > 0 ){
1165+ memory_detail = new ClusterDetailsVO (cluster .getId (),"memoryOvercommitRatio" ,Float .toString (memoryovercommitratio ));
1166+ _clusterDetailsDao .persist (memory_detail );
1167+ }
1168+ }
1169+ else {
1170+ memory_detail .setValue (Float .toString (memoryovercommitratio ));
1171+ _clusterDetailsDao .update (memory_detail .getId (),memory_detail );
1172+ }
1173+
1174+ ClusterDetailsVO cpu_detail = _clusterDetailsDao .findDetail (cluster .getId (),"cpuOvercommitRatio" );
1175+ if ( cpu_detail == null ){
1176+ if (cpuovercommitratio .compareTo (1f ) > 0 ){
1177+ cpu_detail = new ClusterDetailsVO (cluster .getId (),"cpuOvercommitRatio" ,Float .toString (cpuovercommitratio ));
1178+ _clusterDetailsDao .persist (cpu_detail );
1179+ }
1180+ }
1181+ else {
1182+ cpu_detail .setValue (Float .toString (cpuovercommitratio ));
1183+ _clusterDetailsDao .update (cpu_detail .getId (),cpu_detail );
1184+ }
1185+
1186+
11511187 if (doUpdate ) {
11521188 Transaction txn = Transaction .currentTxn ();
11531189 try {
0 commit comments