rhtyd closed pull request #2922: template: create/updateTemplate should allow 
to set/change sshKeyEnabled
URL: https://github.com/apache/cloudstack/pull/2922
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 36767345a4b..cd7aee771ef 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 @@
     @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 Boolean getPasswordEnabled() {
         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 42f138300bc..aa8ecee132f 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 @@
                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 Boolean isPasswordEnabled() {
         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 dc57a8a9ef3..59aa600d10f 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 VMTemplateVO 
createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
         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 VMTemplateVO 
createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
         }
         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 @@ private VMTemplateVO 
updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
         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 @@ private VMTemplateVO 
updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
                   guestOSId == null &&
                   passwordEnabled == null &&
                   bootable == null &&
+                  sshKeyEnabled == null &&
                   requiresHvm == null &&
                   sortKey == null &&
                   isDynamicallyScalable == null &&
@@ -2108,6 +2112,10 @@ private VMTemplateVO 
updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
             template.setEnablePassword(passwordEnabled);
         }
 
+        if (sshKeyEnabled != null) {
+            template.setEnableSshKey(sshKeyEnabled);
+        }
+
         if (bootable != null) {
             template.setBootable(bootable);
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to