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 | |
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
-rw-r--r-- | cobbler.pod | 55 | ||||
-rw-r--r-- | cobbler/action_sync.py | 29 | ||||
-rw-r--r-- | cobbler/cobbler_msg.py | 1 | ||||
-rw-r--r-- | cobbler/item_system.py | 12 | ||||
-rw-r--r-- | dhcp.template | 2 |
5 files changed, 85 insertions, 14 deletions
diff --git a/cobbler.pod b/cobbler.pod index 7a8bf20..6080b6d 100644 --- a/cobbler.pod +++ b/cobbler.pod @@ -50,11 +50,19 @@ an absolute filesystem path to a initrd image =item kopts -(optional) sets kernel arguments, ex: --ksmeta="foo=bar baz=3 asdf" +(optional) sets kernel arguments. + +Example: --ksmeta="foo=bar baz=3 asdf" =item ksmeta -(optional) sets kickstart variables to substitute, ex: --ksmeta="foo=bar baz=3 asdf" +(optional) + +This is an advanced feature that sets kickstart variables to substitute, thus enabling kickstart files to be treated as templates. + +Example: --ksmeta="foo=bar baz=3 asdf" + +See the section below on templating. =back @@ -97,8 +105,7 @@ the name of a previously defined cobbler distribution =head2 ADDING A SYSTEM -B<cobbler system add --name=<ip|mac|hostname> --profile=<string> [--kopts=<string>] [--pxe_arch=<standard|ia64>] [--ksmeta=<string>] - +B<cobbler system add --name=<ip|mac|hostname> --profile=<string> [--kopts=<string>] [--pxe_arch=<standard|ia64>] [--pxe_hostname=<string>] [--ksmeta=<string>] =over =over @@ -115,15 +122,25 @@ so that is the preferred usage. =item pxe-arch -The PXE architecture is (obviously) only relevant to PXE booting. Setting -the arch to "ia64" will use elilo.efi as the boot loader instead of -"pxelinux.0". The default, "standard", uses "pxelinux.0". +Advanced feature. Applies only if manage-dhcp is set to 1 in /var/lib/cobbler/settings and only for PXE provisioning. -If no Itanium machines are present, this can be ignored entirely. +Setting the pxe-arch to "ia64" will use elilo.efi as the boot loader instead of +"pxelinux.0". The default, "standard", uses "pxelinux.0", which does not work for IA-64 (Itanium) systems. -=back +When using this setting, be sure the "--name" given to the "system add" command is a MAC address or no per-system record in dhcpd.conf can be generated.. -=back +Example: --pxe-arch=ia64 + +=item pxe-hostname + +Advanced feature. Applies only if manage-dhcp is set to 1 in /var/lib/cobbler/settings and only for PXE provisioning. + +If cobbler is configured to generate the dhcpd.conf file, use this +setting to pin a certain MAC address to a specific dhcp hostname. + +When using this setting, be sure that the "--name" given to the "system add" command is a MAC address or no per-system record in dhcpd.conf can be generated. + +Example: ---pxe-hostname="foo.example.com" =back @@ -201,6 +218,24 @@ For NFS and HTTP URLs, the "--ksmeta" options will have no effect. This is a goo cobbler manage your kickstart files, though the URL functionality is provided for integration with legacy infrastructure, possibly including web apps that already generate kickstarts. +=head2 DHCP CONFIGURATION MANAGEMENT + +By default, cobbler does not touch dhcpd.conf and leaves configuration +of it up to the user. If manage_dhcp is set to 1 in /var/lib/cobbler/settings, +this changes, and cobbler *will* write a dhcp.conf file. The file is based +on a template in /etc/cobbler/dhcpd.conf.template -- and must be user edited for +the user's particular networking environment. Read the file and understand dhcpd.conf files before proceeding. + +If this flag is set, it enables two things: +(A) relatively seamless mixing of Itanium and x86/x86_64 machines in a PXE environment +(B) pinning dhcp hostnames to MAC addresses automatically. + +Per-system records in DHCP will only be written if the cobbler system name is a MAC address, so it's recommended that those be used if manage_dhcp is turned on. + +Itanium systems also need to be specified by the MAC address, and in addition need to be given the "--pxe-arch=ia64" parameter. + +The dhcpd.conf file will be updated each time "cobbler sync" is run. + =head2 TWEAKING Enterprising users can edit the files in /var/lib/cobbler directly versus using the command line. The repair 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()) diff --git a/cobbler/cobbler_msg.py b/cobbler/cobbler_msg.py index c125c19..4ea4283 100644 --- a/cobbler/cobbler_msg.py +++ b/cobbler/cobbler_msg.py @@ -76,6 +76,7 @@ _msg_table = { "exc_profile2" : "profile name not set", "exc_pxe_arch" : "valid PXE architectures: standard or ia64", "exc_no_template" : "can't read /etc/cobbler/dhcp.template", + "exc_dhcp_nomac" : "when cobbler is managing dhcpd.conf, all system names must be MAC addresses. Aborting.", "check_ok" : """ No setup problems found. diff --git a/cobbler/item_system.py b/cobbler/item_system.py index 7127ae3..2ada359 100644 --- a/cobbler/item_system.py +++ b/cobbler/item_system.py @@ -28,6 +28,7 @@ class System(item.Item): self.kernel_options = "" self.ks_meta = "" self.pxe_arch = "standard" + self.pxe_hostname = "" def from_datastruct(self,seed_data): self.name = seed_data['name'] @@ -35,6 +36,7 @@ class System(item.Item): self.kernel_options = seed_data['kernel_options'] self.ks_meta = seed_data['ks_meta'] self.pxe_arch = seed_data['pxe_arch'] + self.pxe_hostname = seed_data['pxe_hostname'] return self def set_name(self,name): @@ -52,6 +54,12 @@ class System(item.Item): self.name = name # we check it add time, but store the original value. return True + def set_pxe_hostname(self,hostname): + # we allow this to be set to anything + # though we probably should check to see if it looks like a FQDN + self.pxe_hostname = hostname + return True + def set_profile(self,profile_name): """ Set the system to use a certain named profile. The profile @@ -94,7 +102,8 @@ class System(item.Item): 'profile' : self.profile, 'kernel_options' : self.kernel_options, 'ks_meta' : self.ks_meta, - 'pxe_arch' : self.pxe_arch + 'pxe_arch' : self.pxe_arch, + 'pxe_hostname' : self.pxe_hostname } def printable(self,id): @@ -103,5 +112,6 @@ class System(item.Item): buf = buf + "kernel options : %s" % self.kernel_options buf = buf + "ks metadata : %s" % self.ks_meta buf = buf + "pxe arch : %s" % self.pxe_arch + buf = buf + "pxe hostname : %s" % self.pxe_hostname return buf diff --git a/dhcp.template b/dhcp.template index bc95bfc..cf92312 100644 --- a/dhcp.template +++ b/dhcp.template @@ -36,6 +36,4 @@ shared-network rhndev { } } -# ** leave this line intact $insert_cobbler_system_definitions - |