mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Hide UserData field from the EditVM view for VMs that do not offer it (#9731)
* added a v-if directive within the EditVm view to not show the field userdata if the vm's network does not offer the feature * added the parameter listall:true to the requests made to listNetworks and listVirtualMachines
This commit is contained in:
parent
00fe5f1471
commit
28f425a9f9
@ -84,7 +84,7 @@
|
||||
}"
|
||||
:options="groups.opts" />
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-form-item v-if="userDataEnabled">
|
||||
<template #label>
|
||||
<tooltip-label :title="$t('label.userdata')" :tooltip="apiParams.userdata.description"/>
|
||||
</template>
|
||||
@ -143,6 +143,7 @@ export default {
|
||||
return {
|
||||
serviceOffering: {},
|
||||
template: {},
|
||||
userDataEnabled: false,
|
||||
securityGroupsEnabled: false,
|
||||
dynamicScalingVmConfig: false,
|
||||
loading: false,
|
||||
@ -289,15 +290,37 @@ export default {
|
||||
return decodedData.toString('utf-8')
|
||||
},
|
||||
fetchUserData () {
|
||||
const params = {
|
||||
id: this.resource.id,
|
||||
userdata: true
|
||||
let networkId
|
||||
this.resource.nic.forEach(nic => {
|
||||
if (nic.isdefault) {
|
||||
networkId = nic.networkid
|
||||
}
|
||||
})
|
||||
if (!networkId) {
|
||||
return
|
||||
}
|
||||
const listNetworkParams = {
|
||||
id: networkId,
|
||||
listall: true
|
||||
}
|
||||
api(`listNetworks`, listNetworkParams).then(json => {
|
||||
json.listnetworksresponse.network[0].service.forEach(service => {
|
||||
if (service.name === 'UserData') {
|
||||
this.userDataEnabled = true
|
||||
|
||||
api('listVirtualMachines', params).then(json => {
|
||||
this.form.userdata = this.decodeUserData(json.listvirtualmachinesresponse.virtualmachine[0].userdata || '')
|
||||
const listVmParams = {
|
||||
id: this.resource.id,
|
||||
userdata: true,
|
||||
listall: true
|
||||
}
|
||||
api('listVirtualMachines', listVmParams).then(json => {
|
||||
this.form.userdata = atob(json.listvirtualmachinesresponse.virtualmachine[0].userdata || '')
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
handleSubmit () {
|
||||
this.formRef.value.validate().then(() => {
|
||||
const values = toRaw(this.form)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user