Repository: cobbler/cobbler

Issue:
buildiso fails if a profile is named "proxy"
Executing the buildiso command with a profile named "proxy" leads to an exception:

```
# cobbler buildiso
task started: 2013-09-18_104222_buildiso
task started (id=Build Iso, time=Wed Sep 18 10:42:22 2013)
using/creating buildisodir: /var/cache/cobbler/buildiso
building tree for isolinux
copying miscellaneous files
processing profile: P[...]
[...]
processing profile: XXX-proxy-YYY
Exception occured: <type 'exceptions.KeyError'>
Exception value: 'proxy'
Exception Info:
  File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 89, in run
    rc = self._run(self)
   File "/usr/lib/python2.6/site-packages/cobbler/remote.py", line 159, in runner
    self.logger
   File "/usr/lib/python2.6/site-packages/cobbler/api.py", line 1030, in build_iso
    iso=iso, profiles=profiles, systems=systems, buildisodir=buildisodir, distro=distro, standalone=standalone, source=source, exclude_dns=exclude_dns, mkisofs_opts=mkisofs_opts
   File "/usr/lib/python2.6/site-packages/cobbler/action_buildiso.py", line 581, in run
    self.generate_netboot_iso(imagesdir,isolinuxdir,profiles,systems,exclude_dns)
   File "/usr/lib/python2.6/site-packages/cobbler/action_buildiso.py", line 181, in generate_netboot_iso
    if data["proxy"] != "":

!!! TASK FAILED !!!

# rpm -qa cobbler
cobbler-2.4.0-1.el6.noarch
```



Discussion:
[root@cobbler config]# cobbler buildiso
task started: 2013-10-20_203954_buildiso
task started (id=Build Iso, time=Sun Oct 20 20:39:54 2013)
using/creating buildisodir: /var/cache/cobbler/buildiso
building tree for isolinux
copying miscellaneous files
processing profile: proxy
processing profile: sles11sp3-x86_64
processing profile: ubuntu-12.04.2-x86_64
running: mkisofs -o /data/cobbler/config/generated.iso  -r -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -V Cobbler\ Install -R -J -T /var/cache/cobbler/buildiso
received on stdout: 
received on stderr: I: -input-charset not specified, using utf-8 (detected in locale settings)
Size of boot image is 4 sectors -> No emulation
 16.01% done, estimate finish Sun Oct 20 20:39:57 2013
 31.95% done, estimate finish Sun Oct 20 20:39:57 2013
 47.95% done, estimate finish Sun Oct 20 20:39:57 2013
 63.90% done, estimate finish Sun Oct 20 20:39:57 2013
 79.90% done, estimate finish Sun Oct 20 20:39:57 2013
 95.89% done, estimate finish Sun Oct 20 20:39:57 2013
Total translation table size: 4463
Total rockridge attributes bytes: 1474
Total directory bytes: 4700
Path table size(bytes): 40
Max brk space used 1a000
31302 extents written (61 MB)

ISO build complete
You may wish to delete: /var/cache/cobbler/buildiso
The output file is: /data/cobbler/config/generated.iso
**\* TASK COMPLETE ***

Can't reproduce.


Resolving patch:
diff --git a/cobbler/action_buildiso.py b/cobbler/action_buildiso.py
--- a/cobbler/action_buildiso.py
+++ b/cobbler/action_buildiso.py
@@ -162,7 +162,7 @@ def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,e
 
              append_line = " append initrd=%s.img" % distname
              if dist.breed == "suse":
-                 if data["proxy"] != "":
+                 if data.has_key("proxy") and data["proxy"] != "":
                      append_line += " proxy=%s" % data["proxy"]
                  if data["kernel_options"].has_key("install") and data["kernel_options"]["install"] != "":
                      append_line += " install=%s" % data["kernel_options"]["install"]
@@ -178,13 +178,13 @@ def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,e
                      append_line += " autoyast=%s" % data["kickstart"]
 
              if dist.breed == "redhat":
-                 if data["proxy"] != "":
+                 if data.has_key("proxy") and data["proxy"] != "":
                     append_line += " proxy=%s http_proxy=%s" % (data["proxy"], data["proxy"])
                  append_line += " ks=%s" % data["kickstart"]
 
              if dist.breed in ["ubuntu","debian"]:
                  append_line += " auto-install/enable=true url=%s" % data["kickstart"]
-                 if data["proxy"] != "":
+                 if data.has_key("proxy") and data["proxy"] != "":
                      append_line += " mirror/http/proxy=%s" % data["proxy"]
              append_line += self.add_remaining_kopts(data["kernel_options"])
              cfg.write(append_line)
@@ -217,7 +217,7 @@ def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,e
 
              append_line = " append initrd=%s.img" % distname
              if dist.breed == "suse":
-                if data["proxy"] != "":
+                if data.has_key("proxy") and data["proxy"] != "":
                     append_line += " proxy=%s" % data["proxy"]
                 if data["kernel_options"].has_key("install") and data["kernel_options"]["install"] != "":
                     append_line += " install=%s" % data["kernel_options"]["install"]
@@ -233,13 +233,13 @@ def generate_netboot_iso(self,imagesdir,isolinuxdir,profiles=None,systems=None,e
                     append_line += " autoyast=%s" % data["kickstart"]
 
              if dist.breed == "redhat":
-                if data["proxy"] != "":
+                if data.has_key("proxy") and data["proxy"] != "":
                     append_line += " proxy=%s http_proxy=%s" % (data["proxy"], data["proxy"])
                 append_line += " ks=%s" % data["kickstart"]
 
              if dist.breed in ["ubuntu","debian"]:
                 append_line += " auto-install/enable=true url=%s netcfg/disable_dhcp=true" % data["kickstart"]
-                if data["proxy"] != "":
+                if data.has_key("proxy") and data["proxy"] != "":
                     append_line += " mirror/http/proxy=%s" % data["proxy"]
                 # hostname is required as a parameter, the one in the preseed is not respected
                 my_domain = "local.lan"


Test patch: