diff --git a/api/src/main/java/com/cloud/deploy/DeployDestination.java b/api/src/main/java/com/cloud/deploy/DeployDestination.java index 18503fee74b..91b2068e94b 100644 --- a/api/src/main/java/com/cloud/deploy/DeployDestination.java +++ b/api/src/main/java/com/cloud/deploy/DeployDestination.java @@ -36,6 +36,11 @@ public class DeployDestination implements Serializable { Host _host; Map _storage; + /** + * Display volume <-> storage pool mapping by default + */ + boolean displayStorage = true; + public DataCenter getDataCenter() { return _dc; } @@ -63,9 +68,10 @@ public class DeployDestination implements Serializable { _host = host; } - public DeployDestination(DataCenter dc, Pod pod, Cluster cluster, Host host, Map storage) { + public DeployDestination(DataCenter dc, Pod pod, Cluster cluster, Host host, Map storage, boolean displayStorage) { this(dc, pod, cluster, host); _storage = storage; + this.displayStorage = displayStorage; } public DeployDestination() { @@ -139,7 +145,7 @@ public class DeployDestination implements Serializable { destination.append("Cluster(").append(clusterId).append(")").append("-"); destination.append("Host(").append(hostId).append(")").append("-"); destination.append("Storage("); - if (_storage != null) { + if (displayStorage && _storage != null) { StringBuffer storageBuf = new StringBuffer(); //String storageStr = ""; for (Volume vol : _storage.keySet()) { @@ -160,4 +166,8 @@ public class DeployDestination implements Serializable { } return destination.append(")]").toString(); } + + public boolean isDisplayStorage() { + return displayStorage; + } } diff --git a/api/src/main/java/com/cloud/storage/Volume.java b/api/src/main/java/com/cloud/storage/Volume.java index 5fd78efb307..5979697b555 100644 --- a/api/src/main/java/com/cloud/storage/Volume.java +++ b/api/src/main/java/com/cloud/storage/Volume.java @@ -235,4 +235,6 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba boolean isDisplayVolume(); boolean isDisplay(); + + boolean isDeployAsIs(); } diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java index 8a31556a221..02ceef276bf 100755 --- a/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java @@ -1150,7 +1150,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac try { resetVmNicsDeviceId(vm.getId()); - _networkMgr.prepare(vmProfile, new DeployDestination(dest.getDataCenter(), dest.getPod(), null, null, dest.getStorageForDisks()), ctx); + _networkMgr.prepare(vmProfile, new DeployDestination(dest.getDataCenter(), dest.getPod(), null, null, dest.getStorageForDisks(), dest.isDisplayStorage()), ctx); if (vm.getHypervisorType() != HypervisorType.BareMetal) { volumeMgr.prepare(vmProfile, dest); } diff --git a/engine/orchestration/src/main/java/com/cloud/vm/VmWorkMigrate.java b/engine/orchestration/src/main/java/com/cloud/vm/VmWorkMigrate.java index 5bcea9a8aca..1d7deca2d9e 100644 --- a/engine/orchestration/src/main/java/com/cloud/vm/VmWorkMigrate.java +++ b/engine/orchestration/src/main/java/com/cloud/vm/VmWorkMigrate.java @@ -64,14 +64,19 @@ public class VmWorkMigrate extends VmWork { Map vols = null; + boolean displayStorage = true; if (storage != null) { vols = new HashMap(storage.size()); for (Map.Entry entry : storage.entrySet()) { - vols.put(s_entityMgr.findByUuid(Volume.class, entry.getKey()), s_entityMgr.findByUuid(StoragePool.class, entry.getValue())); + Volume volume = s_entityMgr.findByUuid(Volume.class, entry.getKey()); + if (displayStorage && volume.isDeployAsIs()) { + displayStorage = false; + } + vols.put(volume, s_entityMgr.findByUuid(StoragePool.class, entry.getValue())); } } - DeployDestination dest = new DeployDestination(zone, pod, cluster, host, vols); + DeployDestination dest = new DeployDestination(zone, pod, cluster, host, vols, displayStorage); return dest; } diff --git a/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java b/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java index d8323e998f8..b766483e6d1 100644 --- a/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java +++ b/engine/schema/src/main/java/com/cloud/storage/VolumeVO.java @@ -166,6 +166,9 @@ public class VolumeVO implements Volume { @Column(name = "hv_ss_reserve") private Integer hypervisorSnapshotReserve; + @Transient + private boolean deployAsIs; + // Real Constructor public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, Storage.ProvisioningType provisioningType, long size, @@ -261,6 +264,7 @@ public class VolumeVO implements Volume { format = that.getFormat(); provisioningType = that.getProvisioningType(); uuid = UUID.randomUUID().toString(); + deployAsIs = that.isDeployAsIs(); } @Override @@ -572,6 +576,11 @@ public class VolumeVO implements Volume { return displayVolume; } + @Override + public boolean isDeployAsIs() { + return deployAsIs; + } + public void setDisplay(boolean display){ this.displayVolume = display; } diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql b/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql index dd7bfee314c..76907037af1 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41400to41500.sql @@ -517,5 +517,21 @@ ALTER VIEW `cloud`.`image_store_view` AS left join `cloud`.`image_store_details` ON image_store_details.store_id = image_store.id; --- OVF configured OS while registering deploy-as-is templates -INSERT IGNORE INTO `cloud`.`guest_os` (uuid, category_id, display_name, created) VALUES (UUID(), 11, 'OVF Configured OS', now()); +-- OVF configured OS while registering deploy-as-is templates Linux 3.x Kernel OS +INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (305, UUID(), 11, 'OVF Configured OS', now()); +INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (306, UUID(), 2, 'Linux 3.x Kernel (64 bit)', now()); +INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (307, UUID(), 2, 'Linux 3.x Kernel (32 bit)', now()); + +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.0', 'other3xLinux64Guest', 306, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.5', 'other3xLinux64Guest', 306, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7', 'other3xLinux64Guest', 306, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7.1', 'other3xLinux64Guest', 306, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7.2', 'other3xLinux64Guest', 306, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7.3', 'other3xLinux64Guest', 306, now(), 0); + +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.0', 'other3xLinuxGuest', 307, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.5', 'other3xLinuxGuest', 307, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7', 'other3xLinuxGuest', 307, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7.1', 'other3xLinuxGuest', 307, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7.2', 'other3xLinuxGuest', 307, now(), 0); +INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'VMware', '6.7.3', 'other3xLinuxGuest', 307, now(), 0); diff --git a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java index c71fc4da439..9dde8959152 100644 --- a/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java +++ b/engine/storage/src/main/java/org/apache/cloudstack/storage/image/deployasis/DeployAsIsHelperImpl.java @@ -69,10 +69,8 @@ import javax.inject.Inject; import java.io.IOException; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; @Component public class DeployAsIsHelperImpl implements DeployAsIsHelper { @@ -167,11 +165,10 @@ public class DeployAsIsHelperImpl implements DeployAsIsHelper { @Override public void doInTransactionWithoutResult(TransactionStatus status) { if (CollectionUtils.isNotEmpty(guestOsMappings)) { - Pair> result = updateDeployAsIsTemplateToExistingGuestOs(template, guestOsMappings, guestOsDescription); - if (!result.first()) { - // If couldnt find a guest OS matching the display name, create a new guest OS - updateDeployAsIsTemplateToNewGuestOs(template, guestOsType, guestOsDescription, hypervisor, result.second()); - } + GuestOSHypervisorVO mapping = guestOsMappings.get(0); + long guestOsId = mapping.getGuestOsId(); + LOGGER.info("Updating deploy-as-is template guest OS to " + guestOsType); + updateTemplateGuestOsId(template, guestOsId); } else { // The guest OS is not present in DB, create a new guest OS entry and mappings for supported versions List hypervisorVersions = guestOSHypervisorDao.listHypervisorSupportedVersionsFromMinimumVersion( @@ -182,31 +179,6 @@ public class DeployAsIsHelperImpl implements DeployAsIsHelper { }); } - /** - * Return true if the template guest OS can be updated to an existing guest OS matching the display name to - * the guest OS description from the OVF. (the second element of the returned pair is not used) - * If the guest OS does not exist, return false and the hypervisor versions that the guest OS must support - */ - private Pair> updateDeployAsIsTemplateToExistingGuestOs(VMTemplateVO template, - List guestOsMappings, - String guestOsDescription) { - Set versionsToSupport = new HashSet<>(); - for (GuestOSHypervisorVO mapping : guestOsMappings) { - long guestOsId = mapping.getGuestOsId(); - GuestOSVO guestOs = guestOSDao.findById(guestOsId); - versionsToSupport.add(mapping.getHypervisorVersion()); - if (guestOs.getDisplayName().equalsIgnoreCase(guestOsDescription)) { - LOGGER.info("Found guest OS mapping for OVF read guest OS " + guestOsDescription + - " to hypervisor version " + mapping.getHypervisorVersion()); - LOGGER.info("Updating deploy-as-is template guest OS to " + guestOs.getDisplayName()); - updateTemplateGuestOsId(template, guestOsId); - return new Pair<>(true, versionsToSupport); - } - } - LOGGER.info("Could not map the OVF read guest OS " + guestOsDescription + " to an existing guest OS"); - return new Pair<>(false, versionsToSupport); - } - /** * Updates the deploy-as-is template guest OS doing: * - Create a new guest OS with the guest OS description parsed from the OVF diff --git a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java index 340d9119de8..eb99a8eefe3 100644 --- a/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/main/java/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -320,8 +320,9 @@ StateListener { return null; } + boolean displayStorage = getDisplayStorageFromVmProfile(vmProfile); if (vm.getHypervisorType() == HypervisorType.BareMetal) { - DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap()); + DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap(), displayStorage); s_logger.debug("Returning Deployment Destination: " + dest); return dest; } @@ -351,7 +352,7 @@ StateListener { for (Volume vol : readyAndReusedVolumes) { storageVolMap.remove(vol); } - DeployDestination dest = new DeployDestination(dc, pod, cluster, host, storageVolMap); + DeployDestination dest = new DeployDestination(dc, pod, cluster, host, storageVolMap, displayStorage); s_logger.debug("Returning Deployment Destination: " + dest); return dest; } @@ -440,6 +441,7 @@ StateListener { hostHasCapacity = _capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, false, cpuOvercommitRatio, memoryOvercommitRatio, true); } + boolean displayStorage = getDisplayStorageFromVmProfile(vmProfile); if (hostHasCapacity && hostHasCpuCapability) { s_logger.debug("The last host of this VM is UP and has enough capacity"); @@ -449,7 +451,7 @@ StateListener { Pod pod = _podDao.findById(host.getPodId()); Cluster cluster = _clusterDao.findById(host.getClusterId()); if (vm.getHypervisorType() == HypervisorType.BareMetal) { - DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap()); + DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap(), displayStorage); s_logger.debug("Returning Deployment Destination: " + dest); return dest; } @@ -482,7 +484,7 @@ StateListener { storageVolMap.remove(vol); } DeployDestination dest = new DeployDestination(dc, pod, cluster, host, - storageVolMap); + storageVolMap, displayStorage); s_logger.debug("Returning Deployment Destination: " + dest); return dest; } @@ -555,6 +557,13 @@ StateListener { return dest; } + /** + * Display storage in the logs by default if the template is not deploy-as-is. + */ + private boolean getDisplayStorageFromVmProfile(VirtualMachineProfile vmProfile) { + return vmProfile == null || vmProfile.getTemplate() == null || !vmProfile.getTemplate().isDeployAsIs(); + } + @Override public DeploymentPlanner getDeploymentPlannerByName(String plannerName) { if (plannerName != null) { @@ -1121,7 +1130,8 @@ StateListener { for (Volume vol : readyAndReusedVolumes) { storageVolMap.remove(vol); } - DeployDestination dest = new DeployDestination(dc, pod, clusterVO, host, storageVolMap); + boolean displayStorage = getDisplayStorageFromVmProfile(vmProfile); + DeployDestination dest = new DeployDestination(dc, pod, clusterVO, host, storageVolMap, displayStorage); s_logger.debug("Returning Deployment Destination: " + dest); return dest; } @@ -1329,6 +1339,7 @@ StateListener { if (hostCanAccessPool && haveEnoughSpace && hostAffinityCheck && checkIfHostFitsPlannerUsage(potentialHost.getId(), resourceUsageRequired)) { s_logger.debug("Found a potential host " + "id: " + potentialHost.getId() + " name: " + potentialHost.getName() + " and associated storage pools for this VM"); + volumeAllocationMap.clear(); return new Pair>(potentialHost, storage); } else { avoid.addHost(potentialHost.getId());