diff --git a/@xen-orchestra/xva-generator/_toOvaXml.mjs b/@xen-orchestra/xva-generator/_toOvaXml.mjs index 98320fc406d..1262250ea90 100644 --- a/@xen-orchestra/xva-generator/_toOvaXml.mjs +++ b/@xen-orchestra/xva-generator/_toOvaXml.mjs @@ -4,9 +4,6 @@ function escape(string) { if (typeof string === 'number') { return string } - if (string.startsWith('')) { - return string - } const map = { '>': '>', '<': '<', @@ -21,12 +18,19 @@ function escape(string) { }) } +function formatDate(d) { + return d.toISOString().replaceAll('-', '').replace('.000Z', 'Z') +} + export default function toOvaxml(obj) { if (Array.isArray(obj)) { return `${obj.map(val => toOvaxml(val)).join('')}` } if (typeof obj === 'object') { + if (obj instanceof Date) { + return `${escape(formatDate(obj))}` + } return `${Object.entries(obj) .map(([key, value]) => `${escape(key)}${toOvaxml(value)}`) .join('')}` diff --git a/@xen-orchestra/xva-generator/templates/vm.mjs b/@xen-orchestra/xva-generator/templates/vm.mjs index d6fc429851f..b1e62e56d9c 100644 --- a/@xen-orchestra/xva-generator/templates/vm.mjs +++ b/@xen-orchestra/xva-generator/templates/vm.mjs @@ -1,9 +1,7 @@ - export const DEFAULT_VM = { class: 'VM', id: null, - snapshot: - { + snapshot: { actions_after_crash: 'restart', actions_after_reboot: 'restart', actions_after_shutdown: 'destroy', @@ -85,7 +83,7 @@ export const DEFAULT_VM = { snapshot_info: {}, snapshot_metadata: '', snapshot_of: 'OpaqueRef:NULL', - snapshot_time: '19700101T00:00:00Z', + snapshot_time: new Date(0), snapshots: [], start_delay: 0, // suspend_VDI:'OpaqueRef:NULL', @@ -104,5 +102,5 @@ export const DEFAULT_VM = { VTPMs: [], VUSBs: [], xenstore_data: {}, - } -} \ No newline at end of file + }, +}