Move place_loaders_for_boot to boot driver __init__

Host preparation file writing is already done by the __init__ method
of iPXEBoot. This change moves place_loaders_for_boot calls to
iPXEBoot and PXEBoot to be consistent, and to only write the files
when that driver is enabled.

This will mean multiple writes of the same file when subclasses of
these drivers are also enabled, but this overhead will be negligible.

Change-Id: I7e17f4d1a54cd6c5d1a4bf006a0d42db8d123a46
This commit is contained in:
Steve Baker 2021-11-30 11:18:42 +13:00
parent 00c0566185
commit 45e8adc1df
3 changed files with 13 additions and 8 deletions

View File

@ -31,7 +31,6 @@ from ironic.common import driver_factory
from ironic.common import exception from ironic.common import exception
from ironic.common import hash_ring from ironic.common import hash_ring
from ironic.common.i18n import _ from ironic.common.i18n import _
from ironic.common import pxe_utils
from ironic.common import release_mappings as versions from ironic.common import release_mappings as versions
from ironic.common import rpc from ironic.common import rpc
from ironic.common import states from ironic.common import states
@ -88,11 +87,9 @@ class BaseConductorManager(object):
def prepare_host(self): def prepare_host(self):
"""Prepares host for initialization """Prepares host for initialization
Prepares the conductor for basic operation by removing any Prepares the conductor for basic operation by removing any existing
existing transitory node power states and reservations which transitory node power states and reservations which were previously
were previously held by this host. Once that has been completed, held by this host.
bootloader assets, if configured, are staged for network (PXE) boot
operations.
Under normal operation, this is also when the initial database Under normal operation, this is also when the initial database
connectivity is established for the conductor's normal operation. connectivity is established for the conductor's normal operation.
@ -112,8 +109,6 @@ class BaseConductorManager(object):
self.dbapi.clear_node_target_power_state(self.host) self.dbapi.clear_node_target_power_state(self.host)
# clear all locks held by this conductor before registering # clear all locks held by this conductor before registering
self.dbapi.clear_node_reservations_for_conductor(self.host) self.dbapi.clear_node_reservations_for_conductor(self.host)
pxe_utils.place_loaders_for_boot(CONF.pxe.tftp_root)
pxe_utils.place_loaders_for_boot(CONF.deploy.http_root)
def init_host(self, admin_context=None): def init_host(self, admin_context=None):
"""Initialize the conductor host. """Initialize the conductor host.

View File

@ -16,6 +16,7 @@ iPXE Boot Interface
""" """
from ironic.common import pxe_utils from ironic.common import pxe_utils
from ironic.conf import CONF
from ironic.drivers import base from ironic.drivers import base
from ironic.drivers.modules import pxe_base from ironic.drivers.modules import pxe_base
@ -28,3 +29,6 @@ class iPXEBoot(pxe_base.PXEBaseMixin, base.BootInterface):
def __init__(self): def __init__(self):
pxe_utils.create_ipxe_boot_script() pxe_utils.create_ipxe_boot_script()
pxe_utils.place_loaders_for_boot(CONF.deploy.http_root)
# This is required to serve the iPXE binary via tftp
pxe_utils.place_loaders_for_boot(CONF.pxe.tftp_root)

View File

@ -20,9 +20,11 @@ from oslo_log import log as logging
from ironic.common import boot_devices from ironic.common import boot_devices
from ironic.common.i18n import _ from ironic.common.i18n import _
from ironic.common import pxe_utils
from ironic.common import states from ironic.common import states
from ironic.conductor import task_manager from ironic.conductor import task_manager
from ironic.conductor import utils as manager_utils from ironic.conductor import utils as manager_utils
from ironic.conf import CONF
from ironic.drivers import base from ironic.drivers import base
from ironic.drivers.modules import agent_base from ironic.drivers.modules import agent_base
from ironic.drivers.modules import deploy_utils from ironic.drivers.modules import deploy_utils
@ -36,6 +38,10 @@ class PXEBoot(pxe_base.PXEBaseMixin, base.BootInterface):
capabilities = ['ramdisk_boot', 'pxe_boot'] capabilities = ['ramdisk_boot', 'pxe_boot']
def __init__(self):
pxe_utils.place_loaders_for_boot(CONF.deploy.http_root)
pxe_utils.place_loaders_for_boot(CONF.pxe.tftp_root)
class PXEAnacondaDeploy(agent_base.AgentBaseMixin, agent_base.HeartbeatMixin, class PXEAnacondaDeploy(agent_base.AgentBaseMixin, agent_base.HeartbeatMixin,
base.DeployInterface): base.DeployInterface):