[RFE] Introspection rule actions value formatting for complex values
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ironic Inspector |
Confirmed
|
Wishlist
|
Will Miller |
Bug Description
Introspection rule actions cannot use formatting for non-string values. Sometimes we need to set a complex non-string value on a node via inspection rules. We may also want this non-string value to contain a reference to the introspection data.
Steps to reproduce
Here we use the example of setting a root device hint for the serial of the disk determined by inspection to be the root device. The properties.
$ cat > rule << EOF
{
"actions": [
{
"path": "properties/
}
}
],
"conditions": [
{
"op": "is-empty"
}
]
}
$ openstack baremetal introspection rule import rule
+------
| UUID | Description |
+------
| 8e20fa94-
+------
$ openstack baremetal introspection rule show 8e20fa94-
+------
| Field | Value |
+------
| actions | [{u'action': u'set-attribute', u'path': u'properties/
| conditions | [{u'field': u'node:
| description | None |
| uuid | 8e20fa94-
+------
Now start introspection on a node, for example:
$ ironic node-set-
Expected result:
The ironic node gets updated with properties/
Actual result:
The ironic node gets updated with properties/
Proposed solution:
For any action parameters marked as FORMATTED_PARAMS, inspector currently formats them if they are of type string. Inspector should also recursively check all non-string objects (dicts, lists) and format all strings contained nested within them.
summary: |
- Introspection rule actions cannot use formatting for non-string values + [RFE] Introspection rule actions value formatting for complex values |
Changed in ironic-inspector: | |
status: | New → Confirmed |
importance: | Undecided → Wishlist |
tags: | added: rfe |
Changed in ironic-inspector: | |
assignee: | nobody → Will Miller (w-miller) |
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:
{
"action" : "set-attribute", root_device" ,
"value" : {}
"action" : "set-attribute", root_device/ serial" ,
"value" : "{data[ root_device] [serial] }"
"field" : "node:/ /properties. root_device" ,
"actions": [
{
"path": "properties/
},
{
"path": "properties/
}
],
"conditions": [
{
"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.