Skip to content

Commit

Permalink
B #6751: Fix raw data validation handling (#3269)
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Hansson <[email protected]>
Co-authored-by: Tino Vázquez <[email protected]>
  • Loading branch information
vichansson and tinova authored Oct 21, 2024
1 parent f698097 commit 5333608
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/fireedge/src/client/containers/VmTemplates/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ function CreateVmTemplate() {
history.push(PATH.TEMPLATE.VMS.LIST)
enqueueSuccess(T.SuccessVMTemplateUpdated, [templateId, NAME])
}
} catch {}
} catch (error) {
isDevelopment() && console.log('VM Template error: ', error)
}
}

return templateId &&
Expand Down
17 changes: 10 additions & 7 deletions src/fireedge/src/client/utils/parser/vmTemplateFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,15 +767,18 @@ const transformActionsCommon = (template) => {
})
}

// If template has RAW attribute
if (template.RAW) {
// // Add type (hypervisor) on RAW data if exists data, if not, delete RAW section.
if (template.RAW?.DATA) template.RAW.TYPE = template.HYPERVISOR
else delete template.RAW
// Clone template.RAW to ensure its mutable
template.RAW = { ...template.RAW }

// 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)
template?.RAW?.DATA &&
(template.RAW.DATA = transformXmlString(template.RAW.DATA))
if (template.RAW.DATA) {
// DATA exists, so we add TYPE and transform DATA
template.RAW.TYPE = template.HYPERVISOR
template.RAW.DATA = transformXmlString(template.RAW.DATA)
} else {
// DATA doesn't exist, remove RAW from template
delete template.RAW
}
}
}

Expand Down

0 comments on commit 5333608

Please sign in to comment.