mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
B OpenNebula/one#6418: Raw data in template form (#2887)
Signed-off-by: David Carracedo <dcarracedo@opennebula.io> Co-authored-by: Tino Vázquez <cvazquez@opennebula.io> (cherry picked from commit 974f52e71848535395460a27056b003770016426)
This commit is contained in:
parent
9b900b8d54
commit
f2380823dd
@ -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()
|
||||
|
@ -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,
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user