Skip to content

Commit 3de5d9d

Browse files
committed
volume upload: Restart of MS leads to loss of browser uploaded templates
on restart of management server, template sync runs. It checks for templates in ssvm using the uniquename. If it doesnt find any, cleans the directory. In case of uploaded templates, these are getting saved using name instead on uniquename and hence template sync cant find them and does cleanup. Using uniquename in template.properties now.
1 parent aad9b8a commit 3de5d9d

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class TemplateOrVolumePostUploadCommand {
4747

4848
String maxUploadSize;
4949

50+
String description;
51+
5052
public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath, String checksum, String type, String name, String imageFormat, String dataTo,
5153
String dataToRole) {
5254
this.entityId = entityId;
@@ -166,4 +168,12 @@ public String getMaxUploadSize() {
166168
public void setMaxUploadSize(String maxUploadSize) {
167169
this.maxUploadSize = maxUploadSize;
168170
}
171+
172+
public String getDescription() {
173+
return description;
174+
}
175+
176+
public void setDescription(String description) {
177+
this.description = description;
178+
}
169179
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,13 @@ public List<TemplateOrVolumePostUploadCommand> createTemplateForPostUpload(Templ
258258
}
259259

260260
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(), template.getUuid(), tmpl.getInstallPath(), tmpl.getChecksum(), tmpl
261-
.getType().toString(), template.getName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole()
261+
.getType().toString(), template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole()
262262
.toString());
263263
//using the existing max template size configuration
264264
payload.setMaxUploadSize(_configDao.getValue(Config.MaxTemplateAndIsoSize.key()));
265265
payload.setRemoteEndPoint(ep.getPublicAddr());
266266
payload.setRequiresHvm(template.requiresHvm());
267+
payload.setDescription(template.getDisplayText());
267268
payloads.add(payload);
268269
}
269270
_resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template);

services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2634,6 +2634,7 @@ public UploadEntity createUploadEntity(String uuid, String metadata, long conten
26342634
uploadEntity.setHvm(cmd.getRequiresHvm());
26352635
uploadEntity.setChksum(cmd.getChecksum());
26362636
uploadEntity.setMaxSizeInGB(maxSizeInGB);
2637+
uploadEntity.setDescription(cmd.getDescription());
26372638
// create a install dir
26382639
if (!_storage.exists(installPathPrefix)) {
26392640
_storage.mkdir(installPathPrefix);
@@ -2677,9 +2678,9 @@ public String postUpload(String uuid, String filename) {
26772678
Script scr = new Script(getScriptLocation(resourceType), timeout, s_logger);
26782679
scr.add("-s", Integer.toString(imgSizeGigs));
26792680
scr.add("-S", Long.toString(UploadEntity.s_maxTemplateSize));
2680-
//if (uploadEntity.getDescription() != null && dnld.getDescription().length() > 1) {
2681-
// scr.add("-d", dnld.getDescription());
2682-
//}
2681+
if (uploadEntity.getDescription() != null && uploadEntity.getDescription().length() > 1) {
2682+
scr.add("-d", uploadEntity.getDescription());
2683+
}
26832684
if (uploadEntity.isHvm()) {
26842685
scr.add("-h");
26852686
}

services/secondary-storage/server/src/org/apache/cloudstack/storage/template/UploadEntity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class UploadEntity {
3232
private String chksum;
3333
private long physicalSize;
3434
private int maxSizeInGB;
35+
private String description;
3536

3637
public static enum ResourceType {
3738
VOLUME, TEMPLATE
@@ -180,4 +181,12 @@ public int getMaxSizeInGB() {
180181
public void setMaxSizeInGB(int maxSizeInGB) {
181182
this.maxSizeInGB = maxSizeInGB;
182183
}
184+
185+
public String getDescription() {
186+
return description;
187+
}
188+
189+
public void setDescription(String description) {
190+
this.description = description;
191+
}
183192
}

0 commit comments

Comments
 (0)