Skip to content

Commit

Permalink
Merge pull request #12 from OpenCHAMI/trcotton/nidname
Browse files Browse the repository at this point in the history
changed dhcp to serve out nidnames instead of xnames
  • Loading branch information
travisbcotton authored Apr 4, 2024
2 parents d0144c1 + 662e64a commit 6ef554f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dnsmasq-dhcpd-dynamic/smd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def main():
#this for loop writes host entries
for i in ei_data:
if i['Type'] != 'NodeBMC':
print(f"{i['MACAddress']},set:{i['ComponentID']},{i['IPAddresses'][0]['IPAddress']},{i['ComponentID']}", file=hostsfile)
if 'NID' in i:
nidname='nid'+'%0*d' % (3, i['NID'])
print(f"{i['MACAddress']},set:{nidname},{i['IPAddresses'][0]['IPAddress']},{nidname}", file=hostsfile)
else:
print(f"{i['MACAddress']},set:{i['ComponentID']},{i['IPAddresses'][0]['IPAddress']},{i['ComponentID']}", file=hostsfile)
else:
print(f"{i['MACAddress']},{i['IPAddresses'][0]['IPAddress']},{i['ComponentID']}", file=hostsfile)
hostsfile.close()
Expand All @@ -39,7 +43,11 @@ def main():
#this for loop writes option entries, we wouldn't need it if the BSS wasn't MAC specific
for i in ei_data:
if 'bmc' not in i['Description']:
print(f"tag:{i['ComponentID']},tag:IPXEBOOT,option:bootfile-name,\"http://{bss_endpoint}:{bss_port}/boot/v1/bootscript?mac={i['MACAddress']}\"", file=optsfile)
if 'NID' in i:
nidname='nid'+'%0*d' % (3, i['NID'])
print(f"tag:{nidname},tag:IPXEBOOT,option:bootfile-name,\"http://{bss_endpoint}:{bss_port}/boot/v1/bootscript?mac={i['MACAddress']}\"", file=optsfile)
else:
print(f"tag:{i['ComponentID']},tag:IPXEBOOT,option:bootfile-name,\"http://{bss_endpoint}:{bss_port}/boot/v1/bootscript?mac={i['MACAddress']}\"", file=optsfile)
optsfile.close()
if os.path.isfile("/etc/dhcp-optsfile") == False or filecmp.cmp("/etc/dhcp-optsfile-new","/etc/dhcp-optsfile") == False:
sighup = True
Expand Down

0 comments on commit 6ef554f

Please sign in to comment.