From bf88d11f4992fba22823430cafbf2d72706a8231 Mon Sep 17 00:00:00 2001 From: Daan de Goede Date: Mon, 5 Oct 2020 10:06:57 +0200 Subject: [PATCH] Adding uniqueName to downloads for correct sync handling --- .../NfsSecondaryStorageResource.java | 2 +- .../cloud/storage/image/store/TemplateObject.java | 4 ++-- .../communication/command/DownloadCommand.java | 2 +- .../com/cloud/legacymodel/to/TemplateObjectTO.java | 12 +++++++++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cosmic-agent/src/main/java/com/cloud/agent/resource/secondarystorage/NfsSecondaryStorageResource.java b/cosmic-agent/src/main/java/com/cloud/agent/resource/secondarystorage/NfsSecondaryStorageResource.java index d07d592e07..ce3b4013dd 100644 --- a/cosmic-agent/src/main/java/com/cloud/agent/resource/secondarystorage/NfsSecondaryStorageResource.java +++ b/cosmic-agent/src/main/java/com/cloud/agent/resource/secondarystorage/NfsSecondaryStorageResource.java @@ -365,7 +365,7 @@ protected Answer copySnapshotToTemplateFromNfsToNfs(final CopyCommand cmd, final ) { // KVM didn't change template unique name, just used the template name passed from orchestration layer, so no need // to send template name back. - bufferWriter.write("uniquename=" + destData.getName()); + bufferWriter.write("uniquename=" + destData.getUniqueName()); bufferWriter.write("\n"); bufferWriter.write("filename=" + fileName); bufferWriter.write("\n"); diff --git a/cosmic-core/engine/storage/default/src/main/java/com/cloud/storage/image/store/TemplateObject.java b/cosmic-core/engine/storage/default/src/main/java/com/cloud/storage/image/store/TemplateObject.java index 12af2e0ff8..f9ed998bb1 100644 --- a/cosmic-core/engine/storage/default/src/main/java/com/cloud/storage/image/store/TemplateObject.java +++ b/cosmic-core/engine/storage/default/src/main/java/com/cloud/storage/image/store/TemplateObject.java @@ -404,12 +404,12 @@ public DataTO getTO() { } if (dataStore == null) { to = new TemplateObjectTO(this.getInstallPath(), this.getUrl(), this.getUuid(), this.getId(), this.getFormat(), this.getAccountId(), this.getChecksum(), this.getDisplayText(), - dataStoreTO, this.getName(), null, null, null, this.getHypervisorType()); + dataStoreTO, this.getName(), this.getUniqueName(), null, null, null, this.getHypervisorType()); } else { to = dataStore.getDriver().getTO(this); if (to == null) { to = new TemplateObjectTO(this.getInstallPath(), this.getUrl(), this.getUuid(), this.getId(), this.getFormat(), this.getAccountId(), this.getChecksum(), this.getDisplayText(), - dataStoreTO, this.getName(), null, null, null, this.getHypervisorType()); + dataStoreTO, this.getName(), this.getUniqueName(), null, null, null, this.getHypervisorType()); } } diff --git a/cosmic-model/src/main/java/com/cloud/legacymodel/communication/command/DownloadCommand.java b/cosmic-model/src/main/java/com/cloud/legacymodel/communication/command/DownloadCommand.java index 518fcac45e..961cbe6b7f 100644 --- a/cosmic-model/src/main/java/com/cloud/legacymodel/communication/command/DownloadCommand.java +++ b/cosmic-model/src/main/java/com/cloud/legacymodel/communication/command/DownloadCommand.java @@ -54,7 +54,7 @@ public DownloadCommand(final TemplateObjectTO template, final String user, final public DownloadCommand(final TemplateObjectTO template, final Long maxDownloadSizeInBytes) { - super(template.getName(), template.getOrigUrl(), template.getFormat(), template.getAccountId()); + super(template.getUniqueName(), template.getOrigUrl(), template.getFormat(), template.getAccountId()); _store = template.getDataStore(); installPath = template.getPath(); checksum = template.getChecksum(); diff --git a/cosmic-model/src/main/java/com/cloud/legacymodel/to/TemplateObjectTO.java b/cosmic-model/src/main/java/com/cloud/legacymodel/to/TemplateObjectTO.java index 6c73b4b5c8..b882d8dbad 100644 --- a/cosmic-model/src/main/java/com/cloud/legacymodel/to/TemplateObjectTO.java +++ b/cosmic-model/src/main/java/com/cloud/legacymodel/to/TemplateObjectTO.java @@ -15,6 +15,7 @@ public class TemplateObjectTO implements DataTO { private String displayText; private DataStoreTO imageDataStore; private String name; + private String uniqueName; private String guestOsType; private Long size; private Long physicalSize; @@ -25,7 +26,7 @@ public TemplateObjectTO() { } public TemplateObjectTO(final String path, final String origUrl, final String uuid, final long id, final ImageFormat format, final long accountId, final String checksum, final String - displayText, final DataStoreTO imageDataStore, final String name, final String guestOsType, final Long size, final Long physicalSize, final HypervisorType hypervisorType) { + displayText, final DataStoreTO imageDataStore, final String name, final String uniqueName, final String guestOsType, final Long size, final Long physicalSize, final HypervisorType hypervisorType) { this.path = path; this.origUrl = origUrl; this.uuid = uuid; @@ -36,6 +37,7 @@ public TemplateObjectTO(final String path, final String origUrl, final String uu this.displayText = displayText; this.imageDataStore = imageDataStore; this.name = name; + this.uniqueName = uniqueName; this.guestOsType = guestOsType; this.size = size; this.physicalSize = physicalSize; @@ -130,10 +132,18 @@ public String getName() { return name; } + public String getUniqueName() { + return uniqueName; + } + public void setName(final String name) { this.name = name; } + public void setUniqueName(final String uniqueName) { + this.uniqueName = uniqueName; + } + public String getOrigUrl() { return origUrl; }