Add inspector rules to add system vendor to metadata, use to set bmc_type

This commit is contained in:
Mark Goddard 2017-04-04 16:10:12 +01:00
parent 35aab4e4fe
commit c56d126ddc
3 changed files with 84 additions and 1 deletions

View File

@ -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,
}

View File

@ -207,6 +207,68 @@ inspector_rule_lldp_switch_port_desc_to_name:
path: "name" path: "name"
value: "{data[all_interfaces][{{ inspector_rule_var_lldp_switch_port_interface }}][lldp_processed][switch_port_description]}" 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. # Ironic inspector rule to save introspection data to the node.
inspector_rule_save_data: inspector_rule_save_data:
description: "Save introspection data to Ironic node" description: "Save introspection data to Ironic node"
@ -226,6 +288,10 @@ inspector_rules_default:
- "{{ inspector_rule_root_hint_serial }}" - "{{ inspector_rule_root_hint_serial }}"
- "{{ inspector_rule_set_pxe_interface_mac }}" - "{{ inspector_rule_set_pxe_interface_mac }}"
- "{{ inspector_rule_lldp_switch_port_desc_to_name }}" - "{{ 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. # List of additional ironic inspector rules.
inspector_rules_extra: [] inspector_rules_extra: []

View File

@ -30,6 +30,8 @@
{% for host in ironic_inventory.baremetal.hosts %} {% for host in ironic_inventory.baremetal.hosts %}
{% set hostvars=ironic_inventory._meta.hostvars[host] %} {% set hostvars=ironic_inventory._meta.hostvars[host] %}
{% set ipmi_address=hostvars.driver_info.ipmi_address | default %} {% 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 %} {% endfor %}
dest: "{{ kayobe_config_path }}/inventory/controllers" dest: "{{ kayobe_config_path }}/inventory/controllers"