mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
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 <abhishek.mrt@gmail.com>
This commit is contained in:
parent
71e5a88fc1
commit
c8ca9e2fa0
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user