Skip to content

Instantly share code, notes, and snippets.

@strlng
Last active October 29, 2015 18:27
Show Gist options
  • Save strlng/b272921182c35cdbe158 to your computer and use it in GitHub Desktop.
Save strlng/b272921182c35cdbe158 to your computer and use it in GitHub Desktop.
Generate text necessary to create DHCP static reservations for OS X Server via command line
#!/usr/bin/python
import uuid
# Two dimensional array consisting of MAC Address, IP Address, Name
imacs=[["xx:xx:xx:xx:xx:xx","xxx.xxx.xxx.xxx","hostname"]]
for imac in imacs:
uniqueid = uuid.uuid4()
command = "dhcp:static_maps:_array_id:" + str(uniqueid) + " = create\n"
command += "dhcp:static_maps:_array_id:" + str(uniqueid) + ":en_address:_array_index:0 = \"" + imac[0] + "\"\n"
command += "dhcp:static_maps:_array_id:" + str(uniqueid) + ":ip_address:_array_index:0 = \"" + imac[1] + "\"\n"
command += "dhcp:static_maps:_array_id:" + str(uniqueid) + ":name = \"" + imac[2] + "\""
print command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment