Comment 1 for bug 1670768

Revision history for this message
Mark Goddard (mgoddard) wrote : Re: Introspection rule actions cannot use formatting for non-string values

Workaround:

For those needing this capability in released versions of inspector, a workaround that works in the case described above is to use two actions as follows:

{
    "actions": [
        {
            "action": "set-attribute",
            "path": "properties/root_device",
            "value": {}
        },
        {
            "action": "set-attribute",
            "path": "properties/root_device/serial",
            "value": "{data[root_device][serial]}"
        }
    ],
    "conditions": [
        {
            "field": "node://properties.root_device",
            "op": "is-empty"
        }
    ]
}

Here we first initialise the properties/root_device value to an empty dict, which allows us to specify the serial item within this dict.