Skip to content

Commit 3b58ce2

Browse files
committed
CLOUDSTACK-10146: Fixes for ISOs
1 parent d653105 commit 3b58ce2

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

agent/src/com/cloud/agent/direct/download/DirectTemplateDownloaderImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ public boolean validateChecksum() {
185185
String algorithm = providedChecksum.getAlgorithm();
186186
String checksumCommand = "echo '%s %s' | %s -c --quiet";
187187
String cmd = String.format(checksumCommand, providedChecksum.getChecksum(), downloadedFilePath, getChecksumCommandFromAlgorithm(algorithm));
188-
String result = Script.runSimpleBashScript(cmd);
189-
return StringUtils.isBlank(result);
188+
int result = Script.runSimpleBashScriptForExitValue(cmd);
189+
return result == 0;
190190
}
191191
return true;
192192
}

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,21 @@ public Answer attachIso(final AttachCommand cmd) {
904904
final DiskTO disk = cmd.getDisk();
905905
final TemplateObjectTO isoTO = (TemplateObjectTO)disk.getData();
906906
final DataStoreTO store = isoTO.getDataStore();
907-
if (!(store instanceof NfsTO)) {
907+
String dataStoreUrl = null;
908+
if (store instanceof NfsTO) {
909+
NfsTO nfsStore = (NfsTO)store;
910+
dataStoreUrl = nfsStore.getUrl();
911+
} else if (store instanceof PrimaryDataStoreTO && ((PrimaryDataStoreTO) store).getPoolType().equals(StoragePoolType.NetworkFilesystem)) {
912+
//In order to support directly downloaded ISOs
913+
String psHost = ((PrimaryDataStoreTO) store).getHost();
914+
String psPath = ((PrimaryDataStoreTO) store).getPath();
915+
dataStoreUrl = "nfs://" + psHost + File.separator + psPath;
916+
} else {
908917
return new AttachAnswer("unsupported protocol");
909918
}
910-
final NfsTO nfsStore = (NfsTO)store;
911919
try {
912920
final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
913-
attachOrDetachISO(conn, cmd.getVmName(), nfsStore.getUrl() + File.separator + isoTO.getPath(), true);
921+
attachOrDetachISO(conn, cmd.getVmName(), dataStoreUrl + File.separator + isoTO.getPath(), true);
914922
} catch (final LibvirtException e) {
915923
return new Answer(cmd, false, e.toString());
916924
} catch (final URISyntaxException e) {

server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ public TemplateResponse newIsoResponse(TemplateJoinVO iso) {
323323
} else {
324324
isoStatus = iso.getDownloadPercent() + "% Downloaded";
325325
}
326+
} else if (iso.getDownloadState() == Status.BYPASSED) {
327+
isoStatus = "Bypassed Secondary Storage";
326328
} else {
327329
isoStatus = iso.getErrorString();
328330
}

server/src/com/cloud/template/TemplateManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ private boolean attachISOToVM(long vmId, long isoId, boolean attach) {
12031203
}
12041204

12051205
// prepare ISO ready to mount on hypervisor resource level
1206-
TemplateInfo tmplt = prepareIso(isoId, vm.getDataCenterId(), null, null);
1206+
TemplateInfo tmplt = prepareIso(isoId, vm.getDataCenterId(), vm.getHostId(), null);
12071207

12081208
String vmName = vm.getInstanceName();
12091209

0 commit comments

Comments
 (0)