From c56d126ddc8d4a8c6204fed34575f12179abfd44 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Tue, 4 Apr 2017 16:10:12 +0100 Subject: [PATCH] Add inspector rules to add system vendor to metadata, use to set bmc_type --- ansible/filter_plugins/bmc_type.py | 15 ++++++ ansible/group_vars/all/inspector | 66 ++++++++++++++++++++++++ ansible/overcloud-inventory-discover.yml | 4 +- 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 ansible/filter_plugins/bmc_type.py diff --git a/ansible/filter_plugins/bmc_type.py b/ansible/filter_plugins/bmc_type.py new file mode 100644 index 000000000..e15d5dcbc --- /dev/null +++ b/ansible/filter_plugins/bmc_type.py @@ -0,0 +1,15 @@ +def bmc_type_from_system_vendor(system_vendor): + if not system_vendor: + return None + if system_vendor.get('manufacturer') == 'Dell Inc.': + return 'idrac' + return None + + +class FilterModule(object): + """BMC type filters.""" + + def filters(self): + return { + 'bmc_type_from_system_vendor': bmc_type_from_system_vendor, + } diff --git a/ansible/group_vars/all/inspector b/ansible/group_vars/all/inspector index ce3258e7a..4d8a92ef9 100644 --- a/ansible/group_vars/all/inspector +++ b/ansible/group_vars/all/inspector @@ -207,6 +207,68 @@ inspector_rule_lldp_switch_port_desc_to_name: path: "name" value: "{data[all_interfaces][{{ inspector_rule_var_lldp_switch_port_interface }}][lldp_processed][switch_port_description]}" +# Ironic inspector rule to initialise system vendor data in the node's metadata. +inspector_rule_save_system_vendor_init: + description: "Intiialise system vendor data in Ironic node metadata" + conditions: + - field: "data://inventory.system_vendor" + op: "is-empty" + invert: True + - field: "node://extra.system_vendor" + op: "is-empty" + actions: + - action: "set-attribute" + path: "extra/system_vendor" + value: {} + +# Ironic inspector rule to save system vendor manufacturer data in the node's +# metadata. +inspector_rule_save_system_vendor_manufacturer: + description: "Save system vendor manufacturer data in Ironic node metadata" + conditions: + - field: "data://inventory.system_vendor" + op: "is-empty" + invert: True + - field: "data://inventory.system_vendor.manufacturer" + op: "is-empty" + invert: True + actions: + - action: "set-attribute" + path: "extra/system_vendor/manufacturer" + value: "{data[inventory][system_vendor][manufacturer]}" + +# Ironic inspector rule to save system vendor serial number in the node's +# metadata. +inspector_rule_save_system_vendor_serial_number: + description: "Save system vendor serial number in Ironic node metadata" + conditions: + - field: "data://inventory.system_vendor" + op: "is-empty" + invert: True + - field: "data://inventory.system_vendor.serial_number" + op: "is-empty" + invert: True + actions: + - action: "set-attribute" + path: "extra/system_vendor/serial_number" + value: "{data[inventory][system_vendor][serial_number]}" + +# Ironic inspector rule to save system vendor product name in the node's +# metadata. +inspector_rule_save_system_vendor_product_name: + description: "Save system vendor product name in Ironic node metadata" + conditions: + - field: "data://inventory.system_vendor" + op: "is-empty" + invert: True + - field: "data://inventory.system_vendor.product_name" + op: "is-empty" + invert: True + actions: + - action: "set-attribute" + path: "extra/system_vendor/product_name" + value: "{data[inventory][system_vendor][product_name]}" + # Ironic inspector rule to save introspection data to the node. inspector_rule_save_data: description: "Save introspection data to Ironic node" @@ -226,6 +288,10 @@ inspector_rules_default: - "{{ inspector_rule_root_hint_serial }}" - "{{ inspector_rule_set_pxe_interface_mac }}" - "{{ inspector_rule_lldp_switch_port_desc_to_name }}" + - "{{ inspector_rule_save_system_vendor_init }}" + - "{{ inspector_rule_save_system_vendor_manufacturer }}" + - "{{ inspector_rule_save_system_vendor_serial_number }}" + - "{{ inspector_rule_save_system_vendor_product_name }}" # List of additional ironic inspector rules. inspector_rules_extra: [] diff --git a/ansible/overcloud-inventory-discover.yml b/ansible/overcloud-inventory-discover.yml index 7719cdf1b..98bc52a58 100644 --- a/ansible/overcloud-inventory-discover.yml +++ b/ansible/overcloud-inventory-discover.yml @@ -30,6 +30,8 @@ {% for host in ironic_inventory.baremetal.hosts %} {% set hostvars=ironic_inventory._meta.hostvars[host] %} {% set ipmi_address=hostvars.driver_info.ipmi_address | default %} - {{ host }} ipmi_address={{ ipmi_address }} + {% set system_vendor=hostvars.extra.system_vendor | default %} + {% set bmc_type=system_vendor | bmc_type_from_system_vendor %} + {{ host }} ipmi_address={{ ipmi_address }} bmc_type={{ bmc_type }} {% endfor %} dest: "{{ kayobe_config_path }}/inventory/controllers"