diff options
author | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-05-24 16:11:55 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-05-24 16:11:55 -0400 |
commit | ca8039d41fe40de1237106571f684408e144d7c8 (patch) | |
tree | 6e3159f21b6bb76ec1a87bef5951e31fa4f12a4e /cobbler | |
parent | 8cbf4c2cf24c79f194d5f66c72fdc8cd9df185a7 (diff) | |
download | third_party-cobbler-ca8039d41fe40de1237106571f684408e144d7c8.tar.gz third_party-cobbler-ca8039d41fe40de1237106571f684408e144d7c8.tar.xz third_party-cobbler-ca8039d41fe40de1237106571f684408e144d7c8.zip |
Change cobbler code to use /etc/ethers and /var/lib/cobbler/cobbler_hosts
for dnsmasq, only writing minimal contents to /etc/dnsmasq.conf --
basically just tagging the systems with weird arches so they get the right
bootloaders. "Cobbler sync" will only need to be run when adding the
systems with the weird arches, and others should be dynamic without need
to SIGHUP (/sbin/service restart) dnsmasq. In theory :)
dnsmasq integration with cobbler is still rather experimental, but looks
solid thus far. Have not actually tested any non-pxelinux.0 arches.
Diffstat (limited to 'cobbler')
-rw-r--r-- | cobbler/action_litesync.py | 2 | ||||
-rw-r--r-- | cobbler/action_sync.py | 55 |
2 files changed, 47 insertions, 10 deletions
diff --git a/cobbler/action_litesync.py b/cobbler/action_litesync.py index 825bcbe..c08690b 100644 --- a/cobbler/action_litesync.py +++ b/cobbler/action_litesync.py @@ -97,6 +97,8 @@ class BootLiteSync: if system is None: raise cexceptions.CobblerException("error in system lookup") # rebuild system_list file in webdir + self.sync.regen_ethers() # /etc/ethers, for dnsmasq & rarpd + self.sync.regen_hosts() # /var/lib/cobbler/cobbler_hosts, pretty much for dnsmasq self.sync.write_listings() # write the PXE and YAML files for the system self.sync.write_all_system_files(system) diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py index e6225c7..d263aa3 100644 --- a/cobbler/action_sync.py +++ b/cobbler/action_sync.py @@ -69,6 +69,8 @@ class BootSync: if self.settings.manage_dhcp: # these functions DRT for ISC or dnsmasq self.write_dhcp_file() + self.regen_ethers() + self.regen_hosts() self.restart_dhcp() self.make_pxe_menu() return True @@ -171,28 +173,61 @@ class BootSync: systxt = systxt + " fixed-address %s;\n" % system.pxe_address systxt = systxt + " next-server %s;\n" % self.settings.next_server systxt = systxt + "}\n" - system_definitions = system_definitions + systxt else: - # dnsmasq. dnsmasq also allows for setting hostnames. Neat. - - systxt = systxt + "dhcp-host=" + system.name + # dnsmasq. don't have to write IP and other info here, but we do tag + # each MAC based on the arch of it's distro, if it needs something other + # than pxelinux.0 -- for these arches, and these arches only, a dnsmasq + # reload (full "cobbler sync") would be required after adding the system + # to cobbler, just to tag this relationship. + + profile = self.profiles.find(system.profile) + distro = self.distros.find(profile.distro) if system.pxe_address != "": - systxt = systxt + "," + system.pxe_address - if system.hostname != "": - systxt = systxt + "," + system.hostname + ",infinite" - systxt = systxt + "\n" + if distro.arch.lower() == "ia64": + systxt = "dhcp-host=net:ia64," + system.pxe_address + "\n" + # support for other arches needs modifications here + else: + systxt = "" system_definitions = system_definitions + systxt metadata = { "insert_cobbler_system_definitions" : system_definitions, - "date" : time.asctime(time.gmtime()), - "next_server" : self.settings.next_server + "date" : time.asctime(time.gmtime()), + "cobbler_server" : self.settings.server, + "next_server" : self.settings.next_server, + "elilo" : elilo } # print "writing to: %s" % settings_file self.apply_template(template_data, metadata, settings_file) + def regen_ethers(self): + # dnsmasq knows how to read this database of MACs -> IPs, so we'll keep it up to date + # every time we add a system. + # read 'man ethers' for format info + fh = open("/etc/ethers","w+") + for sys in self.systems: + if not utils.is_mac(sys.name): + # hopefully no one uses non-mac system ID's anymore, but I'm not sure. + # these need to be deprecated + continue + if sys.pxe_address != "": + fh.write(sys.name.upper() + "\t" + sys.pxe_address + "\n") + fh.close() + + def regen_hosts(self): + # dnsmasq knows how to read this database for host info + # (other things may also make use of this later) + fh = open("/var/lib/cobbler/cobbler_hosts","w+") + for sys in self.systems: + if not utils.is_mac(sys.name): + continue + if sys.hostname != "" and sys.pxe_address != "": + fh.write(sys.pxe_address + "\t" + sys.hostname + "\n") + fh.close() + + def templatify(self, data, metadata, outfile): for x in metadata.keys(): template_data = template_data.replace("$%s" % x, metadata[x]) |