From 3f5fbb8fe49cecd37fba5f2c52999a5ad9d598cd Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Tue, 6 Dec 2011 16:31:02 +0530 Subject: [PATCH] bug 12282: Fixed NPE in register template API. The ssh key enabled attribute didnt have any default value and was throwing NPE. Also changed some minor code to stick to the conventions. Reviewed by : Kishan. --- core/src/com/cloud/storage/VMTemplateVO.java | 2 +- server/src/com/cloud/template/TemplateAdapterBase.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/com/cloud/storage/VMTemplateVO.java b/core/src/com/cloud/storage/VMTemplateVO.java index 49b6842896c..d4a01292b39 100755 --- a/core/src/com/cloud/storage/VMTemplateVO.java +++ b/core/src/com/cloud/storage/VMTemplateVO.java @@ -153,7 +153,7 @@ public class VMTemplateVO implements VirtualMachineTemplate, Identity { this.uuid = UUID.randomUUID().toString(); } - public 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, String templateTag, Map details, Boolean sshKeyEnabled) { + public 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, String templateTag, Map details, boolean sshKeyEnabled) { this(id, name, format, isPublic, featured, isExtractable, type, url, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details); this.templateTag = templateTag; this.uuid = UUID.randomUUID().toString(); diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index b94b3b1e8a0..877e527ad35 100755 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -137,6 +137,9 @@ public abstract class TemplateAdapterBase implements TemplateAdapter { if (isExtractable == null) { isExtractable = Boolean.FALSE; } + if (sshkeyEnabled == null) { + sshkeyEnabled = Boolean.FALSE; + } boolean isAdmin = _accountDao.findById(templateOwner.getId()).getType() == Account.ACCOUNT_TYPE_ADMIN;