summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2014-06-23 15:03:41 +1000
committerGerrit Code Review <gerrit@beaker-project.org>2014-06-24 02:13:24 +0000
commit46e4ce1dcdce8a2608d62868922b57d41b554b1e (patch)
tree0e0c06e5fe9c65c5d11196b2679b249add2516f3
parent358cc8420199603c84b6376aa1888f2d81deca4d (diff)
generate menu for aarch64 in beaker-pxemenu
-rw-r--r--IntegrationTests/src/bkr/inttest/labcontroller/test_pxemenu.py32
-rw-r--r--LabController/src/bkr/labcontroller/pxemenu.py57
-rw-r--r--documentation/admin-guide/distro-import.rst33
-rw-r--r--documentation/admin-guide/tftp.rst4
4 files changed, 111 insertions, 15 deletions
diff --git a/IntegrationTests/src/bkr/inttest/labcontroller/test_pxemenu.py b/IntegrationTests/src/bkr/inttest/labcontroller/test_pxemenu.py
index 2187259..9397459 100644
--- a/IntegrationTests/src/bkr/inttest/labcontroller/test_pxemenu.py
+++ b/IntegrationTests/src/bkr/inttest/labcontroller/test_pxemenu.py
@@ -91,3 +91,35 @@ title PinkUshankaLinux8.1 Server x86_64
kernel /distrotrees/{0}/kernel method=http://localhost:19998/ repo=http://localhost:19998/
initrd /distrotrees/{0}/initrd
'''.format(distro_tree.id))
+
+ def test_aarch64_menu(self):
+ with session.begin():
+ lc = self.get_lc()
+ tag = u'test_aarch64_menu'
+ distro_tree = data_setup.create_distro_tree(
+ osmajor=u'PinkUshankaLinux8', osminor=u'1',
+ distro_name=u'PinkUshankaLinux8.1', distro_tags=[tag],
+ arch=u'aarch64', lab_controllers=[lc],
+ urls=['http://localhost:19998/'])
+ write_menus(self.tftp_dir, tags=[tag], xml_filter=None)
+ menu = open(os.path.join(self.tftp_dir, 'aarch64', 'beaker_menu.cfg')).read()
+ self.assertEquals(menu, '''\
+set default="Exit PXE"
+set timeout=60
+menuentry "Exit PXE" {
+ exit
+}
+
+submenu "PinkUshankaLinux8" {
+
+submenu "PinkUshankaLinux8.1" {
+
+menuentry "PinkUshankaLinux8.1 Server aarch64" {
+ linux /distrotrees/%s/kernel method=http://localhost:19998/ repo=http://localhost:19998/
+ initrd /distrotrees/%s/initrd
+}
+
+}
+
+}
+''' % (distro_tree.id, distro_tree.id))
diff --git a/LabController/src/bkr/labcontroller/pxemenu.py b/LabController/src/bkr/labcontroller/pxemenu.py
index c303b05..c8f8d80 100644
--- a/LabController/src/bkr/labcontroller/pxemenu.py
+++ b/LabController/src/bkr/labcontroller/pxemenu.py
@@ -61,6 +61,13 @@ title ${distro_name} ${variant} ${arch}
initrd /distrotrees/${distro_tree_id}/initrd
''')
+aarch64_menu_entry_template = string.Template('''
+menuentry "${distro_name} ${variant} ${arch}" {
+ linux /distrotrees/${distro_tree_id}/kernel method=${url} repo=${url}
+ initrd /distrotrees/${distro_tree_id}/initrd
+}
+''')
+
def write_menus(tftp_root, tags, xml_filter):
# The order of steps for cleaning images is important,
# to avoid races and to avoid deleting stuff we shouldn't:
@@ -75,20 +82,26 @@ def write_menus(tftp_root, tags, xml_filter):
existing_tree_ids = []
proxy = xmlrpclib.ServerProxy('http://localhost:8000', allow_none=True)
- distrotrees = proxy.get_distro_trees({
+ x86_distrotrees = proxy.get_distro_trees({
'arch': ['x86_64', 'i386'],
'tags': tags,
'xml': xml_filter,
})
+ aarch64_distrotrees = proxy.get_distro_trees({
+ 'arch': ['aarch64'],
+ 'tags': tags,
+ 'xml': xml_filter,
+ })
- obsolete_tree_ids = set(existing_tree_ids).difference(
- str(dt['distro_tree_id']) for dt in distrotrees)
+ current_tree_ids = set(str(dt['distro_tree_id'])
+ for dt in x86_distrotrees + aarch64_distrotrees)
+ obsolete_tree_ids = set(existing_tree_ids).difference(current_tree_ids)
print 'Removing images for %s obsolete distro trees' % len(obsolete_tree_ids)
for obs in obsolete_tree_ids:
shutil.rmtree(os.path.join(tftp_root, 'distrotrees', obs), ignore_errors=True)
- print 'Generating menu for %s distro trees' % len(distrotrees)
- osmajors = _group_distro_trees(distrotrees)
+ print 'Generating PXELINUX and EFI GRUB menus for %s distro trees' % len(x86_distrotrees)
+ osmajors = _group_distro_trees(x86_distrotrees)
makedirs_ignore(os.path.join(tftp_root, 'pxelinux.cfg'), mode=0755)
pxe_menu = atomically_replaced_file(os.path.join(tftp_root, 'pxelinux.cfg', 'beaker_menu'))
makedirs_ignore(os.path.join(tftp_root, 'grub'), mode=0755)
@@ -139,6 +152,40 @@ menu end
menu end
''')
+ if aarch64_distrotrees:
+ print 'Generating aarch64 menu for %s distro trees' % len(aarch64_distrotrees)
+ osmajors = _group_distro_trees(aarch64_distrotrees)
+ makedirs_ignore(os.path.join(tftp_root, 'aarch64'), mode=0755)
+ aarch64_menu = atomically_replaced_file(os.path.join(tftp_root, 'aarch64', 'beaker_menu.cfg'))
+ with aarch64_menu as aarch64_menu:
+ aarch64_menu.write('''set default="Exit PXE"
+set timeout=60
+menuentry "Exit PXE" {
+ exit
+}
+''')
+
+ for osmajor, osversions in sorted(osmajors.iteritems(), reverse=True):
+ print 'Writing submenu %s' % osmajor
+ aarch64_menu.write('\nsubmenu "%s" {\n' % osmajor)
+ for osversion, distro_trees in sorted(osversions.iteritems(), reverse=True):
+ print 'Writing submenu %s -> %s' % (osmajor, osversion)
+ aarch64_menu.write('\nsubmenu "%s" {\n' % osversion)
+ for distro_tree in distro_trees:
+ url = _get_url(distro_tree['available'])
+ try:
+ _get_images(tftp_root, distro_tree['distro_tree_id'],
+ url, distro_tree['images'])
+ except IOError, e:
+ sys.stderr.write('Error fetching images for distro tree %s: %s\n' %
+ (distro_tree['distro_tree_id'], e))
+ else:
+ print 'Writing menu entry for distro tree %s' % distro_tree['distro_tree_id']
+ aarch64_menu.write(aarch64_menu_entry_template.substitute(
+ distro_tree, url=url))
+ aarch64_menu.write('\n}\n')
+ aarch64_menu.write('\n}\n')
+
def main():
parser = OptionParser(description='''Writes a netboot menu to the TFTP root
directory, containing distros from Beaker.''')
diff --git a/documentation/admin-guide/distro-import.rst b/documentation/admin-guide/distro-import.rst
index bc8f5ac..1e167cf 100644
--- a/documentation/admin-guide/distro-import.rst
+++ b/documentation/admin-guide/distro-import.rst
@@ -49,27 +49,27 @@ more specific jobs that you might find useful.
.. _pxe-menu:
-Generating a PXE menu
----------------------
+Generating a boot menu
+----------------------
Beaker includes a command, ``beaker-pxemenu``, which can be run on the lab
-controller to generate a PXELINUX-compatible boot menu listing the distros in
-Beaker. Users in the lab can then perform manual installations by selecting
-a distro from the menu. The menu is written to ``pxelinux.cfg/beaker_menu`` in
-the TFTP root directory.
+controller to generate a boot menu containing the distros in Beaker. Users in
+the lab can then perform manual installations by selecting a distro from the
+menu. Boot menus are generated for ``menu.c32`` (PXELINUX), EFI GRUB, and
+64-bit ARM.
You can limit the menu to only contain distros tagged in Beaker with a
certain tag, by passing the ``--tag`` option to ``beaker-pxemenu``. By
default, all distros which are available in the lab are included in the
-PXE menu.
+menu.
.. note:: If you have configured a non-default TFTP root directory in
``/etc/beaker/labcontroller.conf``, be sure to pass that same directory in
the ``--tftp-root`` option to ``beaker-pxemenu``.
-If using the PXE menu, you should configure ``pxelinux.cfg/default`` to
-boot from local disk by default, with an option to load the menu. For
-example::
+If you are using a boot menu, you should edit the PXELINUX default
+configuration :file:`pxelinux.cfg/default` to boot from local disk by default,
+with an option to load the menu. For example::
default local
prompt 1
@@ -87,6 +87,19 @@ example::
kernel menu.c32
append pxelinux.cfg/beaker_menu
+Similarly, you should edit the default configuration for 64-bit ARM
+:file:`aarch64/grub.cfg` to exit after a timeout, with an option to load the
+menu. For example::
+
+ set default="Exit PXE"
+ set timeout=10
+ menuentry "Exit PXE" {
+ exit
+ }
+ menuentry "Install distro from Beaker" {
+ configfile aarch64/beaker_menu.cfg
+ }
+
If your site imports distros into Beaker infrequently, you may prefer to
run ``beaker-pxemenu`` after importing new distros. Otherwise, you can
create a cron job to periodically update the PXE menu::
diff --git a/documentation/admin-guide/tftp.rst b/documentation/admin-guide/tftp.rst
index 15ed0e0..30581f6 100644
--- a/documentation/admin-guide/tftp.rst
+++ b/documentation/admin-guide/tftp.rst
@@ -135,6 +135,10 @@ Other files in the TFTP root directory
:file:`grub/efidefault`
Menu configuration generated by :program:`beaker-pxemenu` for EFI GRUB.
+:file:`aarch64/beaker_menu.cfg`
+ Menu configuration generated by :program:`beaker-pxemenu` for 64-bit ARM
+ systems.
+
:file:`distrotrees/`
Cached images for the generated menus. The contents of this directory are
managed by :program:`beaker-pxemenu`.