Blame SOURCES/cobbler-buildiso.patch

1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/action_buildiso.py cobbler-2.0.7-new/cobbler/action_buildiso.py
1070a0
--- cobbler-2.0.7-orig/cobbler/action_buildiso.py	2013-05-22 15:00:28.213867934 -0400
1070a0
+++ cobbler-2.0.7-new/cobbler/action_buildiso.py	2013-07-11 15:35:59.637378396 -0400
1070a0
@@ -86,7 +86,7 @@ class BuildIso:
1070a0
             return str(self.distctr)
1070a0
1070a0
   
1070a0
-    def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,exclude_dns=None):
1070a0
+    def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,exclude_dns=None,force_server=None):
1070a0
         self.logger.info("copying kernels and initrds for profiles")
1070a0
         # copy all images in included profiles to images dir
1070a0
         for profile in self.api.profiles():
1070a0
@@ -152,6 +152,8 @@ class BuildIso:
1070a0
                 if dist.name.find("-xen") != -1:
1070a0
                     continue
1070a0
                 data = utils.blender(self.api, True, profile)
1070a0
+                if force_server:
1070a0
+                    data["server"] = force_server
1070a0
                 distname = self.make_shorter(dist.name)
1070a0
1070a0
                 cfg.write("\n")
1070a0
@@ -164,6 +166,12 @@ class BuildIso:
1070a0
                         data["server"],
1070a0
                         profile.name
1070a0
                     )
1070a0
+                else:
1070a0
+                    if force_server:
1070a0
+                        # replace configured hostname with the forced one
1070a0
+                        data["kickstart"] = re.sub(r'://.*?/',
1070a0
+                                '://' + data["server"] + '/',
1070a0
+                                data["kickstart"])
1070a0
1070a0
                 append_line = "  append initrd=%s.img" % distname
1070a0
                 append_line = append_line + " ks=%s " % data["kickstart"]
1070a0
@@ -199,6 +207,8 @@ class BuildIso:
1070a0
                    if dist.name.find("-xen") != -1:
1070a0
                        continue
1070a0
                    data = utils.blender(self.api, True, system)
1070a0
+                   if force_server:
1070a0
+                       data["server"] = force_server
1070a0
                    distname = self.make_shorter(dist.name)
1070a0
1070a0
                    cfg.write("\n")
1070a0
@@ -211,6 +221,12 @@ class BuildIso:
1070a0
                            data["server"],
1070a0
                            system.name
1070a0
                        )
1070a0
+                   else:
1070a0
+                       if force_server:
1070a0
+                           # replace configured hostname with the forced one
1070a0
+                           data["kickstart"] = re.sub(r'://.*?/',
1070a0
+                                   '://' + data["server"] + '/',
1070a0
+                                   data["kickstart"])
1070a0
1070a0
                    append_line = "  append initrd=%s.img" % distname
1070a0
                    append_line = append_line + " ks=%s" % data["kickstart"]
1070a0
@@ -352,7 +368,7 @@ class BuildIso:
1070a0
         return
1070a0
 
1070a0
 
1070a0
-    def run(self,iso=None,tempdir=None,profiles=None,systems=None,distro=None,standalone=None,source=None,exclude_dns=None):
1070a0
+    def run(self,iso=None,tempdir=None,profiles=None,systems=None,distro=None,standalone=None,source=None,exclude_dns=None,force_server=None):
1070a0
1070a0
         # the distro option is for stand-alone builds only
1070a0
         if not standalone and distro is not None:
1070a0
@@ -372,7 +388,7 @@ class BuildIso:
1070a0
             iso = "kickstart.iso"
1070a0
1070a0
         if tempdir is None:
1070a0
-            tempdir = os.path.join(os.getcwd(), "buildiso")
1070a0
+            tempdir = self.config.settings().buildisodir
1070a0
         else:
1070a0
             if not os.path.isdir(tempdir):
1070a0
                 utils.die(self.logger,"The --tempdir specified is not a directory")
1070a0
@@ -415,14 +431,15 @@ class BuildIso:
1070a0
         files = [ isolinuxbin, menu, chain ]
1070a0
         for f in files:
1070a0
             if not os.path.exists(f):
1070a0
-               utils.die(self.logger,"Required file not found: %s" % f)
1070a0
+                self.logger.error("Required file not found: %s. Try 'yum install cobbler-loaders'." % f)
1070a0
+                return False
1070a0
             else:
1070a0
                utils.copyfile(f, os.path.join(isolinuxdir, os.path.basename(f)), self.api)
1070a0
1070a0
         if standalone:
1070a0
             self.generate_standalone_iso(imagesdir,isolinuxdir,distro,source)
1070a0
         else:
1070a0
-            self.generate_netboot_iso(imagesdir,isolinuxdir,profiles,systems,exclude_dns)
1070a0
+            self.generate_netboot_iso(imagesdir,isolinuxdir,profiles,systems,exclude_dns,force_server)
1070a0
1070a0
         # removed --quiet
1070a0
         cmd = "mkisofs -o %s -r -b isolinux/isolinux.bin -c isolinux/boot.cat" % iso
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/action_check.py cobbler-2.0.7-new/cobbler/action_check.py
1070a0
--- cobbler-2.0.7-orig/cobbler/action_check.py	2013-05-22 15:00:28.210867913 -0400
1070a0
+++ cobbler-2.0.7-new/cobbler/action_check.py	2013-07-11 14:41:26.976177891 -0400
1070a0
@@ -325,7 +325,7 @@ class BootCheck:
1070a0
           missing = True
1070a0
1070a0
        if missing:
1070a0
-          status.append("some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'cobbler get-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'cobbler get-loaders' command is the easiest way to resolve these requirements.")
1070a0
+          status.append("some network boot-loaders are missing from /var/lib/cobbler/loaders, you may run 'yum install cobbler-loaders' to download them, or, if you only want to handle x86/x86_64 netbooting, you may ensure that you have installed a *recent* version of the syslinux package installed and can ignore this message entirely.  Files in this directory, should you want to support all architectures, should include pxelinux.0, menu.c32, elilo.efi, and yaboot. The 'yum install cobbler-loaders' command is the easiest way to resolve these requirements.")
1070a0
  
1070a0
    def check_tftpd_bin(self,status):
1070a0
        """
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/action_dlcontent.py cobbler-2.0.7-new/cobbler/action_dlcontent.py
1070a0
--- cobbler-2.0.7-orig/cobbler/action_dlcontent.py	2013-05-22 15:00:28.209867906 -0400
1070a0
+++ cobbler-2.0.7-new/cobbler/action_dlcontent.py	2013-07-11 14:41:26.976177891 -0400
1070a0
@@ -39,36 +39,11 @@ class ContentDownloader:
1070a0
1070a0
    def run(self,force=False):
1070a0
        """
1070a0
-       Download bootloader content for all of the latest bootloaders, since the user
1070a0
-       has chosen to not supply their own.  You may ask "why not get this from yum", though
1070a0
-       Fedora has no IA64 repo, for instance, and we also want this to be able to work on Debian and
1070a0
-       further do not want folks to have to install a cross compiler.  For those that don't like this approach
1070a0
-       they can still source their cross-arch bootloader content manually.
1070a0
+       This action used to download the bootloaders from fedorapeople.org,
1070a0
+       however these files are now available from yum in the cobbler-loaders
1070a0
+       package so you should use that instead.
1070a0
        """
1070a0
1070a0
-       content_server = "http://mdehaan.fedorapeople.org/loaders"
1070a0
-       dest = "/var/lib/cobbler/loaders"
1070a0
-
1070a0
-       files = (
1070a0
-          ( "%s/README" % content_server, "%s/README" % dest ),
1070a0
-          ( "%s/COPYING.elilo" % content_server, "%s/COPYING.elilo" % dest ),
1070a0
-          ( "%s/COPYING.yaboot" % content_server, "%s/COPYING.yaboot" % dest),
1070a0
-          ( "%s/COPYING.syslinux" % content_server, "%s/COPYING.syslinux" % dest),
1070a0
-          ( "%s/elilo-3.8-ia64.efi" % content_server, "%s/elilo-ia64.efi" % dest ),
1070a0
-          ( "%s/yaboot-1.3.14-12" % content_server, "%s/yaboot" % dest),
1070a0
-          ( "%s/pxelinux.0-3.61" % content_server, "%s/pxelinux.0" % dest),
1070a0
-          ( "%s/menu.c32-3.61" % content_server, "%s/menu.c32" % dest),
1070a0
-       )
1070a0
-
1070a0
-       self.logger.info("downloading content required to netboot all arches")
1070a0
-       for f in files:
1070a0
-          src = f[0]
1070a0
-          dst = f[1]
1070a0
-          if os.path.exists(dst) and not force:
1070a0
-             self.logger.info("path %s already exists, not overwriting existing content, use --force if you wish to update" % dst)
1070a0
-             continue
1070a0
-          self.logger.info("downloading %s to %s" % (src,dst))
1070a0
-          urlgrabber.urlgrab(src,dst)
1070a0
-
1070a0
-       return True
1070a0
+       self.logger.info("The 'cobbler get-loaders' command has been obsoleted with 'yum install cobbler-loaders' in this version of cobbler. Please use 'yum install cobbler-loaders' instead.")
1070a0
+       return False
1070a0
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/api.py cobbler-2.0.7-new/cobbler/api.py
1070a0
--- cobbler-2.0.7-orig/cobbler/api.py	2013-05-22 15:00:28.214867942 -0400
1070a0
+++ cobbler-2.0.7-new/cobbler/api.py	2013-07-11 14:41:26.977177897 -0400
1070a0
@@ -750,10 +750,10 @@ class BootAPI:
1070a0
1070a0
     # ==========================================================================
1070a0
1070a0
-    def build_iso(self,iso=None,profiles=None,systems=None,tempdir=None,distro=None,standalone=None,source=None, exclude_dns=None, logger=None):
1070a0
+    def build_iso(self,iso=None,profiles=None,systems=None,tempdir=None,distro=None,standalone=None,source=None, exclude_dns=None, logger=None, force_server=None):
1070a0
         builder = action_buildiso.BuildIso(self._config, logger=logger)
1070a0
         return builder.run(
1070a0
-           iso=iso, profiles=profiles, systems=systems, tempdir=tempdir, distro=distro, standalone=standalone, source=source, exclude_dns=exclude_dns
1070a0
+           iso=iso, profiles=profiles, systems=systems, tempdir=tempdir, distro=distro, standalone=standalone, source=source, exclude_dns=exclude_dns, force_server=force_server
1070a0
         )
1070a0
1070a0
     # ==========================================================================
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/cli.py cobbler-2.0.7-new/cobbler/cli.py
1070a0
--- cobbler-2.0.7-orig/cobbler/cli.py	2013-05-22 15:00:28.212867927 -0400
1070a0
+++ cobbler-2.0.7-new/cobbler/cli.py	2013-07-12 15:18:14.024502192 -0400
1070a0
@@ -29,6 +29,7 @@ import time
1070a0
 import os
1070a0
1070a0
 import utils
1070a0
+import config
1070a0
 import module_loader
1070a0
 import item_distro
1070a0
 import item_profile
1070a0
@@ -311,16 +312,17 @@ class BootCLI:
1070a0
         task_id = -1 # if assigned, we must tail the logfile
1070a0
1070a0
         if action_name == "buildiso":
1070a0
-
1070a0
-            defaultiso = os.path.join(os.getcwd(), "generated.iso")
1070a0
-            self.parser.add_option("--iso",      dest="iso",  default=defaultiso, help="(OPTIONAL) output ISO to this path")
1070a0
+            buildisodir = config.Config(self).settings().buildisodir
1070a0
+            defaultiso = os.path.join(buildisodir, "generated.iso")
1070a0
+            self.parser.add_option("--iso",      dest="iso",  default=defaultiso, help="(OPTIONAL) output ISO to this path (must be writable by cobblerd)")
1070a0
             self.parser.add_option("--profiles", dest="profiles", help="(OPTIONAL) use these profiles only")
1070a0
             self.parser.add_option("--systems",  dest="systems",  help="(OPTIONAL) use these systems only")
1070a0
-            self.parser.add_option("--tempdir",  dest="tempdir",  help="(OPTIONAL) working directory")
1070a0
+            self.parser.add_option("--tempdir",  dest="tempdir",  help="(OPTIONAL) temporary working directory (must be writable by cobblerd)")
1070a0
             self.parser.add_option("--distro",   dest="distro",   help="(OPTIONAL) used with --standalone to create a distro-based ISO including all associated profiles/systems")
1070a0
             self.parser.add_option("--standalone", dest="standalone", action="store_true", help="(OPTIONAL) creates a standalone ISO with all required distro files on it")
1070a0
             self.parser.add_option("--source",   dest="source",   help="(OPTIONAL) used with --standalone to specify a source for the distribution files")
1070a0
             self.parser.add_option("--exclude-dns", dest="exclude_dns", action="store_true", help="(OPTIONAL) prevents addition of name server addresses to the kernel boot options")
1070a0
+            self.parser.add_option("--force-server", dest="force_server", help="(OPTIONAL) when kickstarting get required files from the given server instead of the default (may be given as IP Address or FQDN of the server). Useful when kickstarting through a proxy.")
1070a0
1070a0
             (options, args) = self.parser.parse_args()
1070a0
             task_id = self.start_task("buildiso",options)
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/remote.py cobbler-2.0.7-new/cobbler/remote.py
1070a0
--- cobbler-2.0.7-orig/cobbler/remote.py	2013-05-22 15:00:28.212867927 -0400
1070a0
+++ cobbler-2.0.7-new/cobbler/remote.py	2013-07-11 14:41:26.978177903 -0400
1070a0
@@ -152,7 +152,8 @@ class CobblerXMLRPCInterface:
1070a0
                 self.options.get("standalone",False),
1070a0
                 self.options.get("source",None),
1070a0
                 self.options.get("exclude_dns",False),
1070a0
-                self.logger
1070a0
+                self.logger,
1070a0
+                self.options.get("force_server",None)
1070a0
             )
1070a0
         def on_done(self):
1070a0
             if self.options.get("iso","") == "/var/www/cobbler/pub/generated.iso":
1070a0
diff -rupN cobbler-2.0.7-orig/cobbler/settings.py cobbler-2.0.7-new/cobbler/settings.py
1070a0
--- cobbler-2.0.7-orig/cobbler/settings.py	2013-05-22 15:00:28.212867927 -0400
1070a0
+++ cobbler-2.0.7-new/cobbler/settings.py	2013-07-11 16:31:33.375946740 -0400
1070a0
@@ -96,6 +96,7 @@ DEFAULTS = {
1070a0
     "template_remote_kickstarts"  : 0,
1070a0
     "virt_auto_boot"              : 0,
1070a0
     "webdir"                      : "/var/www/cobbler",
1070a0
+    "buildisodir"                 : "/tmp/cobbler/buildiso",
1070a0
     "xmlrpc_port"                 : 25151,
1070a0
     "yum_post_install_mirror"     : 1,
1070a0
     "createrepo_flags"            : "-c cache -s sha",