I’ve been researching and inquiring online about this subject and I cannot find any useful info regarding it. So, the location and subnet plugins within fog only works with registered host to direct it to the storage node to use for the imaging task I know this and use this function with all registered host I have. But, I want to know if there is a way to implement this with non-registered host, where if I choose the deploy image option in the PXE menu the main fog server can determine the node to use within the same location/subnet of the client pc booting in to PXE based off info gathered from the pc like Ip address/subnet, I have not been successful yet at cracking this so I’m wondering if anyone else has attempted or been successful at doing this or could give me some ideas of where to tie all this together to make it possible. I want the node assignment during the imaging task to be automated without having to always register the host pc. I have a main fog server and 2 storage nodes on 2 different subnets within our facility right now I am running dnsmasq on the storage nodes to respond to PXE request within the different subnets and serve the files. It works great but it obviously will choose a random node based off the main server’s current logic after the deploy image option is selected; I want to see about implementing this to cut latency down by having the closest node (the node within the corresponding subnet of the client pc) to always be the one to handle imaging.
Not sure if this is relevant but I modified the embedded ipxescript from the original to automate the chain loading of the tftp server I want to use so I don’t have to enter it manually each time here is a copy of my script below, so this process is already automated but I want to automate the logic for the storage node tasked with the imaging and Ive experimented with trying to set parameters within the ipxe script did not work:
#!ipxe
Obtain DHCP lease
dhcp || goto dhcperror
echo Received DHCP lease, proceeding…
Test the hostname resolution by pinging it
ping -c 1 fogserver || goto pingerror
echo Hostname resolved, proceeding…
Proceed to netboot using the hostname directly
chain tftp://fogserver/default.ipxe || goto chainloadfailed
:chainloadfailed
prompt --key s --timeout 10000 Chainloading failed, hit ‘s’ for the iPXE shell; reboot in 10 seconds && shell || reboot
:dhcperror
prompt --key s --timeout 10000 DHCP failed, hit ‘s’ for the iPXE shell; reboot in 10 seconds && shell || reboot
:pingerror
prompt --key s --timeout 10000 Hostname resolution failed, hit ‘s’ for the iPXE shell; reboot in 10 seconds && shell || reboot
And below is the script I tried to use to attempt to set the location of the host booting over pxe to task the storage node with imaging task, which did not work due to the main servers decision is done after choices are made in the pxe menu so I do not think that adding params to this script is the way to go but I may be wrong:
#!ipxe
Obtain DHCP lease
dhcp || goto dhcperror
echo Received DHCP lease, proceeding…
Determine the location based on subnet
set clientip ${net0/ip}
set locationid 0 # Default location ID (if needed)
if (${clientip} =~ 10.130.192.) set locationid 1
if (${clientip} =~ 10.130.208.) set locationid 2
Perform the API call to set the location for this session
Replace <api-user> and <api-pass> with your FOG API credentials
set api_user <api-user>
set api_pass <api-pass>
set api_token “”
set user_token “”
Fetch API token
set api_url
http://<fog-server>/fog/management/index.php?sub=auth&action=login
params set=api_user=${api_user}&api_pass=${api_pass}
route http post ${api_url} params | parse api_token=${api_token},user_token=${user_token}
Set location via API call
set location_url
http://<fog-server>/fog/management/index.php?sub=location&action=setLocation&mac=${net0/mac}&locationid=${locationid}
route http post ${location_url} Authorization: “Bearer ${api_token}”
Test the hostname resolution by pinging it
ping -c 1 fogserver || goto pingerror
echo Hostname resolved, proceeding…
Chain to boot.php and pass location ID
chain tftp://fogserver/default.ipxe?locationid=${locationid} || goto chainloadfailed
:chainloadfailed
prompt --key s --timeout 10000 Chainloading failed, hit ‘s’ for the iPXE shell; reboot in 10 seconds && shell || reboot
:dhcperror
prompt --key s --timeout 10000 DHCP failed, hit ‘s’ for the iPXE shell; reboot in 10 seconds && shell || reboot
:pingerror
prompt --key s --timeout 10000 Hostname resolution failed, hit ‘s’ for the iPXE shell; reboot in 10 seconds && shell || reboot