spacewalkproject/spacewalk — pull request #17 by SilvioMoioli (2014-03-14 15:24:17+00:00)
Title: Master pxe default image no powermanagement

This pull request adds support to list bare-metal systems in Spacewalk and provision them. This is the basic workflow:
- admin enables this feature from Spacewalk Configuration -> Bare-metal systems. This results in a new default Cobbler profile being created;

![baremetal configuration](https://f.cloud.github.com/assets/250541/2422031/b9e8bfd8-ab89-11e3-9369-4418c96e8843.png)

- bare-metal system is powered on, and gets the default (hereinafter "bootstrap") image from Cobbler. This is a special, minimal OS that will boot, register the system with a special "bootstrap" activation key and shut the system down;
- admin will happily see its system in the Systems list with a special icon and slightly different pages (basically, to hide a lot of actions which would not make sense). Bare-metal systems have a special entitlement which gets assigned with the bootstrap activation key only;

![overview with bare-metal system](https://f.cloud.github.com/assets/250541/2422037/d3ab85ea-ab89-11e3-8413-a5420c6dc02e.png)

![bare-metal system details](https://f.cloud.github.com/assets/250541/2422051/e8335d30-ab89-11e3-8264-8fd87bd81424.png)

- provisioning works as usual with Kickstart by creating Cobbler records (obviously scheduled provisioning is not supported). We have also extended functionality provided by the "Create Cobbler System Record"
button in the Provisioning page to multiple systems to ease that.

![ssm options are reduced when operating on bare-metal systems](https://f.cloud.github.com/assets/250541/2422185/cb046fe0-ab8b-11e3-88c6-965112679f20.png)

- admin can also use the power management feature to power on his system and begin the kickstart process. See [Power Management pull request](https://github.com/spacewalkproject/spacewalk/pull/15).

This pull request basically comprises the following:
- handling of bootstrap activation keys and entitlements, database updates;
- new acls and front-end code to hide portions of the UI that do not make sense for bare-metal systems;
- a new button to enable or disable this feature;
- correct handling of a few corner cases, like migrating a bare-metal system between organizations;
- test code.

You may notice a big missing piece: the bootstrap image itself! We created one for SUSE Manager using SLES, and one for Spacewalk based on openSUSE. It is available, together with its sources, here:

https://build.opensuse.org/package/show/systemsmanagement:spacewalk:misc/pxe-default-image

As we lack knowledge in Fedora and RHEL tools to build images, we used Kiwi and OBS to build it, as we are mostly familiar with those - others in the Spacewalk community are of course welcome to produce a Fedora or RHEL-based version.

End-user documentation for SUSE Manager, which is mostly relevant for Spacewalk as well, can be found here:

http://wiki.novell.com/index.php/SUSE_Manager/NewFeatures2.1#Unattended_bare-metal_system_provisioning

Some implementation details you might be interested in:
- you can install a copy of the bootstrap image with the following commands. The last command is needed to allow Cobbler to read the image through SELinux:

wget http://download.opensuse.org/repositories/systemsmanagement:/spacewalk:/misc/openSUSE_13.1/noarch/pxe-default-image-13.1-0.14.2.noarch.rpm
rpm -i pxe-default-image-13.1-0.14.2.noarch.rpm
chcon -R -v --type=cobbler_var_lib_t /srv/pxe-default-image

- this feature needs a few new configuration options, particularly regarding the bootstrap image location (we kept it as a parameter to easily adapt to various distros). Copy those from rhn_java.conf or from the Troubleshooting section of the above user guide;
- stored procedures have been updated to automatically add a large number of bootstrap entitlements to all organizations. That way system migrations between organizations are always possible;
- enabling or disabling the feature also implicitly triggers a cobbler sync. On my standard Fedora 19 install, this caused a Cobbler exception:

cobbler sync
task started: 2013-12-04_105106_sync
task started (id=Sync, time=Wed Dec 4 10:51:06 2013)
running pre-sync triggers
cleaning trees
removing: /var/lib/tftpboot/grub/images
copying bootloaders
Exception occured:
Exception value: 'Could not find files matching /usr/lib/syslinux/pxelinux.0'

This can be fixed by installing the syslinux package:

yum install syslinux

BTW: in SUSE syslinux is a dependency of the cobbler package, I do not know why this is different in Fedora;

Note: this branch was first proposed for merging in May 2013 and has not been rebased or adapted for last changes in master. Please provide some initial feedback - if the feature is basically OK to merge we will rebase it, move migration scripts, update JSPs to latest conventions etc.