diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2006-09-22 17:18:13 -0400 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-09-22 17:18:13 -0400 |
commit | 1f8dadc3a3aded03dab038a66f5edfe7bee43ec9 (patch) | |
tree | f079b5610055e2baac288c5921f25e801b4b0632 /cobbler/action_sync.py | |
parent | 7b51ac050a094e1164b0df9b0ecf0acdc5ae9a7b (diff) | |
download | third_party-cobbler-1f8dadc3a3aded03dab038a66f5edfe7bee43ec9.tar.gz third_party-cobbler-1f8dadc3a3aded03dab038a66f5edfe7bee43ec9.tar.xz third_party-cobbler-1f8dadc3a3aded03dab038a66f5edfe7bee43ec9.zip |
dhcp templating for individual systems
Diffstat (limited to 'cobbler/action_sync.py')
-rw-r--r-- | cobbler/action_sync.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index a4699ee..b025138 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -25,6 +25,8 @@ import cexceptions import traceback import errno + + class BootSync: """ Handles conversion of internal state to the tftpboot tree layout @@ -80,6 +82,7 @@ class BootSync: self.copyfile(path, destpath) def write_dhcp_file(self): + try: f2 = open("/etc/cobbler/dhcp.template","r") except: @@ -88,7 +91,31 @@ class BootSync: f1 = self.open_file("/etc/dhcpd.conf","w+") template_data = f2.read() f2.close() - system_definitions = "<INSERT COBBLER LIST HERE>" + + # build each per-system definition + system_definitions = "" + counter = 0 + elilo = os.path.basename(self.settings.bootloaders["ia64"]) + for system in self.systems: + if not utils.is_mac(system.name): + # can't do per-system dhcp features if the system + # hostname is not a MAC, therefore the templating + # gets to be pretty lame. The general rule here is + # if you want to PXE IA64 boxes, you need to use + # the MAC as the system name. + continue + systxt = "" + counter = counter + 1 + systxt = "\nhost label%d {\n" % counter + if system.pxe_arch == "ia64": + # can't use pxelinux.0 anymore + systxt = systxt + " filename \"/%s\";\n" % elilo + systxt = systxt + " hardware ethernet %s;\n" % system.name + if system.pxe_hostname != "": + systxt = systxt + " fixed-address %s;\n" % system.pxe_hostname + systxt = systxt + "}\n" + system_definitions = system_definitions + systxt + metadata = { "insert_cobbler_system_definitions" : system_definitions, "date" : time.asctime(time.gmtime()) |