Skip to content

Commit

Permalink
updated to use xnames if NIDs are not set
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbcotton committed Apr 4, 2024
1 parent 29aaa51 commit 662e64a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions dnsmasq-dhcpd-dynamic/smd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ def main():
hostsfile = open("/etc/dhcp-hostsfile-new", "w")
#this for loop writes host entries
for i in ei_data:
nidname='nid'+'%0*d' % (3, i['NID'])
if i['Type'] != 'NodeBMC':
print(f"{i['MACAddress']},set:{nidname},{i['IPAddresses'][0]['IPAddress']},{nidname}", 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 @@ -40,8 +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']:
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)
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 662e64a

Please sign in to comment.