@@ -1235,21 +1235,9 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
12351235
12361236 long destHostId = dest .getHost ().getId ();
12371237 vm .setPodIdToDeployIn (dest .getPod ().getId ());
1238- final Long cluster_id = dest .getCluster ().getId ();
1239- final ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao .findDetail (cluster_id , VmDetailConstants .CPU_OVER_COMMIT_RATIO );
1240- final ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao .findDetail (cluster_id , VmDetailConstants .MEMORY_OVER_COMMIT_RATIO );
1241-
1242- if (userVmDetailsDao .findDetail (vm .getId (), VmDetailConstants .CPU_OVER_COMMIT_RATIO ) == null &&
1243- (Float .parseFloat (cluster_detail_cpu .getValue ()) > 1f || Float .parseFloat (cluster_detail_ram .getValue ()) > 1f )) {
1244- userVmDetailsDao .addDetail (vm .getId (), VmDetailConstants .CPU_OVER_COMMIT_RATIO , cluster_detail_cpu .getValue (), true );
1245- userVmDetailsDao .addDetail (vm .getId (), VmDetailConstants .MEMORY_OVER_COMMIT_RATIO , cluster_detail_ram .getValue (), true );
1246- } else if (userVmDetailsDao .findDetail (vm .getId (), VmDetailConstants .CPU_OVER_COMMIT_RATIO ) != null ) {
1247- userVmDetailsDao .addDetail (vm .getId (), VmDetailConstants .CPU_OVER_COMMIT_RATIO , cluster_detail_cpu .getValue (), true );
1248- userVmDetailsDao .addDetail (vm .getId (), VmDetailConstants .MEMORY_OVER_COMMIT_RATIO , cluster_detail_ram .getValue (), true );
1249- }
1238+ final Long clusterId = dest .getCluster ().getId ();
1239+ updateOverCommitRatioForVmProfile (vmProfile , clusterId );
12501240
1251- vmProfile .setCpuOvercommitRatio (Float .parseFloat (cluster_detail_cpu .getValue ()));
1252- vmProfile .setMemoryOvercommitRatio (Float .parseFloat (cluster_detail_ram .getValue ()));
12531241 StartAnswer startAnswer = null ;
12541242
12551243 try {
@@ -1264,7 +1252,7 @@ public void orchestrateStart(final String vmUuid, final Map<VirtualMachineProfil
12641252 resetVmNicsDeviceId (vm .getId ());
12651253 _networkMgr .prepare (vmProfile , dest , ctx );
12661254 if (vm .getHypervisorType () != HypervisorType .BareMetal ) {
1267- checkAndAttemptMigrateVmAcrossCluster (vm , cluster_id , dest .getStorageForDisks ());
1255+ checkAndAttemptMigrateVmAcrossCluster (vm , clusterId , dest .getStorageForDisks ());
12681256 volumeMgr .prepare (vmProfile , dest );
12691257 }
12701258
@@ -1510,6 +1498,27 @@ private void addToNetworkNameMap(long networkId, long dataCenterId, Map<Long, St
15101498 }
15111499 networkToNetworkNameMap .put (networkVO .getId (), networkName );
15121500 }
1501+
1502+ private void updateOverCommitRatioForVmProfile (VirtualMachineProfile vmProfile , long clusterId ) {
1503+ final ClusterDetailsVO clusterDetailCpu = _clusterDetailsDao .findDetail (clusterId , VmDetailConstants .CPU_OVER_COMMIT_RATIO );
1504+ final ClusterDetailsVO clusterDetailRam = _clusterDetailsDao .findDetail (clusterId , VmDetailConstants .MEMORY_OVER_COMMIT_RATIO );
1505+ final float parsedClusterCpuDetailCpu = Float .parseFloat (clusterDetailCpu .getValue ());
1506+ final float parsedClusterDetailRam = Float .parseFloat (clusterDetailRam .getValue ());
1507+ UserVmDetailVO vmDetailCpu = userVmDetailsDao .findDetail (vmProfile .getId (), VmDetailConstants .CPU_OVER_COMMIT_RATIO );
1508+ UserVmDetailVO vmDetailRam = userVmDetailsDao .findDetail (vmProfile .getId (), VmDetailConstants .MEMORY_OVER_COMMIT_RATIO );
1509+
1510+ if ((vmDetailCpu == null && parsedClusterCpuDetailCpu > 1f ) ||
1511+ (vmDetailCpu != null && Float .parseFloat (vmDetailCpu .getValue ()) != parsedClusterCpuDetailCpu )) {
1512+ userVmDetailsDao .addDetail (vmProfile .getId (), VmDetailConstants .CPU_OVER_COMMIT_RATIO , clusterDetailCpu .getValue (), true );
1513+ }
1514+ if ((vmDetailRam == null && parsedClusterDetailRam > 1f ) ||
1515+ (vmDetailRam != null && Float .parseFloat (vmDetailRam .getValue ()) != parsedClusterDetailRam )) {
1516+ userVmDetailsDao .addDetail (vmProfile .getId (), VmDetailConstants .MEMORY_OVER_COMMIT_RATIO , clusterDetailRam .getValue (), true );
1517+ }
1518+
1519+ vmProfile .setCpuOvercommitRatio (Float .parseFloat (clusterDetailCpu .getValue ()));
1520+ vmProfile .setMemoryOvercommitRatio (Float .parseFloat (clusterDetailRam .getValue ()));
1521+ }
15131522
15141523 /**
15151524 * Setting pod id to null can result in migration of Volumes across pods. This is not desirable for VMs which
@@ -2740,6 +2749,7 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
27402749 _networkMgr .prepareNicForMigration (profile , dest );
27412750 volumeMgr .prepareForMigration (profile , dest );
27422751 profile .setConfigDriveLabel (VmConfigDriveLabel .value ());
2752+ updateOverCommitRatioForVmProfile (profile , dest .getHost ().getClusterId ());
27432753
27442754 final VirtualMachineTO to = toVmTO (profile );
27452755 final PrepareForMigrationCommand pfmc = new PrepareForMigrationCommand (to );
0 commit comments