From e54071e67479752a14936fc6a363a50f1ea94f7a Mon Sep 17 00:00:00 2001 From: nvazquez Date: Mon, 15 Jan 2018 09:12:05 -0300 Subject: [PATCH] Dettach ISO and direct download label fixes --- .../classes/resources/messages.properties | 2 +- .../kvm/storage/KVMStorageProcessor.java | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties index 0e57e464674..0b7a1a57025 100644 --- a/client/WEB-INF/classes/resources/messages.properties +++ b/client/WEB-INF/classes/resources/messages.properties @@ -2139,5 +2139,5 @@ state.Stopping=Stopping state.Suspended=Suspended ui.listView.filters.all=All ui.listView.filters.mine=Mine -label.directdownload=bypass secondary storage +label.direct.download=Direct Download label.checksum=checksum diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java index 711964cd43a..9238684d231 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java @@ -902,13 +902,23 @@ public class KVMStorageProcessor implements StorageProcessor { DiskTO disk = cmd.getDisk(); TemplateObjectTO isoTO = (TemplateObjectTO)disk.getData(); DataStoreTO store = isoTO.getDataStore(); - if (!(store instanceof NfsTO)) { + + String dataStoreUrl; + if (store instanceof NfsTO) { + NfsTO nfsStore = (NfsTO)store; + dataStoreUrl = nfsStore.getUrl(); + } else if (store instanceof PrimaryDataStoreTO && ((PrimaryDataStoreTO) store).getPoolType().equals(StoragePoolType.NetworkFilesystem)) { + //In order to support directly downloaded ISOs + String psHost = ((PrimaryDataStoreTO) store).getHost(); + String psPath = ((PrimaryDataStoreTO) store).getPath(); + dataStoreUrl = "nfs://" + psHost + File.separator + psPath; + } else { return new AttachAnswer("unsupported protocol"); } - NfsTO nfsStore = (NfsTO)store; + try { Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); - attachOrDetachISO(conn, cmd.getVmName(), nfsStore.getUrl() + File.separator + isoTO.getPath(), false); + attachOrDetachISO(conn, cmd.getVmName(), dataStoreUrl + File.separator + isoTO.getPath(), false); } catch (LibvirtException e) { return new Answer(cmd, false, e.toString()); } catch (URISyntaxException e) {