From 07be7ddf3c3bc630ba1ebb6718df2b01095ea9bf Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Sat, 21 Jun 2025 14:21:46 -0300 Subject: [PATCH 1/3] [Multi-Arch] Select Template Arch when creating template from volume --- .../user/template/CreateTemplateCmd.java | 10 ++++++++ .../cloud/template/TemplateManagerImpl.java | 2 +- ui/src/views/storage/CreateTemplate.vue | 25 +++++++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) 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 0a7bf2918435..c5ba51b4a1eb 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 @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; +import com.cloud.cpu.CPU; import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandResourceType; @@ -148,6 +149,11 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd implements UserCmd { since = "4.19.0") private String accountName; + @Parameter(name = ApiConstants.ARCH, type = CommandType.STRING, + description = "the CPU arch of the template. Valid options are: x86_64, aarch64", + since = "4.20.1") + private String arch; + // /////////////////////////////////////////////////// // ///////////////// Accessors /////////////////////// // /////////////////////////////////////////////////// @@ -234,6 +240,10 @@ public String getAccountName() { return accountName; } + public CPU.CPUArch getArch() { + return CPU.CPUArch.fromType(arch); + } + // /////////////////////////////////////////////////// // ///////////// API Implementation/////////////////// // /////////////////////////////////////////////////// diff --git a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java index 9f23bdef142d..cf88ccec919c 100755 --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java @@ -1831,6 +1831,7 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t throw new InvalidParameterValueException("Failed to create private template record, please specify only one of volume ID (" + volumeId + ") and snapshot ID (" + snapshotId + ")"); } + CPU.CPUArch arch = cmd.getArch(); HypervisorType hyperType; VolumeVO volume = null; @@ -1923,7 +1924,6 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t String description = cmd.getDisplayText(); boolean isExtractable = false; Long sourceTemplateId = null; - CPU.CPUArch arch = CPU.CPUArch.amd64; if (volume != null) { VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId()); isExtractable = template != null && template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM; diff --git a/ui/src/views/storage/CreateTemplate.vue b/ui/src/views/storage/CreateTemplate.vue index 65941d39a9d9..d974092a5f8c 100644 --- a/ui/src/views/storage/CreateTemplate.vue +++ b/ui/src/views/storage/CreateTemplate.vue @@ -129,6 +129,25 @@ + + + + + {{ opt.name || opt.description }} + + + @@ -163,7 +182,7 @@ - +
@@ -204,7 +223,8 @@ export default { accounts: [], domainLoading: false, domainid: null, - account: null + account: null, + architectureTypes: {} } }, computed: { @@ -239,6 +259,7 @@ export default { if ('listDomains' in this.$store.getters.apis) { this.fetchDomains() } + this.architectureTypes.opts = this.$fetchCpuArchitectureTypes() }, fetchOsTypes () { this.osTypes.opts = [] From 340e9532b74222d0d256b7d6aa5c419602386464 Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Sun, 22 Jun 2025 14:39:59 -0300 Subject: [PATCH 2/3] Update api/src/main/java/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java Co-authored-by: Abhishek Kumar --- .../cloudstack/api/command/user/template/CreateTemplateCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 c5ba51b4a1eb..494614a6bb95 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 @@ -151,7 +151,7 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd implements UserCmd { @Parameter(name = ApiConstants.ARCH, type = CommandType.STRING, description = "the CPU arch of the template. Valid options are: x86_64, aarch64", - since = "4.20.1") + since = "4.20.2") private String arch; // /////////////////////////////////////////////////// From 017296a1bec8dd7543d932730cb243b56d711243 Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez Date: Mon, 28 Jul 2025 07:38:10 -0300 Subject: [PATCH 3/3] Update api/src/main/java/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java Co-authored-by: Vishesh --- .../cloudstack/api/command/user/template/CreateTemplateCmd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 494614a6bb95..5f09ac6698d6 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 @@ -150,7 +150,7 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd implements UserCmd { private String accountName; @Parameter(name = ApiConstants.ARCH, type = CommandType.STRING, - description = "the CPU arch of the template. Valid options are: x86_64, aarch64", + description = "the CPU arch of the template. Valid options are: x86_64, aarch64. Defaults to x86_64", since = "4.20.2") private String arch;