|
89 | 89 | import com.cloud.exception.ConnectionException; |
90 | 90 | import com.cloud.exception.InsufficientServerCapacityException; |
91 | 91 | import com.cloud.gpu.GPU; |
| 92 | +import com.cloud.host.DetailVO; |
92 | 93 | import com.cloud.host.Host; |
93 | 94 | import com.cloud.host.HostVO; |
94 | 95 | import com.cloud.host.Status; |
95 | 96 | import com.cloud.host.dao.HostDao; |
| 97 | +import com.cloud.host.dao.HostDetailsDao; |
96 | 98 | import com.cloud.hypervisor.Hypervisor.HypervisorType; |
97 | 99 | import com.cloud.offering.ServiceOffering; |
98 | 100 | import com.cloud.org.Cluster; |
|
102 | 104 | import com.cloud.service.ServiceOfferingDetailsVO; |
103 | 105 | import com.cloud.service.dao.ServiceOfferingDetailsDao; |
104 | 106 | import com.cloud.storage.DiskOfferingVO; |
| 107 | +import com.cloud.storage.GuestOSVO; |
105 | 108 | import com.cloud.storage.ScopeType; |
106 | 109 | import com.cloud.storage.Storage; |
107 | 110 | import com.cloud.storage.StorageManager; |
@@ -165,6 +168,8 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy |
165 | 168 | private long _hostReservationReleasePeriod = 60L * 60L * 1000L; // one hour by default |
166 | 169 | @Inject |
167 | 170 | protected VMReservationDao _reservationDao; |
| 171 | + @Inject |
| 172 | + HostDetailsDao _hostDetailsDao; |
168 | 173 |
|
169 | 174 | private static final long INITIAL_RESERVATION_RELEASE_CHECKER_DELAY = 30L * 1000L; // thirty seconds expressed in milliseconds |
170 | 175 | protected long _nodeId = -1; |
@@ -411,14 +416,7 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile, Deploym |
411 | 416 | } |
412 | 417 | } else { |
413 | 418 | if (host.getStatus() == Status.Up && host.getResourceState() == ResourceState.Enabled) { |
414 | | - boolean hostTagsMatch = true; |
415 | | - if(offering.getHostTag() != null){ |
416 | | - _hostDao.loadHostTags(host); |
417 | | - if (!(host.getHostTags() != null && host.getHostTags().contains(offering.getHostTag()))) { |
418 | | - hostTagsMatch = false; |
419 | | - } |
420 | | - } |
421 | | - if (hostTagsMatch) { |
| 419 | + if (checkVmProfileAndHost(vmProfile, host)) { |
422 | 420 | long cluster_id = host.getClusterId(); |
423 | 421 | ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id, |
424 | 422 | "cpuOvercommitRatio"); |
@@ -489,8 +487,6 @@ public DeployDestination planDeployment(VirtualMachineProfile vmProfile, Deploym |
489 | 487 | } else { |
490 | 488 | s_logger.debug("The last host of this VM does not have enough capacity"); |
491 | 489 | } |
492 | | - } else { |
493 | | - s_logger.debug("Service Offering host tag does not match the last host of this VM"); |
494 | 490 | } |
495 | 491 | } else { |
496 | 492 | 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: " + |
@@ -569,6 +565,31 @@ public DeploymentPlanner getDeploymentPlannerByName(String plannerName) { |
569 | 565 | return null; |
570 | 566 | } |
571 | 567 |
|
| 568 | + private boolean checkVmProfileAndHost(final VirtualMachineProfile vmProfile, final HostVO host) { |
| 569 | + ServiceOffering offering = vmProfile.getServiceOffering(); |
| 570 | + if (offering.getHostTag() != null) { |
| 571 | + _hostDao.loadHostTags(host); |
| 572 | + if (!(host.getHostTags() != null && host.getHostTags().contains(offering.getHostTag()))) { |
| 573 | + s_logger.debug("Service Offering host tag does not match the last host of this VM"); |
| 574 | + return false; |
| 575 | + } |
| 576 | + } |
| 577 | + long guestOSId = vmProfile.getTemplate().getGuestOSId(); |
| 578 | + GuestOSVO guestOS = _guestOSDao.findById(guestOSId); |
| 579 | + if (guestOS != null) { |
| 580 | + long guestOSCategoryId = guestOS.getCategoryId(); |
| 581 | + DetailVO hostDetail = _hostDetailsDao.findDetail(host.getId(), "guest.os.category.id"); |
| 582 | + if (hostDetail != null) { |
| 583 | + String guestOSCategoryIdString = hostDetail.getValue(); |
| 584 | + if (String.valueOf(guestOSCategoryId) != guestOSCategoryIdString) { |
| 585 | + s_logger.debug("The last host has different guest.os.category.id than guest os category of VM, skipping"); |
| 586 | + return false; |
| 587 | + } |
| 588 | + } |
| 589 | + } |
| 590 | + return true; |
| 591 | + } |
| 592 | + |
572 | 593 | @Override |
573 | 594 | public void checkForNonDedicatedResources(VirtualMachineProfile vmProfile, DataCenter dc, ExcludeList avoids) { |
574 | 595 | boolean isExplicit = false; |
|
0 commit comments