Skip to content

Commit 8756be5

Browse files
nvazquezshwstpprsureshanapartivishesh92
authored
[Multi-Arch] Select Template Arch when creating template from volume (#11068)
Co-authored-by: Abhishek Kumar <[email protected]> Co-authored-by: Suresh Kumar Anaparti <[email protected]> Co-authored-by: Vishesh <[email protected]>
1 parent 82396b6 commit 8756be5

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

api/src/main/java/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23+
import com.cloud.cpu.CPU;
2324
import org.apache.cloudstack.acl.SecurityChecker;
2425
import org.apache.cloudstack.api.APICommand;
2526
import org.apache.cloudstack.api.ApiCommandResourceType;
@@ -148,6 +149,11 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd implements UserCmd {
148149
since = "4.19.0")
149150
private String accountName;
150151

152+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
153+
description = "the CPU arch of the template. Valid options are: x86_64, aarch64. Defaults to x86_64",
154+
since = "4.20.2")
155+
private String arch;
156+
151157
// ///////////////////////////////////////////////////
152158
// ///////////////// Accessors ///////////////////////
153159
// ///////////////////////////////////////////////////
@@ -234,6 +240,10 @@ public String getAccountName() {
234240
return accountName;
235241
}
236242

243+
public CPU.CPUArch getArch() {
244+
return CPU.CPUArch.fromType(arch);
245+
}
246+
237247
// ///////////////////////////////////////////////////
238248
// ///////////// API Implementation///////////////////
239249
// ///////////////////////////////////////////////////

server/src/main/java/com/cloud/template/TemplateManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,7 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
18311831
throw new InvalidParameterValueException("Failed to create private template record, please specify only one of volume ID (" + volumeId +
18321832
") and snapshot ID (" + snapshotId + ")");
18331833
}
1834+
CPU.CPUArch arch = cmd.getArch();
18341835

18351836
HypervisorType hyperType;
18361837
VolumeVO volume = null;
@@ -1923,7 +1924,6 @@ public VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd, Account t
19231924
String description = cmd.getDisplayText();
19241925
boolean isExtractable = false;
19251926
Long sourceTemplateId = null;
1926-
CPU.CPUArch arch = CPU.CPUArch.amd64;
19271927
if (volume != null) {
19281928
VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId());
19291929
isExtractable = template != null && template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM;

ui/src/views/storage/CreateTemplate.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@
129129
</a-select-option>
130130
</a-select>
131131
</a-form-item>
132+
<a-form-item
133+
name="arch"
134+
ref="arch">
135+
<template #label>
136+
<tooltip-label :title="$t('label.arch')" :tooltip="apiParams.arch.description"/>
137+
</template>
138+
<a-select
139+
showSearch
140+
optionFilterProp="label"
141+
:filterOption="(input, option) => {
142+
return option.children[0].children.toLowerCase().indexOf(input.toLowerCase()) >= 0
143+
}"
144+
v-model:value="form.arch"
145+
:placeholder="apiParams.arch.description">
146+
<a-select-option v-for="opt in architectureTypes.opts" :key="opt.id">
147+
{{ opt.name || opt.description }}
148+
</a-select-option>
149+
</a-select>
150+
</a-form-item>
132151
<a-row :gutter="12">
133152
<a-col :md="24" :lg="12">
134153
<a-form-item ref="isdynamicallyscalable" name="isdynamicallyscalable">
@@ -163,7 +182,7 @@
163182
<tooltip-label :title="$t('label.isfeatured')" :tooltip="apiParams.isfeatured.description"/>
164183
</template>
165184
<a-switch v-model:checked="form.isfeatured" />
166-
</a-form-item>
185+
</a-form-item>
167186
</a-col>
168187
</a-row>
169188
<div :span="24" class="action-button">
@@ -204,7 +223,8 @@ export default {
204223
accounts: [],
205224
domainLoading: false,
206225
domainid: null,
207-
account: null
226+
account: null,
227+
architectureTypes: {}
208228
}
209229
},
210230
computed: {
@@ -239,6 +259,7 @@ export default {
239259
if ('listDomains' in this.$store.getters.apis) {
240260
this.fetchDomains()
241261
}
262+
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
242263
},
243264
fetchOsTypes () {
244265
this.osTypes.opts = []

0 commit comments

Comments
 (0)