Problem:
When a host is deleted, I captured the JSON passed through stdin to a host-managed/destroy hook script.
It looks like this: {"host":{"host":{"ip":null,"ip6":null,"environment_id":null,"environment_name":null,"last_report":null,"mac":null,....
Because of this I am not able to capture the MAC address of the host getting deleted.
I think the host gets deleted before it’s details are passed to the destroy script.
Expected outcome:
For other host-managed hook scripts, the JSON looks fine {"host":{"host":{"ip":"10.10.10.20","ip6":"","environment_id":null,"environment_name":null,"last_report":null,"mac":"00:50:56:88:1e:d9",....
Which destroy hook you work with? If this is an “after” hook, this might be too late - ActiveRecord probably already deleted interfaces and it’s all gone, thus MAC address is nil (it’s just a reference to primary interface). Try using “host/managed/destroy” orchestration hook, that runs in “before_destroy” AR callback.
I am using host/managed/destroy hook only. From production.log 2018-06-15T17:07:25 [app] [D] Found hook to Host::Managed#destroy, filename 01-del-tftp-mac-dir.sh