summaryrefslogtreecommitdiff
path: root/ironic/common
diff options
context:
space:
mode:
authorJulia Kreger <juliaashleykreger@gmail.com>2022-03-29 18:32:36 -0700
committerJulia Kreger <juliaashleykreger@gmail.com>2022-07-20 06:50:03 -0700
commit33bb2c248a20d6a2a0af570655124cbc86d58b6a (patch)
treee00370d4149feeebd9bf60bba7c3bcb7f0abb9b1 /ironic/common
parente78f123ff8e3a4fcd5e3e596b526eb5eb39a34a9 (diff)
downloadironic-33bb2c248a20d6a2a0af570655124cbc86d58b6a.tar.gz
Do not require stage2 for anaconda with standalone
The use of the anaconda deployment interface can be confusing when using a standalone deployment model. Specifically this is because the anaconda deployment interface was primarily modeled for usage with glance and the inherent configuration of a fully integrated OpenStack deployment. The additional prameters are confusing, so this also (hopefully) provides clarity into use and options. Change-Id: I748fd86901bc05d3d003626b5e14e655b7905215
Diffstat (limited to 'ironic/common')
-rw-r--r--ironic/common/pxe_utils.py55
1 files changed, 41 insertions, 14 deletions
diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index b0f1d906f..64cf4608f 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -698,17 +698,25 @@ def get_instance_image_info(task, ipxe_enabled=False):
anaconda_labels = ()
if deploy_utils.get_boot_option(node) == 'kickstart':
+ isap = node.driver_internal_info.get('is_source_a_path')
# stage2: installer stage2 squashfs image
# ks_template: anaconda kickstart template
# ks_cfg - rendered ks_template
- anaconda_labels = ('stage2', 'ks_template', 'ks_cfg')
+ if not isap:
+ anaconda_labels = ('stage2', 'ks_template', 'ks_cfg')
+ else:
+ # When a path is used, a stage2 ramdisk can be determiend
+ # automatically by anaconda, so it is not an explicit
+ # requirement.
+ anaconda_labels = ('ks_template', 'ks_cfg')
# NOTE(rloo): We save stage2 & ks_template values in case they
# are changed by the user after we start using them and to
# prevent re-computing them again.
if not node.driver_internal_info.get('stage2'):
if i_info.get('stage2'):
node.set_driver_internal_info('stage2', i_info['stage2'])
- else:
+ elif not isap:
+ # If the source is not a path, then we need a stage2 ramdisk.
_get_image_properties()
if 'stage2_id' not in image_properties:
msg = (_("'stage2_id' is missing from the properties of "
@@ -720,19 +728,27 @@ def get_instance_image_info(task, ipxe_enabled=False):
else:
node.set_driver_internal_info(
'stage2', str(image_properties['stage2_id']))
- if i_info.get('ks_template'):
- node.set_driver_internal_info('ks_template',
- i_info['ks_template'])
+ # NOTE(TheJulia): A kickstart template is entirely independent
+ # of the stage2 ramdisk. In the end, it was the configuration which
+ # told anaconda how to execute.
+ if i_info.get('ks_template'):
+ # If the value is set, we always overwrite it, in the event
+ # a rebuild is occuring or something along those lines.
+ node.set_driver_internal_info('ks_template',
+ i_info['ks_template'])
+ else:
+ _get_image_properties()
+ # ks_template is an optional property on the image
+ if 'ks_template' not in image_properties:
+ # If not defined, default to the overall system default
+ # kickstart template, as opposed to a user supplied
+ # template.
+ node.set_driver_internal_info(
+ 'ks_template', CONF.anaconda.default_ks_template)
else:
- _get_image_properties()
- # ks_template is an optional property on the image
- if 'ks_template' not in image_properties:
- node.set_driver_internal_info(
- 'ks_template', CONF.anaconda.default_ks_template)
- else:
- node.set_driver_internal_info(
- 'ks_template', str(image_properties['ks_template']))
- node.save()
+ node.set_driver_internal_info(
+ 'ks_template', str(image_properties['ks_template']))
+ node.save()
for label in labels + anaconda_labels:
image_info[label] = (
@@ -800,6 +816,7 @@ def build_deploy_pxe_options(task, pxe_info, mode='deploy',
def build_instance_pxe_options(task, pxe_info, ipxe_enabled=False):
pxe_opts = {}
node = task.node
+ isap = node.driver_internal_info.get('is_source_a_path')
for label, option in (('kernel', 'aki_path'),
('ramdisk', 'ari_path'),
@@ -822,6 +839,16 @@ def build_instance_pxe_options(task, pxe_info, ipxe_enabled=False):
pxe_opts[option] = os.path.relpath(pxe_info[label][1],
CONF.pxe.tftp_root)
+ # NOTE(TheJulia): This is basically anaconda specific, but who knows
+ # one day! Copy image_source to repo_url if it is a URL to a directory
+ # path, and an explicit stage2 URL is not defined as .treeinfo is totally
+ # a thing and anaconda's dracut element knows the secrets of how to
+ # get and use the treeinfo file. And yes, this is a hidden file. :\
+ # example:
+ # http://mirror.stream.centos.org/9-stream/BaseOS/x86_64/os/.treeinfo
+ if isap and 'stage2_url' not in pxe_opts:
+ pxe_opts['repo_url'] = node.instance_info.get('image_source')
+
pxe_opts.setdefault('aki_path', 'no_kernel')
pxe_opts.setdefault('ari_path', 'no_ramdisk')