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.
This commit is contained in:
Rajani Karuturi 2015-03-16 12:41:58 +05:30
parent aad9b8a51f
commit 3de5d9db5f
4 changed files with 25 additions and 4 deletions

View File

@ -47,6 +47,8 @@ public class TemplateOrVolumePostUploadCommand {
String maxUploadSize;
String description;
public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath, String checksum, String type, String name, String imageFormat, String dataTo,
String dataToRole) {
this.entityId = entityId;
@ -166,4 +168,12 @@ public class TemplateOrVolumePostUploadCommand {
public void setMaxUploadSize(String maxUploadSize) {
this.maxUploadSize = maxUploadSize;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -258,12 +258,13 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
}
TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(), template.getUuid(), tmpl.getInstallPath(), tmpl.getChecksum(), tmpl
.getType().toString(), template.getName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole()
.getType().toString(), template.getUniqueName(), template.getFormat().toString(), templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole()
.toString());
//using the existing max template size configuration
payload.setMaxUploadSize(_configDao.getValue(Config.MaxTemplateAndIsoSize.key()));
payload.setRemoteEndPoint(ep.getPublicAddr());
payload.setRequiresHvm(template.requiresHvm());
payload.setDescription(template.getDisplayText());
payloads.add(payload);
}
_resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template);

View File

@ -2634,6 +2634,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
uploadEntity.setHvm(cmd.getRequiresHvm());
uploadEntity.setChksum(cmd.getChecksum());
uploadEntity.setMaxSizeInGB(maxSizeInGB);
uploadEntity.setDescription(cmd.getDescription());
// create a install dir
if (!_storage.exists(installPathPrefix)) {
_storage.mkdir(installPathPrefix);
@ -2677,9 +2678,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
Script scr = new Script(getScriptLocation(resourceType), timeout, s_logger);
scr.add("-s", Integer.toString(imgSizeGigs));
scr.add("-S", Long.toString(UploadEntity.s_maxTemplateSize));
//if (uploadEntity.getDescription() != null && dnld.getDescription().length() > 1) {
// scr.add("-d", dnld.getDescription());
//}
if (uploadEntity.getDescription() != null && uploadEntity.getDescription().length() > 1) {
scr.add("-d", uploadEntity.getDescription());
}
if (uploadEntity.isHvm()) {
scr.add("-h");
}

View File

@ -32,6 +32,7 @@ public class UploadEntity {
private String chksum;
private long physicalSize;
private int maxSizeInGB;
private String description;
public static enum ResourceType {
VOLUME, TEMPLATE
@ -180,4 +181,12 @@ public class UploadEntity {
public void setMaxSizeInGB(int maxSizeInGB) {
this.maxSizeInGB = maxSizeInGB;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}