|
17 | 17 |
|
18 | 18 | <template> |
19 | 19 | <div> |
| 20 | + <a-card class="ant-form-text" style="text-align: justify; margin: 10px 0; padding: 15px;" v-html="$t('message.desc.register.template')" /> |
20 | 21 | <a-table |
21 | 22 | :columns="columns" |
22 | 23 | :dataSource="predefinedTemplates" |
@@ -70,6 +71,9 @@ export default { |
70 | 71 | created () { |
71 | 72 | this.initForm() |
72 | 73 | }, |
| 74 | + mounted () { |
| 75 | + this.fetchPredefinedTemplates() |
| 76 | + }, |
73 | 77 | computed: { |
74 | 78 | rowSelection () { |
75 | 79 | return { |
@@ -106,154 +110,7 @@ export default { |
106 | 110 | key: 'url' |
107 | 111 | } |
108 | 112 | ] |
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 | | - ] |
255 | 113 | this.defaultOsTypeId = await this.fetchOsTypeId('Other Linux (64-bit)') |
256 | | - this.prepareDownloadUrls() |
257 | 114 | }, |
258 | 115 | handleDone () { |
259 | 116 | this.$emit('refresh-data') |
@@ -359,10 +216,24 @@ export default { |
359 | 216 | } |
360 | 217 | return format |
361 | 218 | }, |
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 |
366 | 237 | } |
367 | 238 | } |
368 | 239 | } |
|
0 commit comments