Skip to content

Commit 3f5fbb8

Browse files
committed
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.
1 parent 489a1d5 commit 3f5fbb8

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎core/src/com/cloud/storage/VMTemplateVO.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic,
153153
this.uuid = UUID.randomUUID().toString();
154154
}
155155

156-
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) {
156+
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) {
157157
this(id, name, format, isPublic, featured, isExtractable, type, url, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId, bootable, hyperType, details);
158158
this.templateTag = templateTag;
159159
this.uuid = UUID.randomUUID().toString();

‎server/src/com/cloud/template/TemplateAdapterBase.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public TemplateProfile prepare(boolean isIso, Long userId, String name, String d
137137
if (isExtractable == null) {
138138
isExtractable = Boolean.FALSE;
139139
}
140+
if (sshkeyEnabled == null) {
141+
sshkeyEnabled = Boolean.FALSE;
142+
}
140143

141144
boolean isAdmin = _accountDao.findById(templateOwner.getId()).getType() == Account.ACCOUNT_TYPE_ADMIN;
142145

0 commit comments

Comments
 (0)