mirror of https://github.com/apache/cloudstack.git
Display storage on logging when not deploy-as-is and guest OS small refactor
This commit is contained in:
parent
81b184877b
commit
32d85b0fa2
|
|
@ -36,6 +36,11 @@ public class DeployDestination implements Serializable {
|
|||
Host _host;
|
||||
Map<Volume, StoragePool> _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<Volume, StoragePool> storage) {
|
||||
public DeployDestination(DataCenter dc, Pod pod, Cluster cluster, Host host, Map<Volume, StoragePool> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,4 +235,6 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
|||
boolean isDisplayVolume();
|
||||
|
||||
boolean isDisplay();
|
||||
|
||||
boolean isDeployAsIs();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,14 +64,19 @@ public class VmWorkMigrate extends VmWork {
|
|||
|
||||
Map<Volume, StoragePool> vols = null;
|
||||
|
||||
boolean displayStorage = true;
|
||||
if (storage != null) {
|
||||
vols = new HashMap<Volume, StoragePool>(storage.size());
|
||||
for (Map.Entry<String, String> 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<Boolean, Set<String>> 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<String> 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<Boolean, Set<String>> updateDeployAsIsTemplateToExistingGuestOs(VMTemplateVO template,
|
||||
List<GuestOSHypervisorVO> guestOsMappings,
|
||||
String guestOsDescription) {
|
||||
Set<String> 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
|
||||
|
|
|
|||
|
|
@ -320,8 +320,9 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
return null;
|
||||
}
|
||||
|
||||
boolean displayStorage = getDisplayStorageFromVmProfile(vmProfile);
|
||||
if (vm.getHypervisorType() == HypervisorType.BareMetal) {
|
||||
DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap<Volume, StoragePool>());
|
||||
DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap<Volume, StoragePool>(), displayStorage);
|
||||
s_logger.debug("Returning Deployment Destination: " + dest);
|
||||
return dest;
|
||||
}
|
||||
|
|
@ -351,7 +352,7 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
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<State, VirtualMachine.Event, VirtualMachine> {
|
|||
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<State, VirtualMachine.Event, VirtualMachine> {
|
|||
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<Volume, StoragePool>());
|
||||
DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap<Volume, StoragePool>(), displayStorage);
|
||||
s_logger.debug("Returning Deployment Destination: " + dest);
|
||||
return dest;
|
||||
}
|
||||
|
|
@ -482,7 +484,7 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
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<State, VirtualMachine.Event, VirtualMachine> {
|
|||
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<State, VirtualMachine.Event, VirtualMachine> {
|
|||
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<State, VirtualMachine.Event, VirtualMachine> {
|
|||
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<Host, Map<Volume, StoragePool>>(potentialHost, storage);
|
||||
} else {
|
||||
avoid.addHost(potentialHost.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue