ironic.common.inspection_rules.tester module

Test inspection rules against captured hardware inventory.

This module runs the inspection rules evaluation process to help test and debug inspection rules before deploying them to a production environment. It backs the ironic-manage inspection-rules check command.

class ironic.common.inspection_rules.tester.FakeNode(data)[source]

Bases: object

Fake node built from ‘openstack baremetal node show’ output.

save()[source]
class ironic.common.inspection_rules.tester.FakeTask(node)[source]

Bases: object

Minimal fake task object for testing.

class ironic.common.inspection_rules.tester.InspectionRulesEvaluator(node_file, inventory_file, rules_file)[source]

Bases: object

Evaluator for testing inspection rules against hardware inventory.

evaluate_rules()[source]

Evaluate inspection rules against the loaded inventory.

load_inventory()[source]

Load hardware inventory and plugin data from JSON or YAML file.

load_node()[source]

Load node data from YAML file.

load_rules()[source]

Load and validate inspection rules from YAML file.

print_results()[source]

Print all results in human-readable form.

run()[source]

Run the complete evaluation process.

ironic.common.inspection_rules.tester.check_files(node_file, inventory_file, rules_file)[source]

Evaluate inspection rules against a single set of captured files.

Parameters:
  • node_file – JSON or YAML file with node data, e.g. from openstack baremetal node show <node> -f json.

  • inventory_file – JSON or YAML file with hardware inventory and plugin data, e.g. from openstack baremetal node inventory save.

  • rules_file – YAML file with the inspection rules to evaluate.

Returns:

an exit code, 0 on success.

ironic.common.inspection_rules.tester.run_suite(data_dir, rules_file)[source]

Run the inspection rules tester against all test cases in a tree.

Each subdirectory of data_dir is one test case and must contain a node file (node.yaml or node.json) and an inventory file (inventory.yaml or inventory.json). The rules in rules_file are evaluated against every test case.

Parameters:
  • data_dir – directory containing test case subdirectories.

  • rules_file – YAML file with the inspection rules to evaluate.

Returns:

an exit code, 0 when all test cases pass.