sushy-tools/sushy_tools/emulator/templates/ethernet_interfaces_collection.json
Ilya Etingof cc0bd13f42 Escape JSON rendered in templates
Dynamic Redfish emulator uses Jinja templates to render JSON
documents out of the values it gathers fromm the backend
hypervisor. Sometimes these hypervisor-supplied values can contain
literals that are special to JSON serialization. Unless escaped
properly, such conflicting literals will surely ruin the entire
JSON document.

This change elicits Jinja and Flask template filters that
circumvent this problem.

Change-Id: Ie3f2e1b68ab93a701adf666bdca9cf3d227c0c57
2018-11-29 18:14:16 +01:00

18 lines
682 B
JSON

{
"@odata.type": "#EthernetInterfaceCollection.EthernetInterfaceCollection",
"Name": "Ethernet Interface Collection",
"Description": "Virtual NICs",
"Members@odata.count": {{ nics|length }},
"Members": [
{% for nic in nics %}
{
"@odata.id": {{ "/redfish/v1/Systems/%s/EthernetInterfaces/%s"|format(identity, nic.id)|tojson }}
}{% if not loop.last %},{% endif %}
{% endfor %}
],
"Oem": {},
"@odata.context": "/redfish/v1/$metadata#EthernetInterfaceCollection.EthernetInterfaceCollection",
"@odata.id": {{ "/redfish/v1/Systems/%s/EthernetInterfaces"|format(identity)|tojson }}
}