Repository: cobbler/cobbler

Issue:
pxe files left in tfpboot when netboot is disabled
We've been using cobbler for some time and I've noticed that the pxe files are generated in the /tftpboot/pxe/grub and /tftpboot/pxe/pxelinux.cfg directories for systems regardless of whether or not netboot is enabled for a system. I'm assuming this hasn't been a problem for most people who are letting cobbler manage dhcp. I'm guessing the dhcp config is manipulated so once netboot is disabled, it removes the boot file from the config. We are using cobbler in a slightly unconventional way as it pertains to dhcp/pxe. We use the pxe files generated by cobbler, but they are accessed via a tfp/dhcp server that is not managed by cobbler. This is done because we have other systems getting managed outside of cobbler that also generate pxe configurations. 

I'm wondering if there is a reason these pxe files are not removed when the host has netboot disabled. 

As a test, I modified the code (this is 2.2.3-2) in /usr/lib/python2.6/site-packages/cobbler/pxegen.py line 279 and added (and system.netboot_enabled):

```
            os.symlink("../yaboot", f3)
        else:
            continue
```

> > ```
> >     if system.is_management_supported() and system.netboot_enabled:
> >             if not image_based:
> >                 self.write_pxe_file(f2, system, profile, distro, working_arch)
> >                 if grub_path:
> >                     self.write_pxe_file(grub_path, system, profile, distro,
> >                             working_arch, format="grub")
> >             else:
> >                 self.write_pxe_file(f2, system, None, None, working_arch, image=profile)
> >         else:
> >             # ensure the file doesn't exist
> >             utils.rmfile(f2)
> >             if grub_path:
> >                 utils.rmfile(grub_path)
> > ```

This change had the desired affect. Is this something that can be patched into the code, or am I missing something?



Discussion:
Seems valid reasoning to me.

This change destroyed the functionality provided by pxe_just_once: The reason the pxe files are (were) left is so that the machines are commanded, via pxe, to boot from the local drive. Once the pxe files are deleted, each machine will now boot using whatever is in /tftboot/.../default, which is _NOT_ what should happen. The netboot-enabled flag  has no control of the individual bios configs on the machines, the whole idea if netboot-enabled is that all machines are configured to pxe boot always, now cobbler controls whether they then boot from the local drive or remiage. With this change, what happens with netboot-enabled false is arbitrary, and can lead to damaging already deployed machines.

I suspect thiis use case requires some special config, e.g.,:

   IGNORE_NETBOOT_ENABLE = 1 (default 0)

and this of course is in direct conflct with pxe_just_once


Resolving patch:
diff --git a/cobbler/pxegen.py b/cobbler/pxegen.py
--- a/cobbler/pxegen.py
+++ b/cobbler/pxegen.py
@@ -282,7 +282,7 @@ def write_all_system_files(self, system):
             else:
                 continue 
 
-            if system.is_management_supported() and system.netboot_enabled:
+            if system.is_management_supported():
                 if not image_based:
                     self.write_pxe_file(f2, system, profile, distro, working_arch, metadata=pxe_metadata)
                     if grub_path:


Test patch: