rhtyd closed pull request #2928: Migrating VM from ISO failures URL: https://github.com/apache/cloudstack/pull/2928
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java b/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java index 4a3d058176c..cc2eaadea07 100644 --- a/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java +++ b/core/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java @@ -46,6 +46,7 @@ private Hypervisor.HypervisorType hypervisorType; private boolean bootable; private String uniqueName; + private boolean directDownload; public TemplateObjectTO() { @@ -235,6 +236,14 @@ public void setUniqueName(String uniqueName) { this.uniqueName = uniqueName; } + public boolean isDirectDownload() { + return directDownload; + } + + public void setDirectDownload(boolean directDownload) { + this.directDownload = directDownload; + } + @Override public String toString() { return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl).append("|name").append(name).append("]").toString(); diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 8a94b058655..652f6431f0e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -49,6 +49,7 @@ import com.cloud.resource.RequestWrapper; import org.apache.cloudstack.storage.to.PrimaryDataStoreTO; +import org.apache.cloudstack.storage.to.TemplateObjectTO; import org.apache.cloudstack.storage.to.VolumeObjectTO; import org.apache.cloudstack.utils.hypervisor.HypervisorUtils; import org.apache.cloudstack.utils.linux.CPUStat; @@ -2209,7 +2210,8 @@ public String getVolumePath(final Connect conn, final DiskTO volume) throws Libv final DataTO data = volume.getData(); final DataStoreTO store = data.getDataStore(); - if (volume.getType() == Volume.Type.ISO && data.getPath() != null && (store instanceof NfsTO || store instanceof PrimaryDataStoreTO)) { + if (volume.getType() == Volume.Type.ISO && data.getPath() != null && (store instanceof NfsTO || + store instanceof PrimaryDataStoreTO && data instanceof TemplateObjectTO && !((TemplateObjectTO) data).isDirectDownload())) { final String isoPath = store.getUrl().split("\\?")[0] + File.separator + data.getPath(); final int index = isoPath.lastIndexOf("/"); final String path = isoPath.substring(0, index); diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 42bdd72af63..48cc6f43a95 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -50,6 +50,7 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import org.apache.cloudstack.utils.imagestore.ImageStoreUtil; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; import org.apache.log4j.Logger; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.ApiConstants; @@ -557,11 +558,13 @@ public void prepareIsoForVmProfile(VirtualMachineProfile profile, DeployDestinat if (vm.getIsoId() != null) { Map<Volume, StoragePool> storageForDisks = dest.getStorageForDisks(); Long poolId = null; - for (StoragePool storagePool : storageForDisks.values()) { - if (poolId != null && storagePool.getId() != poolId) { - throw new CloudRuntimeException("Cannot determine where to download iso"); + if (MapUtils.isNotEmpty(storageForDisks)) { + for (StoragePool storagePool : storageForDisks.values()) { + if (poolId != null && storagePool.getId() != poolId) { + throw new CloudRuntimeException("Cannot determine where to download iso"); + } + poolId = storagePool.getId(); } - poolId = storagePool.getId(); } TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId(), dest.getHost().getId(), poolId); if (template == null){ @@ -579,6 +582,7 @@ public void prepareIsoForVmProfile(VirtualMachineProfile profile, DeployDestinat } TemplateObjectTO iso = (TemplateObjectTO)template.getTO(); + iso.setDirectDownload(template.isDirectDownload()); iso.setGuestOsType(displayName); DiskTO disk = new DiskTO(iso, 3L, null, Volume.Type.ISO); profile.addDisk(disk); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services