summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG6
-rw-r--r--cobbler.spec5
-rw-r--r--cobbler/action_check.py23
-rw-r--r--cobbler/action_import.py2
-rw-r--r--cobbler/action_sync.py79
-rwxr-xr-xcobbler/cobbler.py4
-rw-r--r--cobbler/cobbler_msg.py6
-rw-r--r--cobbler/item_system.py16
-rw-r--r--cobbler/settings.py3
-rw-r--r--docs/cobbler.pod58
-rw-r--r--setup.py1
11 files changed, 143 insertions, 60 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2148b30..b59549b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,10 +1,12 @@
Cobbler CHANGELOG
(all entries mdehaan@redhat.com unless noted otherwise)
-* Fri Apr 27 2007 - 0.4.9
+* Thu May 24 2007 - 0.4.9
- Remove hardcode of /var/www/cobbler in cobblerd
-- Fix warning message error for "cobbler check" and /etc/dhcpd.conf
+- Improve various warning warning messages
- cobbler (objecttype) (objectname) now gives info about the object instead of just all objects
+- Added --hostname to "cobbler system add", --ip-address is also a better alias for --pxe-address
+- Optionally use dnsmasq for DHCP (and DNS!) instead of ISC dhcpd.
* Thu Apr 26 2007 - 0.4.8
- Make import friendlier for older distros
diff --git a/cobbler.spec b/cobbler.spec
index dd62411..35a819c 100644
--- a/cobbler.spec
+++ b/cobbler.spec
@@ -93,6 +93,7 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%config(noreplace) /etc/cobbler/kickstart_fc6.ks
%config(noreplace) /etc/cobbler/kickstart_fc6_domU.ks
%config(noreplace) /etc/cobbler/dhcp.template
+%config(noreplace) /etc/cobbler/dnsmasq.template
%config(noreplace) /etc/cobbler/pxedefault.template
%config(noreplace) /etc/cobbler/pxeprofile.template
%config(noreplace) /etc/cobbler/pxesystem.template
@@ -124,6 +125,10 @@ test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%changelog
+* Thr May 24 2007 Michael DeHaan <mdehaan@redhat.com> - 0.4.9-1
+- Upstream changes (see CHANGELOG)
+- Added dnsmasq.template
+
* Fri Apr 27 2007 Michael DeHaan <mdehaan@redhat.com> - 0.4.9-1
- Upstream changes (see CHANGELOG)
diff --git a/cobbler/action_check.py b/cobbler/action_check.py
index f35b2a5..49ba174 100644
--- a/cobbler/action_check.py
+++ b/cobbler/action_check.py
@@ -35,12 +35,20 @@ class BootCheck:
"""
status = []
self.check_name(status)
- self.check_dhcpd_bin(status)
+ if self.settings.manage_dhcp:
+ mode = self.settings.manage_dhcp_mode.lower()
+ if mode == "isc":
+ self.check_dhcpd_bin(status)
+ self.check_dhcpd_conf(status)
+ elif mode == "dnsmasq":
+ self.check_dnsmasq_bin(status)
+ else:
+ status.append(cobbler_msg.lookup("dhcp_choice"))
+
self.check_bootloaders(status)
self.check_tftpd_bin(status)
self.check_tftpd_dir(status)
self.check_tftpd_conf(status)
- self.check_dhcpd_conf(status)
self.check_httpd(status)
return status
@@ -61,7 +69,7 @@ class BootCheck:
Check if Apache is installed.
"""
if not os.path.exists(self.settings.httpd_bin):
- status.append(cobbler_msg.lookup("no_httpd"))
+ status.append(cobbler_msg.lookup("no_httpd"))
def check_dhcpd_bin(self,status):
@@ -69,7 +77,14 @@ class BootCheck:
Check if dhcpd is installed
"""
if not os.path.exists(self.settings.dhcpd_bin):
- status.append(cobbler_msg.lookup("no_dhcpd"))
+ status.append(cobbler_msg.lookup("no_dhcpd"))
+
+ def check_dnsmasq_bin(self,status):
+ """
+ Check if dnsmasq is installed
+ """
+ if not os.path.exists(self.settings.dnsmasq_bin):
+ status.append(cobbler_msg.lookup("no_dnsmasq"))
def check_bootloaders(self,status):
"""
diff --git a/cobbler/action_import.py b/cobbler/action_import.py
index a01128d..cd623a0 100644
--- a/cobbler/action_import.py
+++ b/cobbler/action_import.py
@@ -270,7 +270,7 @@ class Importer:
def repo_scanner(self,distro,dirname,fnames):
for x in fnames:
- if x == "repodata" or x == "base":
+ if x == "base": # don't do "repodata"
self.process_comps_file(dirname, distro)
continue
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 2af7dd1..e6225c7 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -67,6 +67,7 @@ class BootSync:
self.validate_kickstarts()
self.build_trees()
if self.settings.manage_dhcp:
+ # these functions DRT for ISC or dnsmasq
self.write_dhcp_file()
self.restart_dhcp()
self.make_pxe_menu()
@@ -75,14 +76,19 @@ class BootSync:
def restart_dhcp(self):
"""
DHCP restarts need to be made when the config file is
- changed.
+ changed. ISC or DNSMASQ. Support for ISC omshell not
+ yet available (adding dynamically w/o restart).
"""
try:
- retcode = self.service("dhcpd", "restart")
+ mode = self.settings.manage_dhcp_mode.lower()
+ service = "dhcpd"
+ if mode == "dnsmasq":
+ service = "dnsmasq"
+ retcode = self.service(service, "restart")
if retcode != 0:
- print >>sys.stderr, "Warning: dhcpd restart failed"
+ print >>sys.stderr, "Warning: %s restart failed" % service
except OSError, e:
- print >>sys.stderr, "Warning: dhcpd restart failed: ", e
+ print >>sys.stderr, "Warning: %s restart failed: " % service, e
def copy_koan(self):
"""
@@ -111,25 +117,35 @@ class BootSync:
self.copyfile(path, destpath)
self.copyfile("/var/lib/cobbler/menu.c32", os.path.join(self.settings.tftpboot, "menu.c32"))
-
def write_dhcp_file(self):
"""
DHCP files are written when manage_dhcp is set in
/var/lib/cobbler/settings.
"""
+
+ settings_file = self.settings.dhcpd_conf
+ template_file = "/etc/cobbler/dhcp.template"
+ mode = self.settings.manage_dhcp_mode.lower()
+ # print "my mode is: %s" % mode
+ if mode == "dnsmasq":
+ settings_file = self.settings.dnsmasq_conf
+ template_file = "/etc/cobbler/dnsmasq.template"
+
try:
- f2 = open("/etc/cobbler/dhcp.template","r")
+ f2 = open(template_file,"r")
except:
- raise cexceptions.CobblerException("exc_no_template")
+ raise cexceptions.CobblerException("exc_no_template",template_file)
template_data = ""
- #f1 = self.open_file("/etc/dhcpd.conf","w+")
template_data = f2.read()
f2.close()
# build each per-system definition
+ # as configured, this only works for ISC, patches accepted
+ # from those that care about Itanium.
+ elilo = os.path.basename(self.settings.bootloaders["ia64"])
+
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
@@ -138,19 +154,35 @@ class BootSync:
# 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
- profile = self.profiles.find(system.profile)
- distro = self.distros.find(profile.distro)
- if distro.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_address != "":
- systxt = systxt + " fixed-address %s;\n" % system.pxe_address
- systxt = systxt + " next-server %s;\n" % self.settings.next_server
- systxt = systxt + "}\n"
+ systxt = ""
+ if mode == "isc":
+
+ systxt = "\nhost label%d {\n" % counter
+ profile = self.profiles.find(system.profile)
+ distro = self.distros.find(profile.distro)
+ if distro.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_address != "":
+ 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
+ if system.pxe_address != "":
+ systxt = systxt + "," + system.pxe_address
+ if system.hostname != "":
+ systxt = systxt + "," + system.hostname + ",infinite"
+ systxt = systxt + "\n"
+
system_definitions = system_definitions + systxt
metadata = {
@@ -158,9 +190,8 @@ class BootSync:
"date" : time.asctime(time.gmtime()),
"next_server" : self.settings.next_server
}
- self.apply_template(template_data, metadata, "/etc/dhcpd.conf")
- #self.tee(f1,template_data)
- #self.close_file(f1)
+ # print "writing to: %s" % settings_file
+ self.apply_template(template_data, metadata, settings_file)
def templatify(self, data, metadata, outfile):
for x in metadata.keys():
diff --git a/cobbler/cobbler.py b/cobbler/cobbler.py
index f8d3f53..77e8a81 100755
--- a/cobbler/cobbler.py
+++ b/cobbler/cobbler.py
@@ -448,7 +448,9 @@ class BootCLI:
'--profile' : lambda(a) : sys.set_profile(a),
'--kopts' : lambda(a) : sys.set_kernel_options(a),
'--ksmeta' : lambda(a) : sys.set_ksmeta(a),
- '--pxe-address' : lambda(a) : sys.set_pxe_address(a)
+ '--hostname' : lambda(a) : sys.set_hostname(a),
+ '--pxe-address' : lambda(a) : sys.set_ip_address(a),
+ '--ip-address' : lambda(a) : sys.set_ip_address(a)
}
def on_ok():
self.api.systems().add(sys, with_copy=self.api.sync_flag)
diff --git a/cobbler/cobbler_msg.py b/cobbler/cobbler_msg.py
index 121d70e..d9f3183 100644
--- a/cobbler/cobbler_msg.py
+++ b/cobbler/cobbler_msg.py
@@ -78,8 +78,10 @@ _msg_table = {
"need_perms" : "cobbler could not access %s",
"need_perms2" : "cobbler could not copy %s to %s",
"no_dhcpd" : "cobbler couldn't find dhcpd, try 'yum install dhcp'",
+ "no_dnsmasq" : "cobbler couldn't find dnsmasq, try 'yum install dnsmasq'",
+ "dhcp_choice" : "manage_dhcp_mode in /var/lib/cobbler/settings should be 'isc' or 'dnsmasq'",
"no_bootloader" : "missing 1 or more bootloader files listed in /var/lib/cobbler/settings",
- "no_tftpd" : "cobbler couldn't find tftpd, try 'yum install tftpd'",
+ "no_tftpd" : "cobbler couldn't find tftpd, try 'yum install tftpd-server'",
"no_dir" : "cobbler couldn't find %s, please create it",
"no_mirror" : "mirror URL is not valid",
"chg_attrib" : "need to change field '%s' value to '%s' in file '%s'",
@@ -124,7 +126,7 @@ _msg_table = {
"exc_profile" : "invalid profile name",
"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_no_template" : "can't read template file (%s)",
"exc_dhcp_nomac" : "when cobbler is managing dhcpd.conf, all system names must be MAC addresses. Aborting.",
"exc_ia64_noip" : "due to an IA64 bootloader limitation, system (%s) must define a pxe-address value (which is an IP address)",
"exc_kopts" : "Kernel options should be a space delimited list of values and key=value pairs",
diff --git a/cobbler/item_system.py b/cobbler/item_system.py
index 53cc979..e481097 100644
--- a/cobbler/item_system.py
+++ b/cobbler/item_system.py
@@ -35,6 +35,7 @@ class System(item.Item):
self.ks_meta = {}
self.pxe_address = ""
self.netboot_enabled = 1
+ self.hostname = ""
def from_datastruct(self,seed_data):
self.name = self.load_item(seed_data, 'name')
@@ -43,6 +44,7 @@ class System(item.Item):
self.ks_meta = self.load_item(seed_data, 'ks_meta')
self.pxe_address = self.load_item(seed_data, 'pxe_address')
self.netboot_enabled = self.load_item(seed_data, 'netboot_enabled', 1)
+ self.hostname = self.load_item(seed_data, 'hostname')
# backwards compatibility -- convert string entries to dicts for storage
if type(self.kernel_options) != dict:
@@ -67,6 +69,14 @@ class System(item.Item):
self.name = name # we check it add time, but store the original value.
return True
+ def set_hostname(self,hostname):
+ self.hostname = hostname
+ return True
+
+ def set_ip_address(self,address):
+ # allow function to use more sensical name
+ return self.set_pxe_address(address)
+
def set_pxe_address(self,address):
"""
Assign a IP or hostname in DHCP when this MAC boots.
@@ -128,7 +138,8 @@ class System(item.Item):
'kernel_options' : self.kernel_options,
'ks_meta' : self.ks_meta,
'pxe_address' : self.pxe_address,
- 'netboot_enabled' : self.netboot_enabled
+ 'netboot_enabled' : self.netboot_enabled,
+ 'hostname' : self.hostname,
}
def printable(self):
@@ -136,6 +147,7 @@ class System(item.Item):
buf = buf + "profile : %s\n" % self.profile
buf = buf + "kernel options : %s\n" % self.kernel_options
buf = buf + "ks metadata : %s\n" % self.ks_meta
- buf = buf + "pxe address : %s\n" % self.pxe_address
+ buf = buf + "ip address : %s\n" % self.pxe_address
+ buf = buf + "hostname : %s\n" % self.hostname
return buf
diff --git a/cobbler/settings.py b/cobbler/settings.py
index 2aa421b..58995a4 100644
--- a/cobbler/settings.py
+++ b/cobbler/settings.py
@@ -20,10 +20,12 @@ TESTMODE = False
DEFAULTS = {
"httpd_bin" : "/usr/sbin/httpd",
"dhcpd_conf" : "/etc/dhcpd.conf",
+ "dnsmasq_conf" : "/etc/dnsmasq.conf",
"tftpd_bin" : "/usr/sbin/in.tftpd",
"server" : "127.0.0.1",
"next_server" : "127.0.0.1",
"dhcpd_bin" : "/usr/sbin/dhcpd",
+ "dnsmasq_bin" : "/usr/sbin/dnsmasq",
"kernel_options" : {
"lang" : " ",
"text" : None,
@@ -34,6 +36,7 @@ DEFAULTS = {
"webdir" : "/var/www/cobbler",
"default_kickstart" : "/etc/cobbler/default.ks",
"manage_dhcp" : 0,
+ "manage_dhcp_mode" : "isc",
"koan_path" : "",
"bootloaders" : {
"standard" : "/usr/lib/syslinux/pxelinux.0",
diff --git a/docs/cobbler.pod b/docs/cobbler.pod
index a375c31..5f5ea98 100644
--- a/docs/cobbler.pod
+++ b/docs/cobbler.pod
@@ -141,7 +141,7 @@ can make use of during kickstart installation. For example, an example might be
Systems assign a piece of hardware with the cobbler profile to be assigned to it. Systems can be defined by hostname, IP, or MAC address. When available, use of the MAC address to assign systems is preferred.
-B<cobbler system add --name=ip|mac|hostname --profile=string [--kopts=string] [--pxe-address=string] [--ksmeta=string]>
+B<cobbler system add --name=macaddress --profile=string [--kopts=string] [--ipaddress=string] [--hostname=string] [--ksmeta=string]>
Adds a cobbler System to the configuration. Arguments are specified as per "profile add" with
the following changes:
@@ -159,20 +159,25 @@ address here, as it makes things a lot easier and more powerful across the board
There is also the magic name "default", which allows creation of the default PXE profile. Without
a "default" system name created, PXE will fall through to local boot for unconfigured systems.
-=item pxe-address
+=item ip-address
-Advanced feature.
+If cobbler is configured to generate to manage a DHCP configuratition (see advanced section), use this
+setting to pin a certain IP to a given MAC address. This corresponds to the "fixed-address" field in dhcpd.conf.
-If cobbler is configured to generate the dhcpd.conf file, use this
-setting to pin a certain hostname or IP to a given MAC address. This corresponds to the "fixed-address" field in dhcpd.conf.
+Example: ---ip-address=192.168.1.50
-When using this setting for IA64 machines, 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.
+Note for Itanium users: For this to work with IA64 systems, currently ISC dhcpd must be chosen as the DHCP server. Even if no cobbler DHCP management is enabled, this parameter is mandatory to get cobbler systems to PXE boot, due to limitations in ELILO (it doesn't request config files based on MAC addresses).
-Example: ---pxe-address=192.168.1.50
+=back
-NOTE: Due to a limitation in elilo (IA64 bootloader), this parameter must ALSO be used even if dhcpd.conf files are not being managed by cobbler AND you want to PXE provision IA64 systems using a handwritten dhcpd.conf. Also, for IA64, the value of pxe-address must be an IP, and not a hostname, even though hostnames work for X86. Thankfully, if you don't have IA64 systems, there are a lot less rules.
+=item hostname
-=back
+If using the DHCP configuration feature (see advanced section), use this to pin a hostname to a particular
+system record. Currently this only works when 'manage_dhcp_mode' is set to 'dnsmasq' and not for 'isc'.
+
+Example: --hostname=mycomputer.example.com
+
+=end
=head2 ADDING A REPOSITORY TO MIRROR
@@ -421,27 +426,32 @@ Should you want to express larger sections of templating (more that can be decen
=head2 DHCP CONFIGURATION MANAGEMENT
-By default, cobbler does not write a dhcpd.conf and leaves configuration
-of DHCP up to the user. If manage_dhcp is set to 1 in /var/lib/cobbler/settings,
-this changes, and cobbler *will* write it's own dhcp.conf file, replacing any dhcpd.conf
-that already exists.
+Cobbler can optionally help you manage DHCP and (depending on how used) DNS as it relates
+to systems you wish to provision/control. This allows cobbler to essentially maintain a database
+of all of your installed systems, and be a central point of control for aspects related to setting
+up those systems.
-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 you already have dhcpd.conf data that you would like to preserve (say DHCP was manually configured earlier),
-insert the relevant portions of it into the template file.
+This feature is off by default and must be turned on by setting 'manage_dhcp' to 1 in
+/var/lib/cobbler/settings. Choices include ISC dhcpd (default), or DNSmasq, which can be chosen
+by setting manage_dhcp_mode to 'dnsmasq'. If you choose dnsmasq and want to revert to ISC, change
+the setting to 'isc'.
-So, if this manage_dhcp bit is enabled, the following features are enabled:
+Depending on your choice, cobbler will use /etc/cobbler/dhcpd.template or /etc/cobbler/dnsmasq.template as a starting point. This file must be user edited for the user's particular networking environment. Read the file and understand how the particular app (ISC dhcpd or dnsmasq) work before proceeding.
+
+If you already have DHCP configuration data that you would like to preserve (say DHCP was manually configured earlier), insert the relevant portions of it into the template file, as running "cobbler sync" will overwrite your previous configuration.
+
+In summary, if this manage_dhcp bit is enabled, the following features are enabled:
(A) pinning dhcp hostnames to MAC addresses automatically.
-(B) relatively seamless mixing of Itanium and x86/x86_64 machines in a PXE environment
+(B) relatively seamless mixing of Itanium and x86/x86_64 machines in a PXE environment (ISC only)
+(C) assigning hostnames to MAC addresses using DNS (dnsmasq only).
-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.
+These options are all enabled by using the --hostname and --ip-address options when using the "cobbler system add" command.
-Itanium systems names also need to be specified by the MAC address, and their distribution needs to be created with the "--arch=ia64" parameter.
+Itanium systems names also need to be assigned to a distro that was created with the "--arch=ia64" parameter. If you have Itanium systems, you must (for now) choose 'isc' for
+'manage_dhcp_mode' in the /var/lib/cobbler/settings file, and are required to use --ip-address when creating the system object in order for those systems to PXE.
-The dhcpd.conf file will be updated each time "cobbler sync" is run, and not until then, so it is important
-to remember to use "cobbler sync" when using this feature.
+The dhcpd.conf file will be updated each time "cobbler sync" is run, and not until then, so it is important to remember to use "cobbler sync" when using this feature. Support for online updates to DHCP (and DNS, in this dnsmasq case) are pending.
=head2 ENCHANT
@@ -461,7 +471,6 @@ Example: B<cobbler enchant --virt=yes --address=192.168.10.10 --profile=fc6xen>
Before using enchant, configure the location of the koan noarch RPM in /var/lib/cobbler/settings (a local path) and re-run "cobbler sync".
-
=head2 IMPORTING TREES
Cobbler can auto-add distributions and profiles from remote sources, whether this is a filesystem path or an rsync mirror. This can save a lot of time when setting up a new provisioning environment.
@@ -572,6 +581,7 @@ When adding a distro, profile, system, or repo, all scripts in /var/lib/cobbler/
=head2 API
Cobbler also makes itself available as a Python API for use by higher level management software.
+Learn more at http://cobbler.et.redhat.com
=head1 EXIT_STATUS
diff --git a/setup.py b/setup.py
index 0abb52c..b8a716e 100644
--- a/setup.py
+++ b/setup.py
@@ -55,6 +55,7 @@ if __name__ == "__main__":
(etcpath, ['kickstarts/kickstart_fc6_domU.ks']),
(etcpath, ['kickstarts/default.ks']),
(etcpath, ['templates/dhcp.template']),
+ (etcpath, ['templates/dnsmasq.template']),
(etcpath, ['templates/pxedefault.template']),
(etcpath, ['templates/pxesystem.template']),
(etcpath, ['templates/pxesystem_ia64.template']),