From e7dc17fb176308f33d9543a374ddf6fbf0924550 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 20 Jul 2023 09:42:31 +0200 Subject: [PATCH] UI: fix userdataid or userdata content is passed when userdata append/override is unchecked --- ui/src/views/compute/DeployVM.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ui/src/views/compute/DeployVM.vue b/ui/src/views/compute/DeployVM.vue index b15fa8bcccf7..73d994a86449 100644 --- a/ui/src/views/compute/DeployVM.vue +++ b/ui/src/views/compute/DeployVM.vue @@ -1970,7 +1970,8 @@ export default { deployVmData.dynamicscalingenabled = values.dynamicscalingenabled deployVmData.iothreadsenabled = values.iothreadsenabled deployVmData.iodriverpolicy = values.iodriverpolicy - if (values.userdata && values.userdata.length > 0) { + const isUserdataAllowed = !this.userdataDefaultOverridePolicy || (this.userdataDefaultOverridePolicy === 'ALLOWOVERRIDE' && this.doUserdataOverride) || (this.userdataDefaultOverridePolicy === 'APPEND' && this.doUserdataAppend) + if (isUserdataAllowed && values.userdata && values.userdata.length > 0) { deployVmData.userdata = encodeURIComponent(btoa(sanitizeReverse(values.userdata))) } // step 2: select template/iso @@ -2093,7 +2094,9 @@ export default { } // step 7: select ssh key pair deployVmData.keypairs = this.sshKeyPairs.join(',') - deployVmData.userdataid = values.userdataid + if (isUserdataAllowed) { + deployVmData.userdataid = values.userdataid + } if (values.name) { deployVmData.name = values.name @@ -2129,7 +2132,7 @@ export default { idx++ } } - if (this.userDataValues) { + if (isUserdataAllowed && this.userDataValues) { for (const [key, value] of Object.entries(this.userDataValues)) { deployVmData['userdatadetails[' + idx + '].' + `${key}`] = value idx++