From 54ff228bc3e9f7615443b7c607308dda7d270433 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 15 Mar 2017 09:44:22 +0000 Subject: [PATCH] Add more introspection rules - local boot, LLDP description to name We currently hard code the interface from which to pull the LLDP port description. This should be improved at some point, but we are limited by indexing the interfaces dict by some constant. We could provide a rule for each possible interface name but this feels ugly. Alternatively we could do this with a custom plugin. --- ansible/group_vars/all/bifrost | 4 ++- ansible/group_vars/all/inspector | 46 +++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/ansible/group_vars/all/bifrost b/ansible/group_vars/all/bifrost index 51eb1646c..9d691b714 100644 --- a/ansible/group_vars/all/bifrost +++ b/ansible/group_vars/all/bifrost @@ -69,8 +69,10 @@ kolla_bifrost_inspector_rules: - "{{ inspector_rule_ipmi_credentials }}" - "{{ inspector_rule_deploy_kernel }}" - "{{ inspector_rule_deploy_ramdisk }}" + - "{{ inspector_rule_local_boot }}" + - "{{ inspector_rule_root_hint_init }}" - "{{ inspector_rule_root_hint_serial }}" - - "{{ inspector_rule_save_data }}" + - "{{ inspector_rule_eno3_lldp_switch_port_desc_to_name }}" # Ironic inspector IPMI username to set. kolla_bifrost_inspector_ipmi_username: diff --git a/ansible/group_vars/all/inspector b/ansible/group_vars/all/inspector index ed543299b..01b73989b 100644 --- a/ansible/group_vars/all/inspector +++ b/ansible/group_vars/all/inspector @@ -61,22 +61,54 @@ inspector_rule_deploy_ramdisk: path: "driver_info/deploy_ramdisk" value: "{{ inspector_deploy_ramdisk }}" +# Ironic inspector rule to set local boot capability +inspector_rule_local_boot: + description: "Set local boot capability" + conditions: [] + actions: + - action: "set-capability" + name: "boot_option" + value: "local" + +# Ironic inspector rule to initialise root device hints. +inspector_rule_root_hint_init: + description: "Initialise root device hint" + conditions: + - field: "node://properties.root_device" + op: "is-empty" + actions: + # Inspector can't combine references to introspection data with non-string + # types, see https://bugs.launchpad.net/ironic-inspector/+bug/1670768. We + # must therefore first set the root_device property to an empty dict, then + # update the fields within it. + - action: "set-attribute" + path: "properties/root_device" + value: {} + # Ironic inspector rule to set serial root device hint. inspector_rule_root_hint_serial: description: "Set serial root device hint" conditions: - - field: "node://properties.root_device" - op: "is-empty" - field: "data://root_disk.serial" op: "is-empty" invert: True actions: - action: "set-attribute" - path: "properties/root_device" - #value: "{{ '{{' | replace('{{', '{{ \"{{\" }}') }}\"serial\": \"{data[root_disk][serial]}\"{{ '}}' | replace('}}', '{{ \"}}\" }}') }}" - # We need to suppoly a JSON encoded object of root device hints, escaping - # the curly brackets. - value: "{{ inspector_rule_escaped_left_curly }}\"serial\": \"{data[root_disk][serial]}\"{{ inspector_rule_escaped_right_curly }}" + path: "properties/root_device/serial" + value: "{data[root_disk][serial]}" + +# Ironic inspector rule to set the node's name from eno3's LLDP switch port +# description. +inspector_rule_eno3_lldp_switch_port_desc_to_name: + description: "Set node name from LLDP switch port description" + conditions: + - field: "data://all_interfaces.eno3.lldp_processed.switch_port_description" + op: "is-empty" + invert: True + actions: + - action: "set-attribute" + path: "name" + value: "{data[all_interfaces][eno3][lldp_processed][switch_port_description]}" # Ironic inspector rule to save introspection data to the node. inspector_rule_save_data: