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", "description": "Set IPMI driver_info if no credentials",
"actions": [ "actions": [
{'action': 'set-attribute', 'path': 'driver', 'value': 'agent_ipmitool'}, {"action": "set-attribute", "path": "driver", "value": "agent_ipmitool"},
{'action': 'set-attribute', 'path': 'driver_info/ipmi_username', {"action": "set-attribute", "path": "driver_info/ipmi_username",
'value': 'username'}, "value": "username"},
{'action': 'set-attribute', 'path': 'driver_info/ipmi_password', {"action": "set-attribute", "path": "driver_info/ipmi_password",
'value': 'password'} "value": "password"}
] ],
"conditions": [ "conditions": [
{'op': 'is-empty', 'field': 'node://driver_info.ipmi_password'}, {"op": "is-empty", "field": "node://driver_info.ipmi_password"},
{'op': 'is-empty', 'field': 'node://driver_info.ipmi_username'} {"op": "is-empty", "field": "node://driver_info.ipmi_username"}
] ]
},{
"description": "Set deploy info if not already set on node", "description": "Set deploy info if not already set on node",
"actions": [ "actions": [
{'action': 'set-attribute', 'path': 'driver_info/deploy_kernel', {"action": "set-attribute", "path": "driver_info/deploy_kernel",
'value': '<glance uuid>'}, "value": "<glance uuid>"},
{'action': 'set-attribute', 'path': 'driver_info/deploy_ramdisk', {"action": "set-attribute", "path": "driver_info/deploy_ramdisk",
'value': '<glance uuid>'}, "value": "<glance uuid>"}
] ],
"conditions": [ "conditions": [
{'op': 'is-empty', 'field': 'node://driver_info.deploy_ramdisk'}, {"op": "is-empty", "field": "node://driver_info.deploy_ramdisk"},
{'op': 'is-empty', 'field': 'node://driver_info.deploy_kernel'} {"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", "description": "Enroll auto-discovered nodes with fake driver",
"actions": [ "actions": [
{'action': 'set-attribute', 'path': 'driver', 'value': 'fake'} {"action": "set-attribute", "path": "driver", "value": "fake"}
] ],
"conditions": [ "conditions": [
{'op': 'eq', 'field': 'data://auto_discovered', 'value': True} {"op": "eq", "field": "data://auto_discovered", "value": true}
] ]
}
Reapplying introspection on stored data Reapplying introspection on stored data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~