This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new c8ca9e2 template: create/updateTemplate should allow to set/change
sshKeyEnabled (#2922)
c8ca9e2 is described below
commit c8ca9e2fa0774e0909ab700ec170f00934ab7681
Author: Abhishek <[email protected]>
AuthorDate: Wed Oct 24 11:07:03 2018 +0530
template: create/updateTemplate should allow to set/change sshKeyEnabled
(#2922)
Added sshKeyEnabled key in createTemplate and updateTemplate API.
Fixes #2822.
Signed-off-by: Abhishek Kumar <[email protected]>
---
.../org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java | 7 +++++++
.../api/command/user/template/CreateTemplateCmd.java | 7 +++++++
.../src/main/java/com/cloud/template/TemplateManagerImpl.java | 10 +++++++++-
3 files changed, 23 insertions(+), 1 deletion(-)
diff --git
a/api/src/main/java/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
b/api/src/main/java/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
index 3676734..cd7aee7 100644
---
a/api/src/main/java/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
+++
b/api/src/main/java/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
@@ -58,6 +58,9 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends
BaseCmd {
@Parameter(name = ApiConstants.PASSWORD_ENABLED, type =
CommandType.BOOLEAN, description = "true if the image supports the password
reset feature; default is false")
private Boolean passwordEnabled;
+ @Parameter(name = ApiConstants.SSHKEY_ENABLED, type = CommandType.BOOLEAN,
description = "true if the template supports the sshkey upload feature; default
is false")
+ private Boolean sshKeyEnabled;
+
@Parameter(name = ApiConstants.SORT_KEY, type = CommandType.INTEGER,
description = "sort key of the template, integer")
private Integer sortKey;
@@ -109,6 +112,10 @@ public abstract class BaseUpdateTemplateOrIsoCmd extends
BaseCmd {
return passwordEnabled;
}
+ public Boolean isSshKeyEnabled() {
+ return sshKeyEnabled;
+ }
+
public String getFormat() {
return format;
}
diff --git
a/api/src/main/java/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
b/api/src/main/java/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
index 42f1383..aa8ecee 100644
---
a/api/src/main/java/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
+++
b/api/src/main/java/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
@@ -92,6 +92,9 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
description = "true if the template supports the password reset
feature; default is false")
private Boolean passwordEnabled;
+ @Parameter(name = ApiConstants.SSHKEY_ENABLED, type = CommandType.BOOLEAN,
description = "true if the template supports the sshkey upload feature; default
is false")
+ private Boolean sshKeyEnabled;
+
@Parameter(name = ApiConstants.REQUIRES_HVM, type = CommandType.BOOLEAN,
description = "true if the template requres HVM, false otherwise")
private Boolean requiresHvm;
@@ -163,6 +166,10 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
return passwordEnabled;
}
+ public Boolean isSshKeyEnabled() {
+ return sshKeyEnabled;
+ }
+
public Boolean getRequiresHvm() {
return requiresHvm;
}
diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
index dc57a8a..59aa600 100755
--- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
@@ -1736,11 +1736,13 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
Integer bits = cmd.getBits();
Boolean requiresHvm = cmd.getRequiresHvm();
Boolean passwordEnabled = cmd.isPasswordEnabled();
+ Boolean sshKeyEnabled = cmd.isSshKeyEnabled();
Boolean isPublic = cmd.isPublic();
Boolean featured = cmd.isFeatured();
int bitsValue = ((bits == null) ? 64 : bits.intValue());
boolean requiresHvmValue = ((requiresHvm == null) ? true :
requiresHvm.booleanValue());
boolean passwordEnabledValue = ((passwordEnabled == null) ? false :
passwordEnabled.booleanValue());
+ boolean sshKeyEnabledValue = ((sshKeyEnabled == null) ? false :
sshKeyEnabled.booleanValue());
if (isPublic == null) {
isPublic = Boolean.FALSE;
}
@@ -1849,7 +1851,7 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
}
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, false);
+ passwordEnabledValue, guestOS.getId(), true, hyperType,
templateTag, cmd.getDetails(), sshKeyEnabledValue, isDynamicScalingEnabled,
false);
if (sourceTemplateId != null) {
if (s_logger.isDebugEnabled()) {
@@ -2010,6 +2012,7 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
String format = cmd.getFormat();
Long guestOSId = cmd.getOsTypeId();
Boolean passwordEnabled = cmd.getPasswordEnabled();
+ Boolean sshKeyEnabled = cmd.isSshKeyEnabled();
Boolean isDynamicallyScalable = cmd.isDynamicallyScalable();
Boolean isRoutingTemplate = cmd.isRoutingType();
Boolean bootable = cmd.getBootable();
@@ -2045,6 +2048,7 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
guestOSId == null &&
passwordEnabled == null &&
bootable == null &&
+ sshKeyEnabled == null &&
requiresHvm == null &&
sortKey == null &&
isDynamicallyScalable == null &&
@@ -2108,6 +2112,10 @@ public class TemplateManagerImpl extends ManagerBase
implements TemplateManager,
template.setEnablePassword(passwordEnabled);
}
+ if (sshKeyEnabled != null) {
+ template.setEnableSshKey(sshKeyEnabled);
+ }
+
if (bootable != null) {
template.setBootable(bootable);
}