Skip to content

Commit 64b0cc0

Browse files
committed
move template metadata to json file instead of hardcoding
1 parent 2d3290b commit 64b0cc0

File tree

3 files changed

+169
-151
lines changed

3 files changed

+169
-151
lines changed
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
[
2+
{
3+
"id": 1,
4+
"name": "Ubuntu 24.04",
5+
"version": "24.04",
6+
"distro": "Ubuntu",
7+
"arch": "x86_64",
8+
"filename": "ubuntu-24.04-server-cloudimg-amd64.img"
9+
},
10+
{
11+
"id": 2,
12+
"name": "Ubuntu 22.04",
13+
"version": "22.04",
14+
"distro": "Ubuntu",
15+
"arch": "x86_64",
16+
"filename": "ubuntu-22.04-server-cloudimg-amd64.img"
17+
},
18+
{
19+
"id": 3,
20+
"name": "Ubuntu 20.04",
21+
"version": "20.04",
22+
"distro": "Ubuntu",
23+
"arch": "x86_64",
24+
"filename": "ubuntu-20.04-server-cloudimg-amd64.img"
25+
},
26+
{
27+
"id": 4,
28+
"name": "Debian GNU/Linux 12 (64-bit)",
29+
"version": "12",
30+
"distro": "Debian",
31+
"arch": "x86_64",
32+
"filename": "debian-12-genericcloud-amd64.qcow2"
33+
},
34+
{
35+
"id": 5,
36+
"name": "Rocky Linux 8",
37+
"version": "8",
38+
"distro": "Rockylinux",
39+
"arch": "x86_64",
40+
"filename": "Rocky-8-GenericCloud.latest.x86_64.qcow2"
41+
},
42+
{
43+
"id": 6,
44+
"name": "Rocky Linux 9",
45+
"version": "9",
46+
"distro": "Rockylinux",
47+
"arch": "x86_64",
48+
"filename": "Rocky-9-GenericCloud.latest.x86_64.qcow2"
49+
},
50+
{
51+
"id": 7,
52+
"name": "OpenSUSE 15.5",
53+
"version": "15.5",
54+
"distro": "OpenSUSE",
55+
"arch": "x86_64",
56+
"filename": "openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2"
57+
},
58+
{
59+
"id": 8,
60+
"name": "Ubuntu 24.04",
61+
"version": "24.04",
62+
"distro": "Ubuntu",
63+
"arch": "aarch64",
64+
"filename": "ubuntu-24.04-server-cloudimg-arm64.img"
65+
},
66+
{
67+
"id": 9,
68+
"name": "Ubuntu 22.04",
69+
"version": "22.04",
70+
"distro": "Ubuntu",
71+
"arch": "aarch64",
72+
"filename": "ubuntu-22.04-server-cloudimg-arm64.img"
73+
},
74+
{
75+
"id": 10,
76+
"name": "Ubuntu 20.04",
77+
"version": "20.04",
78+
"distro": "Ubuntu",
79+
"arch": "aarch64",
80+
"filename": "ubuntu-20.04-server-cloudimg-arm64.img"
81+
},
82+
{
83+
"id": 11,
84+
"name": "Debian GNU/Linux 12 (64-bit)",
85+
"version": "12",
86+
"distro": "Debian",
87+
"arch": "aarch64",
88+
"filename": "debian-12-genericcloud-arm64.qcow2"
89+
},
90+
{
91+
"id": 12,
92+
"name": "Rocky Linux 8",
93+
"version": "8",
94+
"distro": "Rockylinux",
95+
"arch": "aarch64",
96+
"filename": "Rocky-8-GenericCloud.latest.aarch64.qcow2"
97+
},
98+
{
99+
"id": 13,
100+
"name": "Rocky Linux 9",
101+
"version": "9",
102+
"distro": "Rockylinux",
103+
"arch": "aarch64",
104+
"filename": "Rocky-9-GenericCloud.latest.aarch64.qcow2"
105+
},
106+
{
107+
"id": 14,
108+
"name": "OpenSUSE 15.5",
109+
"version": "15.5",
110+
"distro": "OpenSUSE",
111+
"arch": "aarch64",
112+
"filename": "openSUSE-Leap-15.5-Minimal-VM.aarch64-Cloud.qcow2"
113+
},
114+
{
115+
"id": 15,
116+
"name": "Oracle Linux 8",
117+
"version": "8.10",
118+
"distro": "OracleLinux",
119+
"arch": "aarch64",
120+
"filename": "OL8U10_aarch64-kvm-b122.qcow2"
121+
},
122+
{
123+
"id": 16,
124+
"name": "Oracle Linux 8",
125+
"version": "8.10",
126+
"distro": "OracleLinux",
127+
"arch": "x86_64",
128+
"filename": "OL8U10_x86_64-kvm-b258.qcow2"
129+
},
130+
{
131+
"id": 17,
132+
"name": "Oracle Linux 9",
133+
"version": "9.5",
134+
"distro": "OracleLinux",
135+
"arch": "aarch64",
136+
"filename": "OL9U5_aarch64-kvm-b126.qcow2"
137+
},
138+
{
139+
"id": 18,
140+
"name": "Oracle Linux 9",
141+
"version": "9.5",
142+
"distro": "OracleLinux",
143+
"arch": "x86_64",
144+
"filename": "OL9U5_x86_64-kvm-b259.qcow2"
145+
}
146+
]

ui/public/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,6 +3057,7 @@
30573057
"message.desc.importexportinstancewizard": "By choosing to manage an Instance, CloudStack takes over the orchestration of that Instance. Unmanaging an Instance removes CloudStack ability to manage it. In both cases, the Instance is left running and no changes are done to the VM on the hypervisor.<br><br>For KVM, managing a VM is an experimental feature.",
30583058
"message.desc.importmigratefromvmwarewizard": "By selecting an existing or external VMware Datacenter and an instance to import, CloudStack migrates the selected instance from VMware to KVM on a conversion host using virt-v2v and imports it into a KVM cluster",
30593059
"message.desc.primary.storage": "Each cluster must contain one or more primary storage servers. We will add the first one now. Primary storage contains the disk volumes for all the Instances running on hosts in the cluster. Use any standards-compliant protocol that is supported by the underlying hypervisor.",
3060+
"message.desc.register.template": "Hosted on download.cloudstack.org, these templates can be easily registered directly within CloudStack. Simply click <strong>Register Template</strong> for the templates you wish to use.",
30603061
"message.desc.reset.ssh.key.pair": "Please specify a ssh key pair that you would like to add to this Instance.",
30613062
"message.desc.secondary.storage": "Each zone must have at least one NFS or secondary storage server. We will add the first one now. Secondary storage stores Instance Templates, ISO images, and Instance disk volume Snapshots. This server must be available to all hosts in the zone.<br/><br/>Provide the IP address and exported path.",
30623063
"message.desc.register.user.data": "Please fill in the following data to register a User data.",

ui/src/views/infra/zone/ZoneWizardRegisterTemplate.vue

Lines changed: 22 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<template>
1919
<div>
20+
<a-card class="ant-form-text" style="text-align: justify; margin: 10px 0; padding: 15px;" v-html="$t('message.desc.register.template')" />
2021
<a-table
2122
:columns="columns"
2223
:dataSource="predefinedTemplates"
@@ -70,6 +71,9 @@ export default {
7071
created () {
7172
this.initForm()
7273
},
74+
mounted () {
75+
this.fetchPredefinedTemplates()
76+
},
7377
computed: {
7478
rowSelection () {
7579
return {
@@ -106,154 +110,7 @@ export default {
106110
key: 'url'
107111
}
108112
]
109-
this.predefinedTemplates = [
110-
{
111-
id: 1,
112-
name: 'Ubuntu 24.04',
113-
version: '24.04',
114-
distroName: 'Ubuntu',
115-
arch: 'x86_64',
116-
filename: 'ubuntu-24.04-server-cloudimg-amd64.img'
117-
},
118-
{
119-
id: 2,
120-
name: 'Ubuntu 22.04',
121-
version: '22.04',
122-
distroName: 'Ubuntu',
123-
arch: 'x86_64',
124-
filename: 'ubuntu-22.04-server-cloudimg-amd64.img'
125-
},
126-
{
127-
id: 3,
128-
name: 'Ubuntu 20.04',
129-
version: '20.04',
130-
distroName: 'Ubuntu',
131-
arch: 'x86_64',
132-
filename: 'ubuntu-20.04-server-cloudimg-amd64.img'
133-
},
134-
{
135-
id: 4,
136-
name: 'Debian GNU/Linux 12 (64-bit)',
137-
version: '12',
138-
distroName: 'Debian',
139-
arch: 'x86_64',
140-
filename: 'debian-12-genericcloud-amd64.qcow2'
141-
},
142-
{
143-
id: 5,
144-
name: 'Rocky Linux 8',
145-
version: '8',
146-
distroName: 'Rockylinux',
147-
arch: 'x86_64',
148-
filename: 'Rocky-8-GenericCloud.latest.x86_64.qcow2'
149-
},
150-
{
151-
id: 6,
152-
name: 'Rocky Linux 9',
153-
version: '9',
154-
distroName: 'Rockylinux',
155-
arch: 'x86_64',
156-
filename: 'Rocky-9-GenericCloud.latest.x86_64.qcow2'
157-
},
158-
{
159-
id: 7,
160-
name: 'OpenSUSE 15.5',
161-
version: '15.5',
162-
distroName: 'OpenSUSE',
163-
arch: 'x86_64',
164-
filename: 'openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2'
165-
},
166-
{
167-
id: 8,
168-
name: 'Ubuntu 24.04',
169-
version: '24.04',
170-
distroName: 'Ubuntu',
171-
arch: 'aarch64',
172-
filename: 'ubuntu-24.04-server-cloudimg-arm64.img'
173-
},
174-
{
175-
id: 9,
176-
name: 'Ubuntu 22.04',
177-
version: '22.04',
178-
distroName: 'Ubuntu',
179-
arch: 'aarch64',
180-
filename: 'ubuntu-22.04-server-cloudimg-arm64.img'
181-
},
182-
{
183-
id: 10,
184-
name: 'Ubuntu 20.04',
185-
version: '20.04',
186-
distroName: 'Ubuntu',
187-
arch: 'aarch64',
188-
filename: 'ubuntu-20.04-server-cloudimg-arm64.img'
189-
},
190-
{
191-
id: 11,
192-
name: 'Debian GNU/Linux 12 (64-bit)',
193-
version: '12',
194-
distroName: 'Debian',
195-
arch: 'aarch64',
196-
filename: 'debian-12-genericcloud-arm64.qcow2'
197-
},
198-
{
199-
id: 12,
200-
name: 'Rocky Linux 8',
201-
version: '8',
202-
distroName: 'Rockylinux',
203-
arch: 'aarch64',
204-
filename: 'Rocky-8-GenericCloud.latest.aarch64.qcow2'
205-
},
206-
{
207-
id: 13,
208-
name: 'Rocky Linux 9',
209-
version: '9',
210-
distroName: 'Rockylinux',
211-
arch: 'aarch64',
212-
filename: 'Rocky-9-GenericCloud.latest.aarch64.qcow2'
213-
},
214-
{
215-
id: 14,
216-
name: 'OpenSUSE 15.5',
217-
version: '15.5',
218-
distroName: 'OpenSUSE',
219-
arch: 'aarch64',
220-
filename: 'openSUSE-Leap-15.5-Minimal-VM.aarch64-Cloud.qcow2'
221-
},
222-
{
223-
id: 15,
224-
name: 'Oracle Linux 8',
225-
version: '8.10',
226-
distroName: 'OracleLinux',
227-
arch: 'aarch64',
228-
filename: 'OL8U10_aarch64-kvm-b122.qcow2'
229-
},
230-
{
231-
id: 16,
232-
name: 'Oracle Linux 8',
233-
version: '8.10',
234-
distroName: 'OracleLinux',
235-
arch: 'x86_64',
236-
filename: 'OL8U10_x86_64-kvm-b258.qcow2'
237-
},
238-
{
239-
id: 17,
240-
name: 'Oracle Linux 9',
241-
version: '9.5',
242-
distroName: 'OracleLinux',
243-
arch: 'aarch64',
244-
filename: 'OL9U5_aarch64-kvm-b126.qcow2'
245-
},
246-
{
247-
id: 18,
248-
name: 'Oracle Linux 9',
249-
version: '9.5',
250-
distroName: 'OracleLinux',
251-
arch: 'x86_64',
252-
filename: 'OL9U5_x86_64-kvm-b259.qcow2'
253-
}
254-
]
255113
this.defaultOsTypeId = await this.fetchOsTypeId('Other Linux (64-bit)')
256-
this.prepareDownloadUrls()
257114
},
258115
handleDone () {
259116
this.$emit('refresh-data')
@@ -359,10 +216,24 @@ export default {
359216
}
360217
return format
361218
},
362-
prepareDownloadUrls () {
363-
const templatesBaseUrl = 'https://download.cloudstack.org/templates/cloud-images/'
364-
for (const template of this.predefinedTemplates) {
365-
template.url = templatesBaseUrl + template.distroName.toLowerCase() + '/' + template.filename
219+
async fetchPredefinedTemplates () {
220+
this.loading = true
221+
try {
222+
const response = await fetch('./cloud-image-templates.json')
223+
if (!response.ok) {
224+
throw new Error(`Error fetching predefined templates, status_code: ${response.status}`)
225+
}
226+
const templates = await response.json()
227+
const templatesBaseUrl = 'https://download.cloudstack.org/templates/cloud-images/'
228+
for (const template of templates) {
229+
template.url = templatesBaseUrl + template.distro.toLowerCase() + '/' + template.filename
230+
}
231+
this.predefinedTemplates = templates
232+
} catch (error) {
233+
console.error('Error fetching predefined templates:', error)
234+
this.predefinedTemplates = []
235+
} finally {
236+
this.loading = false
366237
}
367238
}
368239
}

0 commit comments

Comments
 (0)