Jump to: navigation, search


Revision as of 17:21, 3 May 2021 by Julia Kreger (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: This content is likely out of date. Ironic has supported local boot of Bare metal nodes for quite some time, and this page was likely posted when that work was still under development. For the latest ironic documentation, see https://docs.openstack.org/ironic/latest

This is a reference script to passing kernel paramters to ironic localboot instance using configdrive. This only works with ubuntu image, so users should modify this script by their own use case:

 #!/usr/bin/env python
 import os

 # Default grub2 config file in Ubuntu
 grub_file = '/etc/default/grub'
 # Add parameters here to pass to instance.
 kernel_parameters = ['quiet', 'splash']
 grub_cmd = 'GRUB_CMDLINE_LINUX'
 old_grub_file = grub_file+'~'
 os.rename(grub_file, old_grub_file)
 cmdline_existed = False
 with open(grub_file, 'w') as writer, \
         open(old_grub_file, 'r') as reader:
         for line in reader:
             key = line.split('=')[0]
             if key == grub_cmd:
                 #If there is already some value:
                 if line.strip()[-1] == '"':
                     line = line.strip()[:-1] + ' ' + ' '.join(kernel_parameters) + '"'
                 cmdline_existed = True
         if not cmdline_existed:
             line = grub_cmd + '=' + '"' + ' '.join(kernel_parameters) + '"'