@@ -362,49 +362,68 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile, Deploym
362362 " already has max Running VMs(count includes system VMs), skipping this and trying other available hosts" );
363363 } else {
364364 if (host .getStatus () == Status .Up && host .getResourceState () == ResourceState .Enabled ) {
365- long cluster_id = host .getClusterId ();
366- ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao .findDetail (cluster_id , "cpuOvercommitRatio" );
367- ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao .findDetail (cluster_id , "memoryOvercommitRatio" );
368- Float cpuOvercommitRatio = Float .parseFloat (cluster_detail_cpu .getValue ());
369- Float memoryOvercommitRatio = Float .parseFloat (cluster_detail_ram .getValue ());
370- if (_capacityMgr .checkIfHostHasCapacity (host .getId (), cpu_requested , ram_requested , true , cpuOvercommitRatio , memoryOvercommitRatio , true )
371- && _capacityMgr .checkIfHostHasCpuCapability (host .getId (), offering .getCpu (), offering .getSpeed ())) {
372- s_logger .debug ("The last host of this VM is UP and has enough capacity" );
373- s_logger .debug ("Now checking for suitable pools under zone: " + host .getDataCenterId () + ", pod: " + host .getPodId () + ", cluster: " +
374- host .getClusterId ());
375- // search for storage under the zone, pod, cluster of
376- // the last host.
377- DataCenterDeployment lastPlan =
378- new DataCenterDeployment (host .getDataCenterId (), host .getPodId (), host .getClusterId (), host .getId (), plan .getPoolId (), null );
379- Pair <Map <Volume , List <StoragePool >>, List <Volume >> result =
380- findSuitablePoolsForVolumes (vmProfile , lastPlan , avoids , HostAllocator .RETURN_UPTO_ALL );
381- Map <Volume , List <StoragePool >> suitableVolumeStoragePools = result .first ();
382- List <Volume > readyAndReusedVolumes = result .second ();
383-
384- // choose the potential pool for this VM for this host
385- if (!suitableVolumeStoragePools .isEmpty ()) {
386- List <Host > suitableHosts = new ArrayList <Host >();
387- suitableHosts .add (host );
388- Pair <Host , Map <Volume , StoragePool >> potentialResources = findPotentialDeploymentResources (
389- suitableHosts , suitableVolumeStoragePools , avoids ,
390- getPlannerUsage (planner , vmProfile , plan , avoids ), readyAndReusedVolumes );
391- if (potentialResources != null ) {
392- Pod pod = _podDao .findById (host .getPodId ());
393- Cluster cluster = _clusterDao .findById (host .getClusterId ());
394- Map <Volume , StoragePool > storageVolMap = potentialResources .second ();
395- // remove the reused vol<->pool from
396- // destination, since we don't have to prepare
397- // this volume.
398- for (Volume vol : readyAndReusedVolumes ) {
399- storageVolMap .remove (vol );
365+ boolean hostTagsMatch = true ;
366+ if (offering .getHostTag () != null ){
367+ _hostDao .loadHostTags (host );
368+ if (!(host .getHostTags () != null && host .getHostTags ().contains (offering .getHostTag ()))) {
369+ hostTagsMatch = false ;
370+ }
371+ }
372+ if (hostTagsMatch ) {
373+ long cluster_id = host .getClusterId ();
374+ ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao .findDetail (cluster_id ,
375+ "cpuOvercommitRatio" );
376+ ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao .findDetail (cluster_id ,
377+ "memoryOvercommitRatio" );
378+ Float cpuOvercommitRatio = Float .parseFloat (cluster_detail_cpu .getValue ());
379+ Float memoryOvercommitRatio = Float .parseFloat (cluster_detail_ram .getValue ());
380+ if (_capacityMgr .checkIfHostHasCapacity (host .getId (), cpu_requested , ram_requested , true ,
381+ cpuOvercommitRatio , memoryOvercommitRatio , true )
382+ && _capacityMgr .checkIfHostHasCpuCapability (host .getId (), offering .getCpu (),
383+ offering .getSpeed ())) {
384+ s_logger .debug ("The last host of this VM is UP and has enough capacity" );
385+ s_logger .debug ("Now checking for suitable pools under zone: " + host .getDataCenterId ()
386+ + ", pod: " + host .getPodId () + ", cluster: " + host .getClusterId ());
387+ // search for storage under the zone, pod, cluster
388+ // of
389+ // the last host.
390+ DataCenterDeployment lastPlan = new DataCenterDeployment (host .getDataCenterId (),
391+ host .getPodId (), host .getClusterId (), host .getId (), plan .getPoolId (), null );
392+ Pair <Map <Volume , List <StoragePool >>, List <Volume >> result = findSuitablePoolsForVolumes (
393+ vmProfile , lastPlan , avoids , HostAllocator .RETURN_UPTO_ALL );
394+ Map <Volume , List <StoragePool >> suitableVolumeStoragePools = result .first ();
395+ List <Volume > readyAndReusedVolumes = result .second ();
396+
397+ // choose the potential pool for this VM for this
398+ // host
399+ if (!suitableVolumeStoragePools .isEmpty ()) {
400+ List <Host > suitableHosts = new ArrayList <Host >();
401+ suitableHosts .add (host );
402+ Pair <Host , Map <Volume , StoragePool >> potentialResources = findPotentialDeploymentResources (
403+ suitableHosts , suitableVolumeStoragePools , avoids ,
404+ getPlannerUsage (planner , vmProfile , plan , avoids ), readyAndReusedVolumes );
405+ if (potentialResources != null ) {
406+ Pod pod = _podDao .findById (host .getPodId ());
407+ Cluster cluster = _clusterDao .findById (host .getClusterId ());
408+ Map <Volume , StoragePool > storageVolMap = potentialResources .second ();
409+ // remove the reused vol<->pool from
410+ // destination, since we don't have to
411+ // prepare
412+ // this volume.
413+ for (Volume vol : readyAndReusedVolumes ) {
414+ storageVolMap .remove (vol );
415+ }
416+ DeployDestination dest = new DeployDestination (dc , pod , cluster , host ,
417+ storageVolMap );
418+ s_logger .debug ("Returning Deployment Destination: " + dest );
419+ return dest ;
400420 }
401- DeployDestination dest = new DeployDestination (dc , pod , cluster , host , storageVolMap );
402- s_logger .debug ("Returning Deployment Destination: " + dest );
403- return dest ;
404421 }
422+ } else {
423+ s_logger .debug ("The last host of this VM does not have enough capacity" );
405424 }
406425 } else {
407- s_logger .debug ("The last host of this VM does not have enough capacity " );
426+ s_logger .debug ("Service Offering host tag does not match the last host of this VM " );
408427 }
409428 } else {
410429 s_logger .debug ("The last host of this VM is not UP or is not enabled, host status is: " + host .getStatus ().name () + ", host resource state is: " +
0 commit comments