From 471a0e73fe0a53cafd55a505797d6093ab48c1e6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 9 Dec 2010 18:55:13 -0800 Subject: [PATCH] fixing a bug wherein the template/iso gets deleted from the host once upload, on a ms restart. it still exists in db. any further attempt to create vm from this template/iso results in failure. --- api/src/com/cloud/storage/Storage.java | 3 ++- server/src/com/cloud/template/TemplateManagerImpl.java | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/src/com/cloud/storage/Storage.java b/api/src/com/cloud/storage/Storage.java index 87ac50ef9a3..aaf71b43bf9 100644 --- a/api/src/com/cloud/storage/Storage.java +++ b/api/src/com/cloud/storage/Storage.java @@ -82,7 +82,8 @@ public class Storage { public static enum TemplateType { SYSTEM, /*routing, system vm template*/ BUILTIN, /*buildin template*/ - PERHOST /* every host has this template, don't need to install it in secondary storage */ + PERHOST, /* every host has this template, don't need to install it in secondary storage */ + USER /* User supplied template/iso */ } public static enum StoragePoolType { diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 36061a9424a..07b787c58b0 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -251,7 +251,7 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe throw new ServerApiException(BaseCmd.PARAM_ERROR, "File:// type urls are currently unsupported"); } - return createTemplateOrIso(userId, accountId, zoneId, name, displayText, isPublic.booleanValue(), featured.booleanValue(), true, ImageFormat.ISO.toString(), null, url, null, true, 64 /*bits*/, false, guestOSId, bootable, HypervisorType.None); + return createTemplateOrIso(userId, accountId, zoneId, name, displayText, isPublic.booleanValue(), featured.booleanValue(), true, ImageFormat.ISO.toString(), TemplateType.USER, url, null, true, 64 /*bits*/, false, guestOSId, bootable, HypervisorType.None); } @Override @@ -360,11 +360,11 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe userId = Long.valueOf(1); } - return createTemplateOrIso(userId, accountId, zoneId, name, displayText, isPublic, featured, isExtractable, format, "ext3", url, null, requiresHVM, bits, passwordEnabled, guestOSId, true, hypervisorType); + return createTemplateOrIso(userId, accountId, zoneId, name, displayText, isPublic, featured, isExtractable, format, TemplateType.USER, url, null, requiresHVM, bits, passwordEnabled, guestOSId, true, hypervisorType); } - private VMTemplateVO createTemplateOrIso(long userId, Long accountId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, boolean isExtractable, String format, String diskType, String url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hypervisorType) throws IllegalArgumentException, ResourceAllocationException { + private VMTemplateVO createTemplateOrIso(long userId, Long accountId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, boolean isExtractable, String format, TemplateType diskType, String url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hypervisorType) throws IllegalArgumentException, ResourceAllocationException { try { if (name.length() > 32) @@ -426,7 +426,7 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe throw new IllegalArgumentException("Cannot use reserved names for templates"); } - return create(userId, accountId, zoneId, name, displayText, isPublic, featured, isExtractable, imgfmt, null, uri, chksum, requiresHvm, bits, enablePassword, guestOSId, bootable, hypervisorType); + return create(userId, accountId, zoneId, name, displayText, isPublic, featured, isExtractable, imgfmt, diskType, uri, chksum, requiresHvm, bits, enablePassword, guestOSId, bootable, hypervisorType); } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid URL " + url); }