iPXE Embedded loader does not put token to the DHCP filename option
I've encountered two problems with iPXE Embedded:
- DHCP filename option does not include token at all when NEW host is created (EDIT or BUILD does work fine)
- when BUILD is canceled/exited a token which is no longer valid is inserted
For (1) the problem is that token is generated/saved after the host record is saved. Our orchestration triggers earlier than token is generated. So for this case I am proposing to change token generation to be before_validation instead of after_validation. I hope this will not cause any issues elsewhere or I have no other ideas how to fix this.
For (2) foreman_url helper is modified only to include token when build flag is on because during orchestration host record (build flag) is correctly updated but associated token is being removed after DHCP orchestration later on (expiration). And then the build flag is compared for iPXE Embedded loader hosts and DHCP update is properly scheduled.