|
84 | 84 | }" |
85 | 85 | :options="groups.opts" /> |
86 | 86 | </a-form-item> |
87 | | - <a-form-item> |
| 87 | + <a-form-item v-if="userDataEnabled"> |
88 | 88 | <template #label> |
89 | 89 | <tooltip-label :title="$t('label.userdata')" :tooltip="apiParams.userdata.description"/> |
90 | 90 | </template> |
@@ -143,6 +143,7 @@ export default { |
143 | 143 | return { |
144 | 144 | serviceOffering: {}, |
145 | 145 | template: {}, |
| 146 | + userDataEnabled: false, |
146 | 147 | securityGroupsEnabled: false, |
147 | 148 | dynamicScalingVmConfig: false, |
148 | 149 | loading: false, |
@@ -289,15 +290,37 @@ export default { |
289 | 290 | return decodedData.toString('utf-8') |
290 | 291 | }, |
291 | 292 | fetchUserData () { |
292 | | - const params = { |
293 | | - id: this.resource.id, |
294 | | - userdata: true |
| 293 | + let networkId |
| 294 | + this.resource.nic.forEach(nic => { |
| 295 | + if (nic.isdefault) { |
| 296 | + networkId = nic.networkid |
| 297 | + } |
| 298 | + }) |
| 299 | + if (!networkId) { |
| 300 | + return |
| 301 | + } |
| 302 | + const listNetworkParams = { |
| 303 | + id: networkId, |
| 304 | + listall: true |
295 | 305 | } |
| 306 | + api(`listNetworks`, listNetworkParams).then(json => { |
| 307 | + json.listnetworksresponse.network[0].service.forEach(service => { |
| 308 | + if (service.name === 'UserData') { |
| 309 | + this.userDataEnabled = true |
296 | 310 |
|
297 | | - api('listVirtualMachines', params).then(json => { |
298 | | - this.form.userdata = this.decodeUserData(json.listvirtualmachinesresponse.virtualmachine[0].userdata || '') |
| 311 | + const listVmParams = { |
| 312 | + id: this.resource.id, |
| 313 | + userdata: true, |
| 314 | + listall: true |
| 315 | + } |
| 316 | + api('listVirtualMachines', listVmParams).then(json => { |
| 317 | + this.form.userdata = atob(json.listvirtualmachinesresponse.virtualmachine[0].userdata || '') |
| 318 | + }) |
| 319 | + } |
| 320 | + }) |
299 | 321 | }) |
300 | 322 | }, |
| 323 | +
|
301 | 324 | handleSubmit () { |
302 | 325 | this.formRef.value.validate().then(() => { |
303 | 326 | const values = toRaw(this.form) |
|
0 commit comments