Repository: cloudstack Updated Branches: refs/heads/master 7877f3f96 -> 082aed3d3
CLOUDSTACK-7588: [Vmware] Creating templates (with same names) from volumes get deleted from CS. Fix it by changing the unique name generation to the standard one used by registertemplate. Also cleaned up vmtemplatevo which had too many constructors. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/082aed3d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/082aed3d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/082aed3d Branch: refs/heads/master Commit: 082aed3d33109903208014432eebbe3e69737d4e Parents: 7877f3f Author: Nitin Mehta <nitin.me...@citrix.com> Authored: Fri Sep 19 13:40:17 2014 -0700 Committer: Nitin Mehta <nitin.me...@citrix.com> Committed: Fri Sep 19 13:40:17 2014 -0700 ---------------------------------------------------------------------- .../src/com/cloud/storage/VMTemplateVO.java | 38 +++----------------- .../com/cloud/template/TemplateManagerImpl.java | 9 ++--- 2 files changed, 7 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/082aed3d/engine/schema/src/com/cloud/storage/VMTemplateVO.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/com/cloud/storage/VMTemplateVO.java b/engine/schema/src/com/cloud/storage/VMTemplateVO.java index 9a77cbf..d44de22 100755 --- a/engine/schema/src/com/cloud/storage/VMTemplateVO.java +++ b/engine/schema/src/com/cloud/storage/VMTemplateVO.java @@ -159,10 +159,8 @@ public class VMTemplateVO implements VirtualMachineTemplate { uuid = UUID.randomUUID().toString(); } - /** - * Proper constructor for a new vm template. - */ - public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, + //FIXME - Remove unwanted constructors. + private VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType, Map<String, String> details) { this(id, @@ -250,8 +248,8 @@ public class VMTemplateVO implements VirtualMachineTemplate { state = State.Active; } - // Has an extra attribute - isExtractable - public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, + //FIXME - Remove unwanted constructors. Made them private for now + private VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, String url, Date created, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType, Map<String, String> details) { this(id, @@ -278,34 +276,6 @@ public class VMTemplateVO implements VirtualMachineTemplate { state = State.Active; } - public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, boolean isExtractable, TemplateType type, - String url, Date created, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, - boolean bootable, HypervisorType hyperType, String templateTag, Map<String, String> details) { - this(id, - uniqueName, - name, - format, - isPublic, - featured, - isExtractable, - type, - url, - created, - requiresHvm, - bits, - accountId, - cksum, - displayText, - enablePassword, - guestOSId, - bootable, - hyperType, - details); - this.templateTag = templateTag; - uuid = UUID.randomUUID().toString(); - state = State.Active; - } - @Override public boolean getEnablePassword() { return enablePassword; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/082aed3d/server/src/com/cloud/template/TemplateManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 06ca5e0..247ed00 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -22,7 +22,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -1605,7 +1604,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, throw new InvalidParameterValueException("GuestOS with ID: " + guestOSId + " does not exist."); } - String uniqueName = Long.valueOf((userId == null) ? 1 : userId).toString() + UUID.nameUUIDFromBytes(name.getBytes()).toString(); Long nextTemplateId = _tmpltDao.getNextInSequence(Long.class, "id"); String description = cmd.getDisplayText(); boolean isExtractable = false; @@ -1630,10 +1628,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, s_logger.debug("Adding template tag: " + templateTag); } } - privateTemplate = - new VMTemplateVO(nextTemplateId, uniqueName, name, ImageFormat.RAW, isPublic, featured, isExtractable, TemplateType.USER, null, null, requiresHvmValue, - bitsValue, templateOwner.getId(), null, description, passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails()); - privateTemplate.setDynamicallyScalable(isDynamicScalingEnabled); + privateTemplate = new VMTemplateVO(nextTemplateId, name, ImageFormat.RAW, isPublic, featured, isExtractable, + TemplateType.USER, null, requiresHvmValue, bitsValue, templateOwner.getId(), null, description, + passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails(), false, isDynamicScalingEnabled); if (sourceTemplateId != null) { if (s_logger.isDebugEnabled()) {