NSX: Allow registration of CKS templates

This commit is contained in:
Pearl Dsilva 2024-02-07 12:51:47 -05:00
parent 35357dc8f9
commit 66e874b4c7
15 changed files with 66 additions and 0 deletions

View File

@ -144,6 +144,8 @@ public interface VirtualMachineTemplate extends ControlledEntity, Identity, Inte
boolean isDeployAsIs();
boolean isForCks();
Long getUserDataId();
UserData.UserDataOverridePolicy getUserDataOverridePolicy();

View File

@ -824,6 +824,7 @@ public class ApiConstants {
public static final String SPLIT_CONNECTIONS = "splitconnections";
public static final String FOR_VPC = "forvpc";
public static final String FOR_NSX = "fornsx";
public static final String FOR_CKS = "forcks";
public static final String NSX_SUPPORT_LB = "nsxsupportlb";
public static final String FOR_TUNGSTEN = "fortungsten";
public static final String SHRINK_OK = "shrinkok";

View File

@ -169,6 +169,11 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
description = "(VMware only) true if VM deployments should preserve all the configurations defined for this template", since = "4.15.1")
protected Boolean deployAsIs;
@Parameter(name=ApiConstants.FOR_CKS,
type = CommandType.BOOLEAN,
description = "if true, the templates would be available for deploying CKS clusters", since = "4.20.0")
protected Boolean forCks;
@Parameter(name = ApiConstants.TEMPLATE_TYPE, type = CommandType.STRING,
description = "the type of the template. Valid options are: USER/VNF (for all users) and SYSTEM/ROUTING/BUILTIN (for admins only).",
since = "4.19.0")
@ -291,6 +296,10 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
Boolean.TRUE.equals(deployAsIs);
}
public boolean isForCks() {
return Boolean.TRUE.equals(forCks);
}
public String getTemplateType() {
return templateType;
}

View File

@ -200,6 +200,11 @@ public class TemplateResponse extends BaseResponseWithTagInformation implements
since = "4.15")
private Boolean deployAsIs;
@SerializedName(ApiConstants.FOR_CKS)
@Param(description = "If true it indicates that the template can be used for CKS cluster deployments",
since = "4.20")
private Boolean forCks;
@SerializedName(ApiConstants.DEPLOY_AS_IS_DETAILS)
@Param(description = "VMware only: additional key/value details tied with deploy-as-is template",
since = "4.15")
@ -440,6 +445,10 @@ public class TemplateResponse extends BaseResponseWithTagInformation implements
this.deployAsIs = deployAsIs;
}
public void setForCks(Boolean forCks) {
this.forCks = forCks;
}
public void setParentTemplateId(String parentTemplateId) {
this.parentTemplateId = parentTemplateId;
}

View File

@ -158,6 +158,9 @@ public class VMTemplateVO implements VirtualMachineTemplate {
@Column(name = "deploy_as_is")
private boolean deployAsIs;
@Column(name = "for_cks")
private boolean forCks;
@Column(name = "user_data_id")
private Long userDataId;
@ -653,6 +656,14 @@ public class VMTemplateVO implements VirtualMachineTemplate {
this.deployAsIs = deployAsIs;
}
public boolean isForCks() {
return forCks;
}
public void setForCks(boolean forCks) {
this.forCks = forCks;
}
@Override
public Long getUserDataId() {
return userDataId;

View File

@ -360,3 +360,6 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.quarantined_ips', 'remover_account_i
-- Explicitly add support for VMware 8.0b (8.0.0.2), 8.0c (8.0.0.3)
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities` (uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported, vm_snapshot_enabled) values (UUID(), 'VMware', '8.0.0.2', 1024, 0, 59, 64, 1, 1);
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities` (uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported, vm_snapshot_enabled) values (UUID(), 'VMware', '8.0.0.3', 1024, 0, 59, 64, 1, 1);
-- Add for_cks column to the vm_template table
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.vm_template','for_cks', 'int(1) unsigned DEFAULT "0" COMMENT "if true, the template can be used for CKS cluster deployment"');

View File

@ -99,6 +99,7 @@ SELECT
IFNULL(`data_center`.`id`, 0)) AS `temp_zone_pair`,
`vm_template`.`direct_download` AS `direct_download`,
`vm_template`.`deploy_as_is` AS `deploy_as_is`,
`vm_template`.`for_cks` AS `for_cks`,
`user_data`.`id` AS `user_data_id`,
`user_data`.`uuid` AS `user_data_uuid`,
`user_data`.`name` AS `user_data_name`,

View File

@ -413,6 +413,11 @@ public class TemplateObject implements TemplateInfo {
return this.imageVO.isDeployAsIs();
}
@Override
public boolean isForCks() {
return imageVO.isForCks();
}
public void setInstallPath(String installPath) {
this.installPath = installPath;
}

View File

@ -312,6 +312,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
templateResponse.setDetails(details);
setDeployAsIsDetails(template, templateResponse);
templateResponse.setForCks(template.isForCks());
}
// update tag information

View File

@ -236,6 +236,9 @@ public class TemplateJoinVO extends BaseViewWithTagInformationVO implements Cont
@Column(name = "deploy_as_is")
private boolean deployAsIs;
@Column(name = "for_cks")
private boolean forCks;
@Column(name = "user_data_id")
private Long userDataId;
@ -514,6 +517,10 @@ public class TemplateJoinVO extends BaseViewWithTagInformationVO implements Cont
return deployAsIs;
}
public boolean isForCks() {
return forCks;
}
public Object getParentTemplateId() {
return parentTemplateId;
}

View File

@ -53,6 +53,7 @@ public class TemplateProfile {
TemplateType templateType;
Boolean directDownload;
Boolean deployAsIs;
Boolean forCks;
Long size;
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits, Boolean passwordEnabled, Boolean requiresHvm, String url,
@ -337,4 +338,12 @@ public class TemplateProfile {
public boolean isDeployAsIs() {
return this.deployAsIs;
}
public Boolean isForCks() {
return forCks;
}
public void setForCks(Boolean forCks) {
this.forCks = forCks;
}
}

View File

@ -241,6 +241,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
Long templateSize = performDirectDownloadUrlValidation(cmd.getFormat(),
hypervisor, url, cmd.getZoneIds());
profile.setSize(templateSize);
profile.setForCks(cmd.isForCks());
}
profile.setUrl(url);
// Check that the resource limit for secondary storage won't be exceeded

View File

@ -401,6 +401,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat
profile.getDisplayText(), profile.isPasswordEnabled(), profile.getGuestOsId(), profile.isBootable(), profile.getHypervisorType(),
profile.getTemplateTag(), profile.getDetails(), profile.isSshKeyEnabled(), profile.IsDynamicallyScalable(), profile.isDirectDownload(), profile.isDeployAsIs());
template.setState(initialState);
template.setForCks(profile.isForCks());
if (profile.isDirectDownload()) {
template.setSize(profile.getSize());

View File

@ -903,6 +903,7 @@
"label.fix.errors": "Fix errors",
"label.fixed": "Fixed offering",
"label.for": "for",
"label.for.cks": "For CKS",
"label.forbidden": "Forbidden",
"label.forced": "Force",
"label.force.stop": "Force stop",

View File

@ -424,6 +424,11 @@
{{ $t('label.ispublic') }}
</a-checkbox>
</a-col>
<a-col :span="12">
<a-checkbox value="forCks">
{{ $t('label.for.cks') }}
</a-checkbox>
</a-col>
</a-row>
</a-checkbox-group>
</a-form-item>