cobbler: improve error messages

When the serializer encounters an error, it does not provide enough
context for the error to debug.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
6b6363a8 ("Remove methods which create items from Config class") broke imports

The $subject commit removes two methods (new_distro, new_profile) that
are being used by existing code (added in f7ca250).

Fix for issue https://github.com/cobbler/cobbler/issues/1345

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Fixes: 6b6363a8 ("Remove methods which create items from Config class")
Commit c02e2124 ("changed ui for batch profile change to jquery") is missing

The changes necessary from $subject commit were reverted upstream, but
that in turn broke profile selection popups (e.g., bulk actions ->
change profile from system list page). The original code did have a bug
in it, which provoked the exception seen in 2b5f68ea, as it was not
intializing the profiles array to an empty list.

Fix for https://github.com/cobbler/cobbler/issues/1333

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Fixes: 2b5f68ea ("Fix Django exceptions when lists (eg. distro/profiles) are empty.")
Fixes: 632dcdd0 ("Remove unused variable.")
manage_import_signatures: search for architectures in reverse length order

For RHEL7 on ppc64, for example, Cobbler ends up creating both a ppc and
ppc64 entry. Leaving aside the fact that I don't think 32-bit ppc is
supported by RHEL7 (at least not with this iso, that's for sure), the
issue is that both "ppc" and "ppc64" (both listed in
signature["supported_arches"]) are "found" within the
signature["kernel_arch"] file which contains "ppc64".

Two fixes are needed:

1) self.get_valid_arches() should return a reverse-sorted list by length
(longest first)
2) If a match is found (foo[arch] will be set to 1), the arch loop
should be broken out of, as the first match found is the most specific
(matches the most characters)

Fixes  https://github.com/cobbler/cobbler/issues/1332

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Commit d6888de3 ("Rename ks_mirror directory") broke imports

The string length ("ks_mirror" versus "distro_mirror") is no longer 10.
Use an explicit len() call.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Fixes: d6888de3 ("Rename ks_mirror directory")
post_install_network_config_deb: add gateway information

On power systems, at least, no default route is created without a
gateway defined in the system configuration. Since interfaces can
override the gateway, we only use the global gateway if no per-interface
gatway is defined.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
DHCP: export name-server information to DHCP clients

If name servers are defined for a system, send them over DHCP, when in
use.  This avoids one prompt in Ubuntu preseed configurations.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Ubuntu: auto configure netcfg over command-line

For network booting the Ubuntu installer, we need to configure the
network before we can grab the preseed. The first network interface with
link is selected in the preseed with 'd-i netcfg/choose_interface select
auto', so pass this to the installer on the command-line.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
remove remaining missed references to kickstarts

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Rename pxesystem_ppc.template to yaboot_ppc.template

It is not really a PXE template, and it only works for yaboot.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
cobbler: add powerpc grub2 support

GRUB2 is a highly modular and flexible replacement for GRUB. Newer
distributions (FC20+, RHEL7+, SLES12+, Ubuntu 14.04+) support GRUB2 on
Power, and yaboot is now deprecated there. Add "grub2" as a valid
boot_loader type, and provide a template for it's config file. GRUB2
will only be used if a signature on import indicates the distribution
should use it instead of yaboot. Eventually, we would probably remove
yaboot support (or switch the default around, at least).

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
---
Jorgen, I also need to provide you with a binary grub2 tarball that can
be used by get_loaders, I think. What is the process to do that, as they
are not in the repository?
cobbler: add little-endian powerpc support

Power systems now can run in little-endian or big-endian mode, depending
on the support from the OS. Add "ppc64le" and "ppc64el" as valid
architecture names. Generally, LE power is the same as BE, just with a
different architecture string. Update the signature file appropriately:

 - SLES is ppc64le only, Ubuntu/Debian is ppc64el.
 - On Ubuntu ppc64el, the kernel is named vmlinux not linux.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
cobbler: add powerpc pxelinux support

In PowerNV (non-virtualized) mode, certain Power8 systems run petitboot
which can use pxelinux for network booting. Add support throughout the
code for pxelinux config file generation for powerpc systems. There is
one distinction between pxelinux on Power and on other systems, though,
the bootloader is built into the firmware, so we do not want to send any
file via the DHCP configuration.

There is currently a bug in petitboot that misparses 'ipappend 2' and
doesn't prefix the machine type, e.g. "01-". I'm manually working around
this in tftpgen, and will undo that change once petitboot is fixed.

Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>