diff --git a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/booting/rawSchema.js b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/booting/rawSchema.js index 0a5d8bb345..5d7dfb8034 100644 --- a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/booting/rawSchema.js +++ b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/ExtraConfiguration/booting/rawSchema.js @@ -27,6 +27,7 @@ const TYPE = { label: T.Type, type: INPUT_TYPES.TEXT, notOnHypervisors: [lxc, vcenter, firecracker], + htmlType: INPUT_TYPES.HIDDEN, validation: string() .trim() .notRequired() diff --git a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/index.js b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/index.js index 9375aeb340..d898f31c05 100644 --- a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/index.js +++ b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/index.js @@ -26,7 +26,11 @@ import General, { } from 'client/components/Forms/VmTemplate/CreateForm/Steps/General' import { MEMORY_RESIZE_OPTIONS, T } from 'client/constants' -import { jsonToXml, userInputsToArray } from 'client/models/Helper' +import { + jsonToXml, + userInputsToArray, + transformXmlString, +} from 'client/models/Helper' import { convertToMB, createSteps, @@ -155,6 +159,10 @@ const Steps = createSteps([General, ExtraConfiguration, CustomVariables], { extraTemplate?.[nicKey]?.forEach((NIC) => delete NIC?.NAME) ) + // ISSUE #6418: Raw data is in XML format, so it needs to be transform before sennding it to the API (otherwise the value of RAW.DATA will be treat as part of the XML template) + extraTemplate?.RAW?.DATA && + (extraTemplate.RAW.DATA = transformXmlString(extraTemplate.RAW.DATA)) + return jsonToXml({ ...customVariables, ...extraTemplate, diff --git a/src/fireedge/src/client/constants/translates.js b/src/fireedge/src/client/constants/translates.js index edb870eb55..1b9a7ffadb 100644 --- a/src/fireedge/src/client/constants/translates.js +++ b/src/fireedge/src/client/constants/translates.js @@ -1022,10 +1022,10 @@ module.exports = { Disk thread id can be forced by disk IOTHREAD attribute`, Raw: 'Raw', RawData: 'Raw data', - RawDataConcept: 'Raw data to be passed directly to the hypervisor', + RawDataConcept: + 'Raw data is used to pass VM information directly to the underlying hypervisor. Anything placed in the data attribute gets passed straight to the hypervisor. Do not add escape characters.', RawValidateConcept: ` - Disable validation of the RAW data. - By default, the data will be checked against the libvirt schema`, + Enable or disable validation of the RAW data against the libvirt schema`, /* VM Template schema - context */ Context: 'Context', SshPublicKey: 'SSH public key', diff --git a/src/fireedge/src/client/models/Helper.js b/src/fireedge/src/client/models/Helper.js index 4732505483..33cb6a5bbd 100644 --- a/src/fireedge/src/client/models/Helper.js +++ b/src/fireedge/src/client/models/Helper.js @@ -597,3 +597,21 @@ export const getErrorMessage = (resource) => { return [ERROR, SCHED_MESSAGE, templateError].filter(Boolean)[0] } + +/** + * Replace < for < and > for >. + * + * @param {string} xmlString - The string with xml value + * @returns {string} - A string with the same value but with the replace characters + */ +export const transformXmlString = (xmlString) => + xmlString.replace(/[<>"']/g, function (c) { + switch (c) { + case '<': + return '<' + case '>': + return '>' + default: + return c + } + })