Skip to content

Commit

Permalink
Merge pull request #9 from OpenCHAMI/trcotton/endpoint-update
Browse files Browse the repository at this point in the history
removed hardocoded ports for SMD and BSS endpoints
  • Loading branch information
travisbcotton authored Apr 1, 2024
2 parents 2f5d765 + e1e6bb5 commit f59fe8a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
16 changes: 1 addition & 15 deletions dnsmasq-dhcpd-dynamic/dnsmasq.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,4 @@ user=root
dhcp-authoritative
log-dhcp
domain=.local
dhcp-option=option:domain-search,.local
#TODO the next 4 options should be dynamic, I don't know how we want to populate these
dhcp-option=option:ntp-server,172.16.0.254
dhcp-option=option:router,172.16.0.254
dhcp-option=option:dns-server,10.0.69.16,10.0.69.17
dhcp-range=172.16.0.1,172.16.0.255
dhcp-option=option:mtu,1500
dhcp-hostsfile=/etc/dhcp-hostsfile
dhcp-optsfile=/etc/dhcp-optsfile
enable-tftp
tftp-root=/usr/share/ipxe/
dhcp-match=IPXEBOOT,175
dhcp-match=PXEBOOT,60
dhcp-option=tag:PXEBOOT,tag:!IPXEBOOT,option:bootfile-name,ipxe-x86_64.efi

conf-dir=/etc/dnsmasq.d
17 changes: 17 additions & 0 deletions dnsmasq-dhcpd-dynamic/init.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
cat > /etc/dnsmasq.d/dhcp.conf << EOF
dhcp-option=option:domain-search,.local
dhcp-option=option:ntp-server,${NTP_SERVER}
dhcp-option=option:router,${OPTION_ROUTER}
dhcp-option=option:dns-server,${DNS_SERVERS}
dhcp-range=${DHCP_RANGE}
dhcp-option=option:mtu,1500
dhcp-hostsfile=/etc/dhcp-hostsfile
dhcp-optsfile=/etc/dhcp-optsfile
enable-tftp
tftp-root=/usr/share/ipxe/
dhcp-match=IPXEBOOT,175
dhcp-match=PXEBOOT,60
dhcp-option=tag:PXEBOOT,tag:!IPXEBOOT,option:bootfile-name,ipxe-x86_64.efi
dhcp-option=option:netmask,${DHCP_NETMASK}
EOF

smd.py
update_loop.sh &
dnsmasq -k -d --log-dhcp
6 changes: 4 additions & 2 deletions dnsmasq-dhcpd-dynamic/smd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ def getSMD(url):
def main():
sighup = False
smd_endpoint=os.environ['smd_endpoint']
smd_port=os.environ['smd_port']
bss_endpoint=os.environ['bss_endpoint']
ei_data = getSMD(f'http://{smd_endpoint}:27779/hsm/v2/Inventory/EthernetInterfaces')
bss_port=os.environ['bss_port']
ei_data = getSMD(f'http://{smd_endpoint}:{smd_port}/hsm/v2/Inventory/EthernetInterfaces')
#hostsfile = tempfile.TemporaryFile(mode = "r+")
hostsfile = open("/etc/dhcp-hostsfile-new", "w")
#this for loop writes host entries
Expand All @@ -37,7 +39,7 @@ 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}:27778/boot/v1/bootscript?mac={i['MACAddress']}\"", file=optsfile)
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 f59fe8a

Please sign in to comment.