diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | cobbler/item_image.py | 18 | ||||
-rw-r--r-- | cobbler/modules/cli_image.py | 1 | ||||
-rw-r--r-- | cobbler/pxegen.py | 60 | ||||
-rw-r--r-- | cobbler/settings.py | 4 | ||||
-rw-r--r-- | cobbler/utils.py | 10 | ||||
-rw-r--r-- | config/settings | 5 |
7 files changed, 73 insertions, 27 deletions
@@ -42,6 +42,8 @@ Cobbler CHANGELOG - webui page lookups don't load the full object collection - systems can also inherit from images - changes to PXE images directly +- bootloaders is no longer a config file setting +- we can now look for syslinux in one of two places (/usr/lib, /usr/share) - Wed Jun 03 2008 - 1.0.3 - Fix typo in replicate code diff --git a/cobbler/item_image.py b/cobbler/item_image.py index 20bc994b..2abe248c 100644 --- a/cobbler/item_image.py +++ b/cobbler/item_image.py @@ -47,6 +47,7 @@ class Image(item.Item): self.virt_cpus = 1 self.virt_bridge = self.settings.default_virt_bridge self.owners = self.settings.default_ownership + self.image_type = "iso" # direct, iso, memdisk, virt-clone def from_datastruct(self,seed_data): """ @@ -69,6 +70,8 @@ class Image(item.Item): self.arch = self.load_item(seed_data,'arch','i386') self.xml_file = self.load_item(seed_data, 'xml_file', '') + self.image_type = self.load_item(seed_data, 'image_type', 'iso') + self.set_owners(self.owners) self.set_arch(self.arch) @@ -91,10 +94,22 @@ class Image(item.Item): self.file = filename return True + def set_image_type(self,image_type): + """ + Indicates what type of image this is. + direct = something like "memdisk" + iso = a bootable ISO that pxe's or can be used for virt installs + virt-clone = a cloned virtual disk (FIXME: not yet supported) + """ + if not image_type in [ "direct", "iso", "memdisk", "virt-clone" ]: + raise CX(_("image type must be 'direct', 'iso', or 'virt-clone'")) + self.image_type = image_type + def set_xml_file(self,filename): """ Stores an xmlfile for virt-image. This should be accessible on all nodes that need to access it also. See set_file. + FIXME: not yet supported, just a stub. """ self.xml_file = filename return True @@ -139,6 +154,7 @@ class Image(item.Item): """ return { 'name' : self.name, + 'image type' : self.image_type, 'file' : self.file, 'xml_file' : self.xml_file, 'depth' : 0, @@ -157,6 +173,7 @@ class Image(item.Item): A human readable representaton """ buf = _("image : %s\n") % self.name + buf = buf + _("image type : %s\n") % self.image_type buf = buf + _("arch : %s\n") % self.arch buf = buf + _("file : %s\n") % self.file buf = buf + _("xml file : %s\n") % self.xml_file @@ -173,6 +190,7 @@ class Image(item.Item): def remote_methods(self): return { 'name' : self.set_name, + 'image-type' : self.set_image_type, 'arch' : self.set_arch, 'file' : self.set_file, 'xml_file' : self.set_xml_file, diff --git a/cobbler/modules/cli_image.py b/cobbler/modules/cli_image.py index ca32226c..1f606e23 100644 --- a/cobbler/modules/cli_image.py +++ b/cobbler/modules/cli_image.py @@ -45,6 +45,7 @@ class ImageFunction(commands.CobblerFunction): if not self.matches_args(args,["dumpvars","remove","report","list"]): p.add_option("--file", dest="file", help="common filesystem path to image for all hosts (nfs is good)") + p.add_option("--image-type", dest="image-type", help="what kind of image is this?") if self.matches_args(args,["copy","rename"]): diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py index 81826a14..3eeadcb1 100644 --- a/cobbler/pxegen.py +++ b/cobbler/pxegen.py @@ -62,17 +62,29 @@ class PXEGen: NOTE: we support different arch's if defined in /etc/cobbler/settings. """ - for loader in self.settings.bootloaders.keys(): - path = self.settings.bootloaders[loader] - newname = os.path.basename(path) - destpath = os.path.join(self.bootloc, newname) - utils.copyfile(path, destpath) - utils.copyfile("/var/lib/cobbler/menu.c32", os.path.join(self.bootloc, "menu.c32")) - - # Copy memtest to tftpboot if package is installed on system - for memtest in glob.glob('/boot/memtest*'): - base = os.path.basename(memtest) - utils.copyfile(memtest,os.path.join(self.bootloc,"images",base)) + dst = self.bootloc + + # copy syslinux from one of two locations + try: + utils.copyfile_pattern('/usr/lib/syslinux/pxelinux.0', dst) + except: + utils.copyfile_pattern('/usr/share/syslinux/pxelinux.0', dst) + + # copy memtest only if we find it + utils.copyfile_pattern('/boot/memtest*', dst, require_match=False) + + # copy elilo which we include for IA64 targets + utils.copyfile_pattern('/var/lib/cobbler/elilo-3.6-ia64.efi', dst) + + # copy menu.c32 as the older one has some bugs on certain RHEL + utils.copyfile_pattern('/var/lib/cobbler/menu.c32', dst) + + # copy memdisk as we need it to boot ISOs + try: + utils.copyfile_pattern('/usr/lib/syslinux/memdisk', dst) + except: + utils.copyfile_pattern('/usr/share/syslinux/memdisk', dst) + def copy_distros(self): """ @@ -350,7 +362,15 @@ class PXEGen: # Find the kickstart if we inherit from another profile kickstart_path = utils.blender(self.api, True, profile)["kickstart"] else: - kernel_path = os.path.join("/images2",image.name) + if image.image_type == "direct": + kernel_path = os.path.join("/images2",image.name) + elif image.image_type == "memdisk": + kernel_path = "/memdisk" + initrd_path = os.path.join("/images2",image.name) + else: + # CD-ROM ISO or virt-clone image? We can't PXE boot it. + kernel_path = None + initrd_path = None # --- # choose a template @@ -375,7 +395,7 @@ class PXEGen: # generate the append line hkopts = utils.hash_to_string(kopts) - if arch and not arch == "ia64": + if not arch or arch != "ia64": append_line = "append initrd=%s %s" % (initrd_path, hkopts) else: append_line = "append %s" % hkopts @@ -411,17 +431,23 @@ class PXEGen: elif image: metadata["menu_label"] = "MENU LABEL %s" % image.name metadata["profile_name"] = image.name + if kernel_path is not None: metadata["kernel_path"] = kernel_path if initrd_path is not None: metadata["initrd_path"] = initrd_path + metadata["append_line"] = append_line # get the template - template_fh = open(template) - template_data = template_fh.read() - template_fh.close() - + if kernel_path is not None and initrd_path is not None: + template_fh = open(template) + template_data = template_fh.read() + template_fh.close() + else: + # this is something we can't PXE boot + template_data = "\n" + # save file and/or return results, depending on how called. buffer = self.templar.render(template_data, metadata, None) if filename is not None: diff --git a/cobbler/settings.py b/cobbler/settings.py index 527b3dca..929394fc 100644 --- a/cobbler/settings.py +++ b/cobbler/settings.py @@ -25,10 +25,6 @@ DEFAULTS = { "allow_duplicate_macs" : 0, "allow_duplicate_ips" : 0, "bind_bin" : "/usr/sbin/named", - "bootloaders" : { - "standard" : "/usr/lib/syslinux/pxelinux.0", - "ia64" : "/var/lib/cobbler/elilo-3.6-ia64.efi" - }, "cobbler_master" : '', "default_kickstart" : "/etc/cobbler/default.ks", "default_virt_bridge" : "xenbr0", diff --git a/cobbler/utils.py b/cobbler/utils.py index 3572525c..838b4d2b 100644 --- a/cobbler/utils.py +++ b/cobbler/utils.py @@ -709,7 +709,7 @@ def linkfile(src, dst, require_hardlink=False): pass else: if not os.path.exists(dst): - raise + raise CX(_("Cannot hardlink across devices.")) else: # already exists, FIXME: check for sameness or Errno 17 return True @@ -732,6 +732,14 @@ def copyfile(src,dst): # the file as a symlink/hardlink raise CX(_("Error copying %(src)s to %(dst)s") % { "src" : src, "dst" : dst}) +def copyfile_pattern(pattern,dst,require_match=True): + files = glob.glob(pattern) + if require_match and not len(files) > 0: + raise CX(_("Could not find files matching %s") % pattern) + for file in files: + base = os.path.basename(file) + copyfile(file,os.path.join(dst,os.path.basename(file))) + def rmfile(path): try: os.unlink(path) diff --git a/config/settings b/config/settings index d48e2f4c..485a1fd3 100644 --- a/config/settings +++ b/config/settings @@ -19,11 +19,6 @@ allow_duplicate_ips: 0 # the path to BIND's executable for this distribution. bind_bin: /usr/sbin/named -# where to find various bootloaders on the filesystem -bootloaders: - ia64: /var/lib/cobbler/elilo-3.6-ia64.efi - standard: /usr/lib/syslinux/pxelinux.0 - # if no kickstart is specified, use this template (FIXME) default_kickstart: /etc/cobbler/default.ks |