[Et-mgmt-commits-list] [SCM] cobbler branch, master now at v0.4.7-16-gca8039d

Michael DeHaan mdehaan at redhat.com
Thu May 24 20:10:41 UTC 2007


Hello,

This is an automated email from the git hooks/update script, it was
generated because a ref change was pushed to the repository.

Updating branch, master,
       via  ca8039d41fe40de1237106571f684408e144d7c8 (commit)
      from  8cbf4c2cf24c79f194d5f66c72fdc8cd9df185a7 (commit)

- Log -----------------------------------------------------------------
commit ca8039d41fe40de1237106571f684408e144d7c8
Author: Michael DeHaan <mdehaan at mdehaan.rdu.redhat.com>
Date:   Thu May 24 16:11:55 2007 -0400

    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:
 cobbler/action_litesync.py |    2 +
 cobbler/action_sync.py     |   55 ++++++++++++++++++++++++++++++++++++--------
 templates/dnsmasq.template |   12 +++++----
 3 files changed, 54 insertions(+), 15 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])
diff --git a/templates/dnsmasq.template b/templates/dnsmasq.template
index 17a4a85..0646b71 100644
--- a/templates/dnsmasq.template
+++ b/templates/dnsmasq.template
@@ -3,16 +3,18 @@
 #
 
 # resolve.conf .. ?
-no-poll
+#no-poll
+#enable-dbus
+read-ethers
+addn-hosts = /var/lib/cobbler/hosts_cobbler/
 
 dhcp-range=192.168.1.5,192.168.1.200
 dhcp-option=3,$next_server
-dhcp-boot=pxelinux.0
 dhcp-lease-max=1000
 dhcp-authoritative
-
-# FYI: using tftp-server for TFTP ...
-
+dhcp-boot=pxelinux.0
+dhcp-boot=net:normalarch,pxelinux.0
+dhcp-boot=net:ia64,$elilo
 
 $insert_cobbler_system_definitions
 

hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
  8cbf4c2cf24c79f194d5f66c72fdc8cd9df185a7 \
  ca8039d41fe40de1237106571f684408e144d7c8




More information about the Et-mgmt-commits-list mailing list