Merge "Ensure rules documentation examples are valid JSON"

This commit is contained in:
Jenkins 2016-05-11 11:41:59 +00:00 committed by Gerrit Code Review
commit 1061b124cb
1 changed files with 39 additions and 35 deletions

View File

@ -79,8 +79,8 @@ Starting with the Mitaka release, you can also apply conditions to ironic node
field. Prefix field with schema (``data://`` or ``node://``) to distinguish field. Prefix field with schema (``data://`` or ``node://``) to distinguish
between values from introspection data and node. Both schemes use JSON path:: between values from introspection data and node. Both schemes use JSON path::
{'field': 'node://property.path', 'op': 'eq', 'value': 'val'} {"field": "node://property.path", "op": "eq", "value": "val"}
{'field': 'data://introspection.path', 'op': 'eq', 'value': 'val'} {"field": "data://introspection.path", "op": "eq", "value": "val"}
if scheme (node or data) is missing, condition compares data with if scheme (node or data) is missing, condition compares data with
introspection data. introspection data.
@ -127,8 +127,8 @@ Starting from Mitaka release, ``value`` field in actions supports fetching data
from introspection, it's using `python string formatting notation from introspection, it's using `python string formatting notation
<https://docs.python.org/2/library/string.html#formatspec>`_ :: <https://docs.python.org/2/library/string.html#formatspec>`_ ::
{'action': 'set-attribute', 'path': '/driver_info/ipmi_address', {"action": "set-attribute", "path": "/driver_info/ipmi_address",
'value': '{data[inventory][bmc_address]}'} "value": "{data[inventory][bmc_address]}"}
.. _setting-ipmi-creds: .. _setting-ipmi-creds:
@ -241,43 +241,47 @@ see :ref:`rules`.
A rule to set a node's Ironic driver to the ``agent_ipmitool`` driver and A rule to set a node's Ironic driver to the ``agent_ipmitool`` driver and
populate the required driver_info for that driver would look like:: populate the required driver_info for that driver would look like::
"description": "Set IPMI driver_info if no credentials", [{
"actions": [ "description": "Set IPMI driver_info if no credentials",
{'action': 'set-attribute', 'path': 'driver', 'value': 'agent_ipmitool'}, "actions": [
{'action': 'set-attribute', 'path': 'driver_info/ipmi_username', {"action": "set-attribute", "path": "driver", "value": "agent_ipmitool"},
'value': 'username'}, {"action": "set-attribute", "path": "driver_info/ipmi_username",
{'action': 'set-attribute', 'path': 'driver_info/ipmi_password', "value": "username"},
'value': 'password'} {"action": "set-attribute", "path": "driver_info/ipmi_password",
] "value": "password"}
"conditions": [ ],
{'op': 'is-empty', 'field': 'node://driver_info.ipmi_password'}, "conditions": [
{'op': 'is-empty', 'field': 'node://driver_info.ipmi_username'} {"op": "is-empty", "field": "node://driver_info.ipmi_password"},
] {"op": "is-empty", "field": "node://driver_info.ipmi_username"}
]
"description": "Set deploy info if not already set on node", },{
"actions": [ "description": "Set deploy info if not already set on node",
{'action': 'set-attribute', 'path': 'driver_info/deploy_kernel', "actions": [
'value': '<glance uuid>'}, {"action": "set-attribute", "path": "driver_info/deploy_kernel",
{'action': 'set-attribute', 'path': 'driver_info/deploy_ramdisk', "value": "<glance uuid>"},
'value': '<glance uuid>'}, {"action": "set-attribute", "path": "driver_info/deploy_ramdisk",
] "value": "<glance uuid>"}
"conditions": [ ],
{'op': 'is-empty', 'field': 'node://driver_info.deploy_ramdisk'}, "conditions": [
{'op': 'is-empty', 'field': 'node://driver_info.deploy_kernel'} {"op": "is-empty", "field": "node://driver_info.deploy_ramdisk"},
] {"op": "is-empty", "field": "node://driver_info.deploy_kernel"}
]
}]
All nodes discovered and enrolled via the ``enroll`` hook, will contain an All nodes discovered and enrolled via the ``enroll`` hook, will contain an
``auto_discovered`` flag in the introspection data, this flag makes it ``auto_discovered`` flag in the introspection data, this flag makes it
possible to distinguish between manually enrolled nodes and auto-discovered possible to distinguish between manually enrolled nodes and auto-discovered
nodes in the introspection rules using the rule condition ``eq``:: nodes in the introspection rules using the rule condition ``eq``::
"description": "Enroll auto-discovered nodes with fake driver", {
"actions": [ "description": "Enroll auto-discovered nodes with fake driver",
{'action': 'set-attribute', 'path': 'driver', 'value': 'fake'} "actions": [
] {"action": "set-attribute", "path": "driver", "value": "fake"}
"conditions": [ ],
{'op': 'eq', 'field': 'data://auto_discovered', 'value': True} "conditions": [
] {"op": "eq", "field": "data://auto_discovered", "value": true}
]
}
Reapplying introspection on stored data Reapplying introspection on stored data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~