mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Bug 11689 - Templates need a ssh key enabled attribute
status 11689: resolved fixed
This commit is contained in:
parent
5fb518662f
commit
0d7dc40189
@ -127,6 +127,7 @@ public class ApiConstants {
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String NEW_PASSWORD = "new_password";
|
||||
public static final String PASSWORD_ENABLED = "passwordenabled";
|
||||
public static final String SSHKEY_ENABLED = "sshkeyenabled";
|
||||
public static final String PATH = "path";
|
||||
public static final String POD_ID = "podid";
|
||||
public static final String POLICY_ID = "policyid";
|
||||
|
||||
@ -75,6 +75,9 @@ public class RegisterTemplateCmd extends BaseCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.PASSWORD_ENABLED, type=CommandType.BOOLEAN, 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.IS_EXTRACTABLE, type=CommandType.BOOLEAN, description="true if the template or its derivatives are extractable; default is false")
|
||||
private Boolean extractable;
|
||||
@ -148,6 +151,10 @@ public class RegisterTemplateCmd extends BaseCmd {
|
||||
public Boolean isPasswordEnabled() {
|
||||
return passwordEnabled;
|
||||
}
|
||||
|
||||
public Boolean isSshKeyEnabled() {
|
||||
return sshKeyEnabled;
|
||||
}
|
||||
|
||||
public Boolean isExtractable() {
|
||||
return extractable;
|
||||
|
||||
@ -64,6 +64,8 @@ public interface VirtualMachineTemplate extends ControlledEntity {
|
||||
String getDisplayText();
|
||||
|
||||
boolean getEnablePassword();
|
||||
|
||||
boolean getEnableSshKey();
|
||||
|
||||
boolean isCrossZones();
|
||||
|
||||
|
||||
@ -124,7 +124,10 @@ public class VMTemplateVO implements VirtualMachineTemplate, Identity {
|
||||
private String uuid;
|
||||
|
||||
@Column(name="sort_key")
|
||||
int sortKey;
|
||||
private int sortKey;
|
||||
|
||||
@Column(name="enable_sshkey")
|
||||
private boolean enableSshKey;
|
||||
|
||||
@Transient
|
||||
Map details;
|
||||
@ -150,10 +153,11 @@ 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) {
|
||||
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();
|
||||
this.enableSshKey = sshKeyEnabled;
|
||||
}
|
||||
|
||||
public VMTemplateVO(Long id, String uniqueName, String name, ImageFormat format, boolean isPublic, boolean featured, TemplateType type, String url, Date created, boolean requiresHvm, int bits, long accountId, String cksum, String displayText, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hyperType) {
|
||||
@ -456,5 +460,14 @@ public class VMTemplateVO implements VirtualMachineTemplate, Identity {
|
||||
public int getSortKey() {
|
||||
return sortKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnableSshKey() {
|
||||
return enableSshKey;
|
||||
}
|
||||
|
||||
public void setEnableSshKey(boolean enable) {
|
||||
enableSshKey = enable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
2
server/src/com/cloud/template/TemplateAdapter.java
Normal file → Executable file
2
server/src/com/cloud/template/TemplateAdapter.java
Normal file → Executable file
@ -48,5 +48,5 @@ public interface TemplateAdapter extends Adapter {
|
||||
public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits,
|
||||
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
|
||||
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
|
||||
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details) throws ResourceAllocationException;
|
||||
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshKeyEnabled) throws ResourceAllocationException;
|
||||
}
|
||||
|
||||
@ -93,12 +93,13 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
|
||||
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
|
||||
String accountName, Long domainId, String chksum, Boolean bootable, Map details) throws ResourceAllocationException {
|
||||
return prepare(isIso, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, format, guestOSId, zoneId, hypervisorType,
|
||||
chksum, bootable, null, null, details);
|
||||
chksum, bootable, null, null, details, false);
|
||||
}
|
||||
|
||||
public TemplateProfile prepare(boolean isIso, Long userId, String name, String displayText, Integer bits,
|
||||
Boolean passwordEnabled, Boolean requiresHVM, String url, Boolean isPublic, Boolean featured,
|
||||
Boolean isExtractable, String format, Long guestOSId, Long zoneId, HypervisorType hypervisorType,
|
||||
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details) throws ResourceAllocationException {
|
||||
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map details, Boolean sshkeyEnabled) throws ResourceAllocationException {
|
||||
//Long accountId = null;
|
||||
// parameters verification
|
||||
|
||||
@ -201,7 +202,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
|
||||
Long id = _tmpltDao.getNextInSequence(Long.class, "id");
|
||||
UserContext.current().setEventDetails("Id: " +id+ " name: " + name);
|
||||
return new TemplateProfile(id, userId, name, displayText, bits, passwordEnabled, requiresHVM, url, isPublic,
|
||||
featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details);
|
||||
featured, isExtractable, imgfmt, guestOSId, zoneId, hypervisorType, templateOwner.getAccountName(), templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, templateTag, details, sshkeyEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -214,7 +215,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
|
||||
return prepare(false, UserContext.current().getCallerUserId(), cmd.getTemplateName(), cmd.getDisplayText(),
|
||||
cmd.getBits(), cmd.isPasswordEnabled(), cmd.getRequiresHvm(), cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(),
|
||||
cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()),
|
||||
cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails());
|
||||
cmd.getChecksum(), true, cmd.getTemplateTag(), owner, cmd.getDetails(), cmd.isSshKeyEnabled());
|
||||
}
|
||||
|
||||
public TemplateProfile prepare(RegisterIsoCmd cmd) throws ResourceAllocationException {
|
||||
@ -225,7 +226,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
|
||||
|
||||
return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false,
|
||||
true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(),
|
||||
cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null);
|
||||
cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false);
|
||||
}
|
||||
|
||||
protected VMTemplateVO persistTemplate(TemplateProfile profile) {
|
||||
@ -234,7 +235,7 @@ public abstract class TemplateAdapterBase implements TemplateAdapter {
|
||||
profile.getFeatured(), profile.getIsExtractable(), TemplateType.USER, profile.getUrl(), profile.getRequiresHVM(),
|
||||
profile.getBits(), profile.getAccountId(), profile.getCheckSum(), profile.getDisplayText(),
|
||||
profile.getPasswordEnabled(), profile.getGuestOsId(), profile.getBootable(), profile.getHypervisorType(), profile.getTemplateTag(),
|
||||
profile.getDetails());
|
||||
profile.getDetails(), profile.getSshKeyEnabled());
|
||||
|
||||
if (zoneId == null || zoneId == -1) {
|
||||
List<DataCenterVO> dcs = _dcDao.listAll();
|
||||
|
||||
16
server/src/com/cloud/template/TemplateProfile.java
Normal file → Executable file
16
server/src/com/cloud/template/TemplateProfile.java
Normal file → Executable file
@ -12,6 +12,7 @@ public class TemplateProfile {
|
||||
String displayText;
|
||||
Integer bits;
|
||||
Boolean passwordEnabled;
|
||||
Boolean sshKeyEnbaled;
|
||||
Boolean requiresHvm;
|
||||
String url;
|
||||
Boolean isPublic;
|
||||
@ -33,7 +34,7 @@ public class TemplateProfile {
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
|
||||
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details) {
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details, Boolean sshKeyEnabled) {
|
||||
this.templateId = templateId;
|
||||
this.userId = userId;
|
||||
this.name = name;
|
||||
@ -55,6 +56,7 @@ public class TemplateProfile {
|
||||
this.chksum = chksum;
|
||||
this.bootable = bootable;
|
||||
this.details = details;
|
||||
this.sshKeyEnbaled = sshKeyEnabled;
|
||||
}
|
||||
|
||||
public TemplateProfile(Long userId, VMTemplateVO template, Long zoneId) {
|
||||
@ -65,9 +67,9 @@ public class TemplateProfile {
|
||||
|
||||
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm,
|
||||
String url, Boolean isPublic, Boolean featured, Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId,
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details) {
|
||||
HypervisorType hypervisorType, String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag, Map details, Boolean sshKeyEnabled) {
|
||||
this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured, isExtractable, format, guestOsId, zoneId,
|
||||
hypervisorType, accountName, domainId, accountId, chksum, bootable, details);
|
||||
hypervisorType, accountName, domainId, accountId, chksum, bootable, details, sshKeyEnabled);
|
||||
this.templateTag = templateTag;
|
||||
}
|
||||
|
||||
@ -226,4 +228,12 @@ public class TemplateProfile {
|
||||
public void setDetails(Map details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void setSshKeyEnabled(Boolean enabled) {
|
||||
this.sshKeyEnbaled = enabled;
|
||||
}
|
||||
|
||||
public Boolean getSshKeyEnabled() {
|
||||
return this.sshKeyEnbaled;
|
||||
}
|
||||
}
|
||||
|
||||
@ -908,6 +908,7 @@ CREATE TABLE `cloud`.`vm_template` (
|
||||
`checksum` varchar(255) COMMENT 'checksum for the template root disk',
|
||||
`display_text` varchar(4096) NULL COMMENT 'Description text set by the admin for display purpose only',
|
||||
`enable_password` int(1) unsigned NOT NULL default 1 COMMENT 'true if this template supports password reset',
|
||||
`enable_sshkey` int(1) unsigned NOT NULL default 1 COMMENT 'true if this template supports sshkey reset',
|
||||
`guest_os_id` bigint unsigned NOT NULL COMMENT 'the OS of the template',
|
||||
`bootable` int(1) unsigned NOT NULL default 1 COMMENT 'true if this template represents a bootable ISO',
|
||||
`prepopulate` int(1) unsigned NOT NULL default 0 COMMENT 'prepopulate this template to primary storage',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user