3030
3131import org .apache .cloudstack .affinity .AffinityGroupProcessor ;
3232import org .apache .cloudstack .affinity .AffinityGroupService ;
33- import org .apache .cloudstack .affinity .AffinityGroupVMMapVO ;
33+ import org .apache .cloudstack .affinity .AffinityGroupVMMapVO ;
3434import org .apache .cloudstack .affinity .AffinityGroupVO ;
3535import org .apache .cloudstack .affinity .dao .AffinityGroupDao ;
3636import org .apache .cloudstack .affinity .dao .AffinityGroupVMMapDao ;
5656import com .cloud .dc .ClusterVO ;
5757import com .cloud .dc .DataCenter ;
5858import com .cloud .dc .DataCenterVO ;
59- import com .cloud .dc .DedicatedResourceVO ;
59+ import com .cloud .dc .DedicatedResourceVO ;
6060import com .cloud .dc .Pod ;
6161import com .cloud .dc .dao .ClusterDao ;
6262import com .cloud .dc .dao .DataCenterDao ;
63- import com .cloud .dc .dao .DedicatedResourceDao ;
63+ import com .cloud .dc .dao .DedicatedResourceDao ;
6464import com .cloud .dc .dao .HostPodDao ;
6565import com .cloud .deploy .DeploymentPlanner .ExcludeList ;
6666import com .cloud .deploy .DeploymentPlanner .PlannerResourceUsage ;
102102import com .cloud .utils .db .TransactionCallback ;
103103import com .cloud .utils .db .TransactionCallbackNoReturn ;
104104import com .cloud .utils .db .TransactionStatus ;
105- import com .cloud .utils .exception .CloudRuntimeException ;
105+ import com .cloud .utils .exception .CloudRuntimeException ;
106106import com .cloud .utils .fsm .StateListener ;
107107import com .cloud .vm .DiskProfile ;
108108import com .cloud .vm .ReservationContext ;
@@ -176,7 +176,7 @@ public void setHostAllocators(List<HostAllocator> _hostAllocators) {
176176 @ Inject protected HostDao _hostDao ;
177177 @ Inject protected HostPodDao _podDao ;
178178 @ Inject protected ClusterDao _clusterDao ;
179- @ Inject protected DedicatedResourceDao _dedicatedDao ;
179+ @ Inject protected DedicatedResourceDao _dedicatedDao ;
180180 @ Inject protected GuestOSDao _guestOSDao = null ;
181181 @ Inject protected GuestOSCategoryDao _guestOSCategoryDao = null ;
182182 @ Inject protected DiskOfferingDao _diskOfferingDao ;
@@ -216,7 +216,7 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
216216 // call affinitygroup chain
217217 VirtualMachine vm = vmProfile .getVirtualMachine ();
218218 long vmGroupCount = _affinityGroupVMMapDao .countAffinityGroupsForVm (vm .getId ());
219- DataCenter dc = _dcDao .findById (vm .getDataCenterId ());
219+ DataCenter dc = _dcDao .findById (vm .getDataCenterId ());
220220
221221 if (vmGroupCount > 0 ) {
222222 for (AffinityGroupProcessor processor : _affinityProcessors ) {
@@ -226,14 +226,14 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
226226
227227 if (vm .getType () == VirtualMachine .Type .User ) {
228228 checkForNonDedicatedResources (vmProfile , dc , avoids );
229- }
229+ }
230230 if (s_logger .isDebugEnabled ()) {
231231 s_logger .debug ("Deploy avoids pods: " + avoids .getPodsToAvoid () + ", clusters: "
232232 + avoids .getClustersToAvoid () + ", hosts: " + avoids .getHostsToAvoid ());
233233 }
234234
235235 // call planners
236- //DataCenter dc = _dcDao.findById(vm.getDataCenterId());
236+ //DataCenter dc = _dcDao.findById(vm.getDataCenterId());
237237 // check if datacenter is in avoid set
238238 if (avoids .shouldAvoid (dc )) {
239239 if (s_logger .isDebugEnabled ()) {
@@ -308,7 +308,7 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
308308 List <Host > suitableHosts = new ArrayList <Host >();
309309 suitableHosts .add (host );
310310 Pair <Host , Map <Volume , StoragePool >> potentialResources = findPotentialDeploymentResources (
311- suitableHosts , suitableVolumeStoragePools , avoids , getPlannerUsage (planner ,vmProfile , plan ,avoids ));
311+ suitableHosts , suitableVolumeStoragePools , avoids , getPlannerUsage (planner ,vmProfile , plan ,avoids ));
312312 if (potentialResources != null ) {
313313 Pod pod = _podDao .findById (host .getPodId ());
314314 Cluster cluster = _clusterDao .findById (host .getClusterId ());
@@ -350,7 +350,8 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
350350 Float cpuOvercommitRatio = Float .parseFloat (cluster_detail_cpu .getValue ());
351351 Float memoryOvercommitRatio = Float .parseFloat (cluster_detail_ram .getValue ());
352352 if (_capacityMgr .checkIfHostHasCapacity (host .getId (), cpu_requested , ram_requested , true ,
353- cpuOvercommitRatio , memoryOvercommitRatio , true )) {
353+ cpuOvercommitRatio , memoryOvercommitRatio , true )
354+ && _capacityMgr .checkIfHostHasCpuCapability (host .getId (), offering .getCpu (), offering .getSpeed ())) {
354355 s_logger .debug ("The last host of this VM is UP and has enough capacity" );
355356 s_logger .debug ("Now checking for suitable pools under zone: " + host .getDataCenterId ()
356357 + ", pod: " + host .getPodId () + ", cluster: " + host .getClusterId ());
@@ -362,13 +363,13 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
362363 vmProfile , lastPlan , avoids , HostAllocator .RETURN_UPTO_ALL );
363364 Map <Volume , List <StoragePool >> suitableVolumeStoragePools = result .first ();
364365 List <Volume > readyAndReusedVolumes = result .second ();
365-
366+
366367 // choose the potential pool for this VM for this host
367368 if (!suitableVolumeStoragePools .isEmpty ()) {
368369 List <Host > suitableHosts = new ArrayList <Host >();
369370 suitableHosts .add (host );
370371 Pair <Host , Map <Volume , StoragePool >> potentialResources = findPotentialDeploymentResources (
371- suitableHosts , suitableVolumeStoragePools , avoids , getPlannerUsage (planner ,vmProfile , plan ,avoids ));
372+ suitableHosts , suitableVolumeStoragePools , avoids , getPlannerUsage (planner ,vmProfile , plan ,avoids ));
372373 if (potentialResources != null ) {
373374 Pod pod = _podDao .findById (host .getPodId ());
374375 Cluster cluster = _clusterDao .findById (host .getClusterId ());
@@ -418,7 +419,7 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
418419 resetAvoidSet (plannerAvoidOutput , plannerAvoidInput );
419420
420421 dest = checkClustersforDestination (clusterList , vmProfile , plan , avoids , dc ,
421- getPlannerUsage (planner , vmProfile , plan , avoids ), plannerAvoidOutput );
422+ getPlannerUsage (planner , vmProfile , plan , avoids ), plannerAvoidOutput );
422423 if (dest != null ) {
423424 return dest ;
424425 }
@@ -453,7 +454,7 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile,
453454 return dest ;
454455 }
455456
456- private void checkForNonDedicatedResources (VirtualMachineProfile vmProfile , DataCenter dc , ExcludeList avoids ) {
457+ private void checkForNonDedicatedResources (VirtualMachineProfile vmProfile , DataCenter dc , ExcludeList avoids ) {
457458 boolean isExplicit = false ;
458459 VirtualMachine vm = vmProfile .getVirtualMachine ();
459460
@@ -488,16 +489,16 @@ private void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
488489 }
489490
490491 // check affinity group of type Explicit dedication exists. If No put
491- // dedicated pod/cluster/host in avoid list
492- List <AffinityGroupVMMapVO > vmGroupMappings = _affinityGroupVMMapDao .findByVmIdType (vm .getId (), "ExplicitDedication" );
493-
494- if (vmGroupMappings != null && !vmGroupMappings .isEmpty ()){
495- isExplicit = true ;
496- }
497-
498- if (!isExplicit ) {
499- //add explicitly dedicated resources in avoidList
500-
492+ // dedicated pod/cluster/host in avoid list
493+ List <AffinityGroupVMMapVO > vmGroupMappings = _affinityGroupVMMapDao .findByVmIdType (vm .getId (), "ExplicitDedication" );
494+
495+ if (vmGroupMappings != null && !vmGroupMappings .isEmpty ()){
496+ isExplicit = true ;
497+ }
498+
499+ if (!isExplicit ) {
500+ //add explicitly dedicated resources in avoidList
501+
501502 List <Long > allPodsInDc = _podDao .listAllPods (dc .getId ());
502503 List <Long > allDedicatedPods = _dedicatedDao .listAllPods ();
503504 allPodsInDc .retainAll (allDedicatedPods );
@@ -511,10 +512,10 @@ private void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, Data
511512 List <Long > allHostsInDc = _hostDao .listAllHosts (dc .getId ());
512513 List <Long > allDedicatedHosts = _dedicatedDao .listAllHosts ();
513514 allHostsInDc .retainAll (allDedicatedHosts );
514- avoids .addHostList (allHostsInDc );
515- }
516- }
517-
515+ avoids .addHostList (allHostsInDc );
516+ }
517+ }
518+
518519 private void resetAvoidSet (ExcludeList avoidSet , ExcludeList removeSet ) {
519520 if (avoidSet .getDataCentersToAvoid () != null && removeSet .getDataCentersToAvoid () != null ) {
520521 avoidSet .getDataCentersToAvoid ().removeAll (removeSet .getDataCentersToAvoid ());
@@ -533,9 +534,9 @@ private void resetAvoidSet(ExcludeList avoidSet, ExcludeList removeSet) {
533534 }
534535 }
535536
536- private PlannerResourceUsage getPlannerUsage (DeploymentPlanner planner , VirtualMachineProfile vmProfile , DeploymentPlan plan , ExcludeList avoids ) throws InsufficientServerCapacityException {
537+ private PlannerResourceUsage getPlannerUsage (DeploymentPlanner planner , VirtualMachineProfile vmProfile , DeploymentPlan plan , ExcludeList avoids ) throws InsufficientServerCapacityException {
537538 if (planner != null && planner instanceof DeploymentClusterPlanner ) {
538- return ((DeploymentClusterPlanner ) planner ).getResourceUsage (vmProfile , plan , avoids );
539+ return ((DeploymentClusterPlanner ) planner ).getResourceUsage (vmProfile , plan , avoids );
539540 } else {
540541 return DeploymentPlanner .PlannerResourceUsage .Shared ;
541542 }
0 commit comments