This is an automated email from the ASF dual-hosted git repository.

pearl11594 pushed a commit to branch fr06-cks-template-register
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 8ac71ba183e70538149b1ea5db882324ab28c5fc
Author: Pearl Dsilva <pearl1...@gmail.com>
AuthorDate: Thu Feb 8 06:42:08 2024 -0500

    fix issues
---
 .../user/template/GetUploadParamsForTemplateCmd.java     |  9 +++++++++
 .../storage/upload/params/TemplateUploadParams.java      |  4 ++--
 .../cloud/storage/upload/params/UploadParamsBase.java    |  7 ++++++-
 .../main/java/com/cloud/template/TemplateAdapter.java    |  2 +-
 .../java/com/cloud/template/TemplateAdapterBase.java     | 16 +++++++++-------
 ui/src/views/image/RegisterOrUploadTemplate.vue          |  2 +-
 6 files changed, 28 insertions(+), 12 deletions(-)

diff --git 
a/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
 
b/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
index ab872b84edb..940b680fc6e 100644
--- 
a/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
+++ 
b/api/src/main/java/org/apache/cloudstack/api/command/user/template/GetUploadParamsForTemplateCmd.java
@@ -95,6 +95,11 @@ public class GetUploadParamsForTemplateCmd extends 
AbstractGetUploadParamsCmd {
             description = "(VMware only) true if VM deployments should 
preserve all the configurations defined for this template", since = "4.15.1")
     private 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;
+
     public String getDisplayText() {
         return StringUtils.isBlank(displayText) ? getName() : displayText;
     }
@@ -164,6 +169,10 @@ public class GetUploadParamsForTemplateCmd extends 
AbstractGetUploadParamsCmd {
                 Boolean.TRUE.equals(deployAsIs);
     }
 
+    public boolean isForCks() {
+        return Boolean.TRUE.equals(forCks);
+    }
+
     @Override
     public void execute() throws ServerApiException {
         validateRequest();
diff --git 
a/server/src/main/java/com/cloud/storage/upload/params/TemplateUploadParams.java
 
b/server/src/main/java/com/cloud/storage/upload/params/TemplateUploadParams.java
index 31206ca31b3..086038cf1c7 100644
--- 
a/server/src/main/java/com/cloud/storage/upload/params/TemplateUploadParams.java
+++ 
b/server/src/main/java/com/cloud/storage/upload/params/TemplateUploadParams.java
@@ -29,10 +29,10 @@ public class TemplateUploadParams extends UploadParamsBase {
                                 Long zoneId, Hypervisor.HypervisorType 
hypervisorType, String chksum,
                                 String templateTag, long templateOwnerId,
                                 Map details, Boolean sshkeyEnabled,
-                                Boolean isDynamicallyScalable, Boolean 
isRoutingType, boolean deployAsIs) {
+                                Boolean isDynamicallyScalable, Boolean 
isRoutingType, boolean deployAsIs, boolean forCks) {
         super(userId, name, displayText, bits, passwordEnabled, requiresHVM, 
isPublic, featured, isExtractable,
                 format, guestOSId, zoneId, hypervisorType, chksum, 
templateTag, templateOwnerId, details,
-                sshkeyEnabled, isDynamicallyScalable, isRoutingType, 
deployAsIs);
+                sshkeyEnabled, isDynamicallyScalable, isRoutingType, 
deployAsIs, forCks);
         setBootable(true);
     }
 }
diff --git 
a/server/src/main/java/com/cloud/storage/upload/params/UploadParamsBase.java 
b/server/src/main/java/com/cloud/storage/upload/params/UploadParamsBase.java
index 60ccc27a48f..11fec78d8e7 100644
--- a/server/src/main/java/com/cloud/storage/upload/params/UploadParamsBase.java
+++ b/server/src/main/java/com/cloud/storage/upload/params/UploadParamsBase.java
@@ -45,6 +45,7 @@ public abstract class UploadParamsBase implements 
UploadParams {
     private boolean isDynamicallyScalable;
     private boolean isRoutingType;
     private boolean deployAsIs;
+    private boolean forCks;
 
     UploadParamsBase(long userId, String name, String displayText,
                                Integer bits, boolean passwordEnabled, boolean 
requiresHVM,
@@ -53,7 +54,7 @@ public abstract class UploadParamsBase implements 
UploadParams {
                                Long zoneId, Hypervisor.HypervisorType 
hypervisorType, String checksum,
                                String templateTag, long templateOwnerId,
                                Map details, boolean sshkeyEnabled,
-                               boolean isDynamicallyScalable, boolean 
isRoutingType, boolean deployAsIs) {
+                               boolean isDynamicallyScalable, boolean 
isRoutingType, boolean deployAsIs, boolean forCks) {
         this.userId = userId;
         this.name = name;
         this.displayText = displayText;
@@ -229,6 +230,10 @@ public abstract class UploadParamsBase implements 
UploadParams {
         this.bootable = bootable;
     }
 
+    void setForCks(boolean forCks) {
+        this.forCks = forCks;
+    }
+
     void setBits(Integer bits) {
         this.bits = bits;
     }
diff --git a/server/src/main/java/com/cloud/template/TemplateAdapter.java 
b/server/src/main/java/com/cloud/template/TemplateAdapter.java
index 86dd0d3cad5..7962f552251 100644
--- a/server/src/main/java/com/cloud/template/TemplateAdapter.java
+++ b/server/src/main/java/com/cloud/template/TemplateAdapter.java
@@ -78,6 +78,6 @@ public interface TemplateAdapter extends Adapter {
 
     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, List<Long> zoneId, HypervisorType hypervisorType, 
String chksum, Boolean bootable, String templateTag, Account templateOwner, Map 
details, Boolean sshKeyEnabled, String imageStoreUuid, Boolean 
isDynamicallyScalable,
-                            TemplateType templateType, boolean directDownload, 
boolean deployAsIs) throws ResourceAllocationException;
+                            TemplateType templateType, boolean directDownload, 
boolean deployAsIs, boolean forCks) throws ResourceAllocationException;
 
 }
diff --git a/server/src/main/java/com/cloud/template/TemplateAdapterBase.java 
b/server/src/main/java/com/cloud/template/TemplateAdapterBase.java
index f3ce42a56c9..d9d89c6ed19 100644
--- a/server/src/main/java/com/cloud/template/TemplateAdapterBase.java
+++ b/server/src/main/java/com/cloud/template/TemplateAdapterBase.java
@@ -134,14 +134,14 @@ public abstract class TemplateAdapterBase extends 
AdapterBase implements Templat
         Boolean isPublic, Boolean featured, Boolean isExtractable, String 
format, Long guestOSId, List<Long> zoneId, HypervisorType hypervisorType, 
String accountName,
         Long domainId, String chksum, Boolean bootable, Map details, boolean 
directDownload, boolean deployAsIs) throws ResourceAllocationException {
         return prepare(isIso, userId, name, displayText, bits, 
passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, format, 
guestOSId, zoneId,
-            hypervisorType, chksum, bootable, null, null, details, false, 
null, false, TemplateType.USER, directDownload, deployAsIs);
+            hypervisorType, chksum, bootable, null, null, details, false, 
null, false, TemplateType.USER, directDownload, deployAsIs, false);
     }
 
     @Override
     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, List<Long> zoneIdList, HypervisorType hypervisorType, 
String chksum,
         Boolean bootable, String templateTag, Account templateOwner, Map 
details, Boolean sshkeyEnabled, String imageStoreUuid, Boolean 
isDynamicallyScalable,
-        TemplateType templateType, boolean directDownload, boolean deployAsIs) 
throws ResourceAllocationException {
+        TemplateType templateType, boolean directDownload, boolean deployAsIs, 
boolean forCks) throws ResourceAllocationException {
         //Long accountId = null;
         // parameters verification
 
@@ -262,9 +262,11 @@ public abstract class TemplateAdapterBase extends 
AdapterBase implements Templat
 
         Long id = _tmpltDao.getNextInSequence(Long.class, "id");
         CallContext.current().setEventDetails("Id: " + id + " name: " + name);
-        return new TemplateProfile(id, userId, name, displayText, bits, 
passwordEnabled, requiresHVM, url, isPublic, featured, isExtractable, imgfmt, 
guestOSId, zoneIdList,
+        TemplateProfile profile = new TemplateProfile(id, userId, name, 
displayText, bits, passwordEnabled, requiresHVM, url, isPublic, featured, 
isExtractable, imgfmt, guestOSId, zoneIdList,
             hypervisorType, templateOwner.getAccountName(), 
templateOwner.getDomainId(), templateOwner.getAccountId(), chksum, bootable, 
templateTag, details,
             sshkeyEnabled, null, isDynamicallyScalable, templateType, 
directDownload, deployAsIs);
+        profile.setForCks(forCks);
+        return profile;
 
     }
 
@@ -307,7 +309,7 @@ public abstract class TemplateAdapterBase extends 
AdapterBase implements Templat
         return prepare(false, CallContext.current().getCallingUserId(), 
cmd.getTemplateName(), cmd.getDisplayText(), cmd.getBits(), 
cmd.isPasswordEnabled(), cmd.getRequiresHvm(),
                 cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), 
cmd.isExtractable(), cmd.getFormat(), cmd.getOsTypeId(), zoneId, 
hypervisorType, cmd.getChecksum(), true,
                 cmd.getTemplateTag(), owner, details, cmd.isSshKeyEnabled(), 
null, cmd.isDynamicallyScalable(), templateType,
-                cmd.isDirectDownload(), cmd.isDeployAsIs());
+                cmd.isDirectDownload(), cmd.isDeployAsIs(), cmd.isForCks());
 
     }
 
@@ -338,7 +340,7 @@ public abstract class TemplateAdapterBase extends 
AdapterBase implements Templat
                 params.isExtractable(), params.getFormat(), 
params.getGuestOSId(), zoneList,
                 params.getHypervisorType(), params.getChecksum(), 
params.isBootable(), params.getTemplateTag(), owner,
                 params.getDetails(), params.isSshKeyEnabled(), 
params.getImageStoreUuid(),
-                params.isDynamicallyScalable(), params.isRoutingType() ? 
TemplateType.ROUTING : TemplateType.USER, params.isDirectDownload(), 
params.isDeployAsIs());
+                params.isDynamicallyScalable(), params.isRoutingType() ? 
TemplateType.ROUTING : TemplateType.USER, params.isDirectDownload(), 
params.isDeployAsIs(), false);
     }
 
     private Long getDefaultDeployAsIsGuestOsId() {
@@ -359,7 +361,7 @@ public abstract class TemplateAdapterBase extends 
AdapterBase implements Templat
                 BooleanUtils.toBoolean(cmd.isFeatured()), 
BooleanUtils.toBoolean(cmd.isExtractable()), cmd.getFormat(), osTypeId,
                 cmd.getZoneId(), HypervisorType.getType(cmd.getHypervisor()), 
cmd.getChecksum(),
                 cmd.getTemplateTag(), cmd.getEntityOwnerId(), 
cmd.getDetails(), BooleanUtils.toBoolean(cmd.isSshKeyEnabled()),
-                BooleanUtils.toBoolean(cmd.isDynamicallyScalable()), 
BooleanUtils.toBoolean(cmd.isRoutingType()), cmd.isDeployAsIs());
+                BooleanUtils.toBoolean(cmd.isDynamicallyScalable()), 
BooleanUtils.toBoolean(cmd.isRoutingType()), cmd.isDeployAsIs(), 
cmd.isForCks());
         return prepareUploadParamsInternal(params);
     }
 
@@ -390,7 +392,7 @@ public abstract class TemplateAdapterBase extends 
AdapterBase implements Templat
 
         return prepare(true, CallContext.current().getCallingUserId(), 
cmd.getIsoName(), cmd.getDisplayText(), 64, cmd.isPasswordEnabled(), true, 
cmd.getUrl(), cmd.isPublic(),
             cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), 
cmd.getOsTypeId(), zoneList, HypervisorType.None, cmd.getChecksum(), 
cmd.isBootable(), null,
-            owner, null, false, cmd.getImageStoreUuid(), 
cmd.isDynamicallyScalable(), TemplateType.USER, cmd.isDirectDownload(), false);
+            owner, null, false, cmd.getImageStoreUuid(), 
cmd.isDynamicallyScalable(), TemplateType.USER, cmd.isDirectDownload(), false, 
false);
     }
 
     protected VMTemplateVO persistTemplate(TemplateProfile profile, 
VirtualMachineTemplate.State initialState) {
diff --git a/ui/src/views/image/RegisterOrUploadTemplate.vue 
b/ui/src/views/image/RegisterOrUploadTemplate.vue
index ad24e2e47a0..a8abec76474 100644
--- a/ui/src/views/image/RegisterOrUploadTemplate.vue
+++ b/ui/src/views/image/RegisterOrUploadTemplate.vue
@@ -425,7 +425,7 @@
                     </a-checkbox>
                   </a-col>
                   <a-col :span="12">
-                    <a-checkbox value="forCks">
+                    <a-checkbox value="forCks" v-if="currentForm === 'Create'">
                       {{ $t('label.for.cks') }}
                     </a-checkbox>
                   </a-col>

Reply via email to