Browse Source

Merge "Finally remove support for netboot and the boot_option capability"

changes/93/852393/1
Zuul 6 days ago committed by Gerrit Code Review
parent
commit
b34d79e3f4
  1. 15
      devstack/lib/ironic
  2. 12
      ironic/conf/deploy.py
  3. 36
      ironic/drivers/modules/agent.py
  4. 12
      ironic/drivers/modules/agent_base.py
  5. 13
      ironic/drivers/modules/agent_config.template
  6. 6
      ironic/drivers/modules/ansible/deploy.py
  7. 12
      ironic/drivers/modules/deploy_utils.py
  8. 27
      ironic/drivers/modules/ilo/boot.py
  9. 5
      ironic/drivers/modules/ilo/power.py
  10. 6
      ironic/drivers/modules/ipxe_config.template
  11. 5
      ironic/drivers/modules/irmc/boot.py
  12. 11
      ironic/drivers/modules/network/neutron.py
  13. 44
      ironic/drivers/modules/pxe_base.py
  14. 6
      ironic/drivers/modules/pxe_config.template
  15. 5
      ironic/drivers/modules/pxe_grub_config.template
  16. 19
      ironic/tests/unit/common/test_pxe_utils.py
  17. 40
      ironic/tests/unit/conductor/test_manager.py
  18. 6
      ironic/tests/unit/drivers/ipxe_config.template
  19. 6
      ironic/tests/unit/drivers/ipxe_config_boot_from_anaconda.template
  20. 6
      ironic/tests/unit/drivers/ipxe_config_boot_from_iso.template
  21. 6
      ironic/tests/unit/drivers/ipxe_config_boot_from_ramdisk.template
  22. 6
      ironic/tests/unit/drivers/ipxe_config_boot_from_volume_extra_volume.template
  23. 6
      ironic/tests/unit/drivers/ipxe_config_boot_from_volume_multipath.template
  24. 6
      ironic/tests/unit/drivers/ipxe_config_boot_from_volume_no_extra_volumes.template
  25. 6
      ironic/tests/unit/drivers/ipxe_config_timeout.template
  26. 18
      ironic/tests/unit/drivers/modules/ansible/test_deploy.py
  27. 123
      ironic/tests/unit/drivers/modules/ilo/test_boot.py
  28. 39
      ironic/tests/unit/drivers/modules/irmc/test_boot.py
  29. 60
      ironic/tests/unit/drivers/modules/network/test_neutron.py
  30. 209
      ironic/tests/unit/drivers/modules/test_agent.py
  31. 46
      ironic/tests/unit/drivers/modules/test_agent_base.py
  32. 275
      ironic/tests/unit/drivers/modules/test_deploy_utils.py
  33. 328
      ironic/tests/unit/drivers/modules/test_ipxe.py
  34. 274
      ironic/tests/unit/drivers/modules/test_pxe.py
  35. 21
      ironic/tests/unit/drivers/modules/test_ramdisk.py
  36. 6
      ironic/tests/unit/drivers/pxe_config.template
  37. 5
      ironic/tests/unit/drivers/pxe_grub_config.template
  38. 6
      releasenotes/notes/no-netboot-d08f46c12edabd35.yaml
  39. 13
      zuul.d/ironic-jobs.yaml

15
devstack/lib/ironic

@ -681,12 +681,6 @@ if [[ "$IRONIC_BOOT_MODE" == "uefi" ]]; then
fi
fi
# TODO(dtantsur): change this when we change the default value.
IRONIC_DEFAULT_BOOT_OPTION=${IRONIC_DEFAULT_BOOT_OPTION:-local}
if [ $IRONIC_DEFAULT_BOOT_OPTION != "netboot" ] && [ $IRONIC_DEFAULT_BOOT_OPTION != "local" ]; then
die $LINENO "Supported values for IRONIC_DEFAULT_BOOT_OPTION are 'netboot' and 'local' only."
fi
# TODO(pas-ha) find a way to (cross-)sign the custom CA bundle used by tls-proxy
# with default iPXE cert - for reference see http://ipxe.org/crypto
if is_service_enabled tls-proxy && [[ "$IRONIC_IPXE_USE_SWIFT" == "True" ]]; then
@ -1855,8 +1849,6 @@ function configure_ironic_conductor {
iniset $IRONIC_CONF_FILE dhcp dhcp_provider $IRONIC_DHCP_PROVIDER
iniset $IRONIC_CONF_FILE deploy default_boot_option $IRONIC_DEFAULT_BOOT_OPTION
isolinux=$(find -L /usr -type f -name "isolinux.bin" | head -1)
if [[ -n "$isolinux" ]]; then
iniset $IRONIC_CONF_FILE DEFAULT isolinux_bin "$isolinux"
@ -2903,8 +2895,7 @@ function upload_image_if_needed {
# Change the default image only if the provided settings prevent the
# default cirros image from working.
if [[ "$IRONIC_TEMPEST_WHOLE_DISK_IMAGE" != True \
&& "$IRONIC_DEFAULT_BOOT_OPTION" == local ]]; then
if [[ "$IRONIC_TEMPEST_WHOLE_DISK_IMAGE" != True ]]; then
IRONIC_IMAGE_NAME=$IRONIC_PARTITIONED_IMAGE_NAME
DEFAULT_IMAGE_NAME=$IRONIC_IMAGE_NAME
fi
@ -3242,7 +3233,9 @@ function ironic_configure_tempest {
# Driver for API tests
iniset $TEMPEST_CONFIG baremetal driver fake-hardware
iniset $TEMPEST_CONFIG baremetal default_boot_option $IRONIC_DEFAULT_BOOT_OPTION
# NOTE(dtantsur): remove this when the tempest plugin no longer supports
# netboot (i.e. when Zed is the oldest supported branch).
iniset $TEMPEST_CONFIG baremetal default_boot_option local
local adjusted_root_disk_size_gb
if [[ "$IRONIC_IS_HARDWARE" == "False" ]]; then

12
ironic/conf/deploy.py

@ -120,18 +120,6 @@ opts = [
mutable=True,
help=_('Whether to power off a node after deploy failure. '
'Defaults to True.')),
cfg.StrOpt('default_boot_option',
choices=[('netboot', _('boot from a network')),
('local', _('local boot'))],
default='local',
mutable=True,
help=_('Default boot option to use when no boot option is '
'requested in node\'s driver_info. Defaults to '
'"local". Prior to the Ussuri release, the default '
'was "netboot".'),
deprecated_for_removal=True,
deprecated_reason=_('Support for network boot will be removed '
'after the Yoga release.')),
cfg.StrOpt('default_boot_mode',
choices=[(boot_modes.UEFI, _('UEFI boot mode')),
(boot_modes.LEGACY_BIOS, _('Legacy BIOS boot mode'))],

36
ironic/drivers/modules/agent.py

@ -16,7 +16,6 @@ from urllib import parse as urlparse
from ironic_lib import metrics_utils
from oslo_log import log
from oslo_utils import excutils
from oslo_utils import units
from ironic.common import exception
@ -325,33 +324,7 @@ class CustomAgentDeploy(agent_base.AgentBaseMixin, agent_base.AgentDeployMixin,
if node.provision_state == states.DEPLOYING:
# Validate network interface to ensure that it supports boot
# options configured on the node.
try:
task.driver.network.validate(task)
except exception.InvalidParameterValue:
# For 'neutron' network interface validation will fail
# if node is using 'netboot' boot option while provisioning
# a whole disk image. Updating 'boot_option' in node's
# 'instance_info' to 'local for backward compatibility.
# TODO(stendulker): Fail here once the default boot
# option is local.
# NOTE(TheJulia): Fixing the default boot mode only
# masks the failure as the lack of a user definition
# can be perceived as both an invalid configuration and
# reliance upon the default configuration. The reality
# being that in most scenarios, users do not want network
# booting, so the changed default should be valid.
with excutils.save_and_reraise_exception(reraise=False) as ctx:
instance_info = node.instance_info
capabilities = utils.parse_instance_info_capabilities(node)
if 'boot_option' not in capabilities:
capabilities['boot_option'] = 'local'
instance_info['capabilities'] = capabilities
node.instance_info = instance_info
node.save()
# Re-validate the network interface
task.driver.network.validate(task)
else:
ctx.reraise = True
task.driver.network.validate(task)
# Determine if this is a fast track sequence
fast_track_deploy = manager_utils.is_fast_track(task)
if fast_track_deploy:
@ -597,13 +570,6 @@ class AgentDeploy(CustomAgentDeploy):
iwdi = task.node.driver_internal_info.get('is_whole_disk_image')
cpu_arch = task.node.properties.get('cpu_arch')
# If `boot_option` is set to `netboot`, PXEBoot.prepare_instance()
# would need root_uuid of the whole disk image to add it into the
# pxe config to perform chain boot.
# IPA would have returned us the 'root_uuid_or_disk_id' if image
# being provisioned is a whole disk image. IPA would also provide us
# 'efi_system_partition_uuid' if the image being provisioned is a
# partition image.
# In case of local boot using partition image, we need both
# 'root_uuid_or_disk_id' and 'efi_system_partition_uuid' to configure
# bootloader for local boot.

12
ironic/drivers/modules/agent_base.py

@ -1217,12 +1217,12 @@ class AgentDeployMixin(HeartbeatMixin, AgentOobStepsMixin):
"""
node = task.node
if deploy_utils.get_boot_option(node) == "local":
# Install the boot loader
self.configure_local_boot(
task, root_uuid=root_uuid,
efi_system_part_uuid=efi_sys_uuid,
prep_boot_part_uuid=prep_boot_part_uuid)
# Install the boot loader
self.configure_local_boot(
task, root_uuid=root_uuid,
efi_system_part_uuid=efi_sys_uuid,
prep_boot_part_uuid=prep_boot_part_uuid)
try:
task.driver.boot.prepare_instance(task)
except Exception as e:

13
ironic/drivers/modules/agent_config.template

@ -1,13 +0,0 @@
default deploy
label deploy
kernel {{ pxe_options.deployment_aki_path }}
append initrd={{ pxe_options.deployment_ari_path }} text {{ pxe_options.pxe_append_params }}
label boot_partition
kernel {{ pxe_options.aki_path }}
append initrd={{ pxe_options.ari_path }} root={{ ROOT }} ro text {{ pxe_options.pxe_append_params|default("", true) }}
label boot_whole_disk
COM32 chain.c32
append mbr:{{ DISK_IDENTIFIER }}

6
ironic/drivers/modules/ansible/deploy.py

@ -396,12 +396,6 @@ class AnsibleDeploy(agent_base.HeartbeatMixin,
task.driver.boot.validate(task)
node = task.node
iwdi = node.driver_internal_info.get('is_whole_disk_image')
if not iwdi and deploy_utils.get_boot_option(node) == "netboot":
raise exception.InvalidParameterValue(_(
"Node %(node)s is configured to use the ansible deploy "
"interface, which does not support netboot.") %
{'node': node.uuid})
params = {}
image_source = node.instance_info.get('image_source')

12
ironic/drivers/modules/deploy_utils.py

@ -55,7 +55,6 @@ LOG = logging.getLogger(__name__)
METRICS = metrics_utils.get_metrics_logger(__name__)
SUPPORTED_CAPABILITIES = {
'boot_option': ('local', 'netboot', 'ramdisk', 'kickstart'),
'boot_mode': ('bios', 'uefi'),
'secure_boot': ('true', 'false'),
'disk_label': ('msdos', 'gpt'),
@ -159,6 +158,9 @@ def _replace_disk_identifier(path, disk_identifier):
# NOTE(TheJulia): This should likely be migrated to pxe_utils.
# TODO(dtantsur): with the removal of netboot, root_uuid_or_disk_id and
# the logic of replacing ROOT can be dropped, while is_whole_disk_image can
# be renamed to something like netboot_fallback.
def switch_pxe_config(path, root_uuid_or_disk_id, boot_mode,
is_whole_disk_image, iscsi_boot=False,
ramdisk_boot=False, ipxe_enabled=False,
@ -616,17 +618,11 @@ def get_boot_option(node):
:returns: A string representing the boot option type. Defaults to
configuration setting [deploy]default_boot_mode.
"""
# NOTE(TheJulia): Software raid always implies local deployment
if is_software_raid(node):
return 'local'
if is_anaconda_deploy(node):
return 'kickstart'
if is_ramdisk_deploy(node):
return 'ramdisk'
capabilities = utils.parse_instance_info_capabilities(node)
return capabilities.get('boot_option',
CONF.deploy.default_boot_option).lower()
return 'local'
# FIXME(dtantsur): relying on deploy interface name is an anti-pattern.

27
ironic/drivers/modules/ilo/boot.py

@ -320,7 +320,7 @@ class IloVirtualMediaBoot(base.BootInterface):
except exception.ImageRefValidationFailed:
with excutils.save_and_reraise_exception():
LOG.error("Virtual media deploy with 'ramdisk' "
"boot_option accepts only Glance images or "
"deploy accepts only Glance images or "
"HTTP(S) URLs as "
"instance_info['boot_iso']. Either %s "
"is not a valid HTTP(S) URL or is not "
@ -460,21 +460,8 @@ class IloVirtualMediaBoot(base.BootInterface):
boot_devices.CDROM,
persistent=True)
else:
# Boot from disk every time if the image deployed is
# a whole disk image.
node = task.node
iwdi = node.driver_internal_info.get('is_whole_disk_image')
if deploy_utils.get_boot_option(node) == "local" or iwdi:
manager_utils.node_set_boot_device(task, boot_devices.DISK,
persistent=True)
else:
drv_int_info = node.driver_internal_info
root_uuid_or_disk_id = drv_int_info.get('root_uuid_or_disk_id')
if root_uuid_or_disk_id:
self._configure_vmedia_boot(task, root_uuid_or_disk_id)
else:
LOG.warning("The UUID for the root partition could not "
"be found for node %s", node.uuid)
manager_utils.node_set_boot_device(task, boot_devices.DISK,
persistent=True)
# Set boot mode
ilo_common.update_boot_mode(task)
# Need to enable secure boot, if being requested
@ -590,8 +577,7 @@ class IloPXEBoot(pxe.PXEBoot):
"""Prepares the boot of instance.
This method prepares the boot of the instance after reading
relevant information from the node's instance_info. In case of netboot,
it updates the dhcp entries and switches the PXE config. In case of
relevant information from the node's instance_info. In case of
localboot, it cleans up the PXE config.
In case of 'boot from volume', it updates the iSCSI info onto iLO and
sets the node to boot from 'UefiTarget' boot device.
@ -683,8 +669,7 @@ class IloiPXEBoot(ipxe.iPXEBoot):
"""Prepares the boot of instance.
This method prepares the boot of the instance after reading
relevant information from the node's instance_info. In case of netboot,
it updates the dhcp entries and switches the PXE config. In case of
relevant information from the node's instance_info. In case of
localboot, it cleans up the PXE config.
In case of 'boot from volume', it updates the iSCSI info onto iLO and
sets the node to boot from 'UefiTarget' boot device.
@ -904,7 +889,7 @@ class IloUefiHttpsBoot(base.BootInterface):
except exception.ImageRefValidationFailed:
with excutils.save_and_reraise_exception():
LOG.error("UEFI-HTTPS boot with 'ramdisk' "
"boot_option accepts only Glance images or "
"deploy accepts only Glance images or "
"HTTPS URLs as "
"instance_info['boot_iso']. Either %s "
"is not a valid HTTPS URL or is not "

5
ironic/drivers/modules/ilo/power.py

@ -44,9 +44,8 @@ def _attach_boot_iso_if_needed(task):
This method checks the instance info of the baremetal node for a
boot iso. If the instance info has a value of key 'boot_iso',
it indicates that 'boot_option' is 'netboot'. Therefore it attaches
the boot ISO on the baremetal node and then sets the node to boot from
virtual media cdrom.
it indicates ramdisk deploy. Therefore it attaches the boot ISO on the
baremetal node and then sets the node to boot from virtual media cdrom.
:param task: a TaskManager instance containing the node to act on.
"""

6
ironic/drivers/modules/ipxe_config.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.aki_path }} root={{ ROOT }} ro text {{ pxe_options.pxe_append_params|default("", true) }} initrd=ramdisk || goto boot_partition
initrd {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.ari_path }} || goto boot_partition
boot
:boot_anaconda
imgfree
kernel {% if pxe_options.ipxe_timeout > 0 %}--timeout {{ pxe_options.ipxe_timeout }} {% endif %}{{ pxe_options.aki_path }} text {{ pxe_options.pxe_append_params|default("", true) }} inst.ks={{ pxe_options.ks_cfg_url }} {% if pxe_options.repo_url %}inst.repo={{ pxe_options.repo_url }}{% else %}inst.stage2={{ pxe_options.stage2_url }}{% endif %} initrd=ramdisk || goto boot_anaconda

5
ironic/drivers/modules/irmc/boot.py

@ -376,9 +376,8 @@ def attach_boot_iso_if_needed(task):
This method checks the instance info of the bare metal node for a
boot ISO. If the instance info has a value of key 'boot_iso',
it indicates that 'boot_option' is 'netboot'. Threfore it attaches
the boot ISO on the bare metal node and then sets the node to boot from
virtual media cdrom.
it indicates ramdisk deploy. Therefore it attaches the boot ISO on the bare
metal node and then sets the node to boot from virtual media cdrom.
:param task: a TaskManager instance containing the node to act on.
:raises: IRMCOperationError if attaching virtual media failed.

11
ironic/drivers/modules/network/neutron.py

@ -20,9 +20,7 @@ from oslo_log import log
from ironic.common import exception
from ironic.common.i18n import _
from ironic.common import neutron
from ironic.common import states
from ironic.drivers import base
from ironic.drivers.modules import deploy_utils
from ironic.drivers.modules.network import common
LOG = log.getLogger(__name__)
@ -61,15 +59,6 @@ class NeutronNetwork(common.NeutronVIFPortIDMixin,
"""
self.get_cleaning_network_uuid(task)
self.get_provisioning_network_uuid(task)
node = task.node
if (node.provision_state == states.DEPLOYING
and node.driver_internal_info.get('is_whole_disk_image')
and deploy_utils.get_boot_option(node) == 'netboot'):
error_msg = (_('The node %s cannot perform "local" boot for '
'whole disk image when node is using "neutron" '
'network and is configured with "netboot" boot '
'option.') % node.uuid)
raise exception.InvalidParameterValue(error_msg)
def _add_network(self, task, network, security_groups, process):
# If we have left over ports from a previous process, remove them

44
ironic/drivers/modules/pxe_base.py

@ -261,50 +261,6 @@ class PXEBaseMixin(object):
anaconda_boot=(boot_option == "kickstart"))
boot_device = boot_devices.PXE
elif boot_option != "local":
if task.driver.storage.should_write_image(task):
# Make sure that the instance kernel/ramdisk is cached.
# This is for the takeover scenario for active nodes.
instance_image_info = pxe_utils.get_instance_image_info(
task, ipxe_enabled=self.ipxe_enabled)
pxe_utils.cache_ramdisk_kernel(task, instance_image_info,
ipxe_enabled=self.ipxe_enabled)
# If it's going to PXE boot we need to update the DHCP server
dhcp_opts = pxe_utils.dhcp_options_for_instance(
task, ipxe_enabled=self.ipxe_enabled, ip_version=4)
dhcp_opts += pxe_utils.dhcp_options_for_instance(
task, ipxe_enabled=self.ipxe_enabled, ip_version=6)
provider = dhcp_factory.DHCPFactory()
provider.update_dhcp(task, dhcp_opts)
iwdi = task.node.driver_internal_info.get('is_whole_disk_image')
try:
root_uuid_or_disk_id = task.node.driver_internal_info[
'root_uuid_or_disk_id'
]
except KeyError:
if not task.driver.storage.should_write_image(task):
pass
elif not iwdi:
LOG.warning("The UUID for the root partition can't be "
"found, unable to switch the pxe config from "
"deployment mode to service (boot) mode for "
"node %(node)s", {"node": task.node.uuid})
else:
LOG.warning("The disk id for the whole disk image can't "
"be found, unable to switch the pxe config "
"from deployment mode to service (boot) mode "
"for node %(node)s. Booting the instance "
"from disk.", {"node": task.node.uuid})
pxe_utils.clean_up_pxe_config(
task, ipxe_enabled=self.ipxe_enabled)
boot_device = boot_devices.DISK
else:
pxe_utils.build_service_pxe_config(
task, instance_image_info, root_uuid_or_disk_id,
ipxe_enabled=self.ipxe_enabled)
boot_device = boot_devices.PXE
else:
# NOTE(dtantsur): create a PXE configuration as a safety net for
# hardware uncapable of persistent boot. If on a reboot it will try

6
ironic/drivers/modules/pxe_config.template

@ -5,12 +5,6 @@ kernel {{ pxe_options.deployment_aki_path }}
append initrd={{ pxe_options.deployment_ari_path }} selinux=0 troubleshoot=0 text {{ pxe_options.pxe_append_params|default("", true) }}
ipappend 2
label boot_partition
kernel {{ pxe_options.aki_path }}
append initrd={{ pxe_options.ari_path }} root={{ ROOT }} ro text {{ pxe_options.pxe_append_params|default("", true) }}
label boot_whole_disk
COM32 chain.c32
append mbr:{{ DISK_IDENTIFIER }}

5
ironic/drivers/modules/pxe_grub_config.template

@ -7,11 +7,6 @@ menuentry "deploy" {
initrdefi {{ pxe_options.deployment_ari_path }}
}
menuentry "boot_partition" {
linuxefi {{ pxe_options.aki_path }} root={{ ROOT }} ro text {{ pxe_options.pxe_append_params|default("", true) }} boot_server={{pxe_options.tftp_server}}
initrdefi {{ pxe_options.ari_path }}
}
menuentry "boot_ramdisk" {
linuxefi {{ pxe_options.aki_path }} root=/dev/ram0 text {{ pxe_options.pxe_append_params|default("", true) }} {{ pxe_options.ramdisk_opts|default('', true) }}
initrdefi {{ pxe_options.ari_path }}

19
ironic/tests/unit/common/test_pxe_utils.py

@ -1295,25 +1295,6 @@ class PXEInterfacesTestCase(db_base.DbTestCase):
self.assertEqual('instance_ramdisk_uuid',
task.node.instance_info['ramdisk'])
def test_get_instance_image_info(self):
# Tests when 'is_whole_disk_image' exists in driver_internal_info
# NOTE(TheJulia): The method being tested is primarily geared for
# only netboot operation as the information should only need to be
# looked up again during network booting.
self.config(group="deploy", default_boot_option="netboot")
self._test_get_instance_image_info()
def test_get_instance_image_info_without_is_whole_disk_image(self):
# NOTE(TheJulia): The method being tested is primarily geared for
# only netboot operation as the information should only need to be
# looked up again during network booting.
self.config(group="deploy", default_boot_option="netboot")
# Tests when 'is_whole_disk_image' doesn't exists in
# driver_internal_info
del self.node.driver_internal_info['is_whole_disk_image']
self.node.save()
self._test_get_instance_image_info()
@mock.patch('ironic.drivers.modules.deploy_utils.get_boot_option',
return_value='local', autospec=True)
def test_get_instance_image_info_localboot(self, boot_opt_mock):

40
ironic/tests/unit/conductor/test_manager.py

@ -7319,7 +7319,6 @@ class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
mock_take_over.assert_called_once_with(task.driver.deploy, task)
self.assertFalse(mock_start_console.called)
mock_boot_validate.assert_not_called()
self.assertNotIn('is_whole_disk_image', task.node.driver_internal_info)
@mock.patch('ironic.common.image_service.HttpImageService.validate_href',
autospec=True)
@ -7328,26 +7327,23 @@ class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeBoot.validate', autospec=True)
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console',
autospec=True)
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.take_over',
@mock.patch('ironic.drivers.modules.ramdisk.RamdiskDeploy.take_over',
autospec=True)
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare',
@mock.patch('ironic.drivers.modules.ramdisk.RamdiskDeploy.prepare',
autospec=True)
def test__do_adoption_with_netboot(self,
mock_prepare,
mock_take_over,
mock_start_console,
mock_boot_validate,
mock_power_validate,
mock_validate_href):
def test__do_adoption_ramdisk_deploy(self,
mock_prepare,
mock_take_over,
mock_start_console,
mock_boot_validate,
mock_power_validate,
mock_validate_href):
"""Test a successful node adoption"""
self._start_service()
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
provision_state=states.ADOPTING,
instance_info={
'capabilities': {'boot_option': 'netboot'},
'image_source': 'http://127.0.0.1/image',
})
deploy_interface='ramdisk',
provision_state=states.ADOPTING)
task = task_manager.TaskManager(self.context, node.uuid)
self.service._do_adoption(task)
@ -7360,10 +7356,6 @@ class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
mock_take_over.assert_called_once_with(task.driver.deploy, task)
self.assertFalse(mock_start_console.called)
mock_boot_validate.assert_called_once_with(task.driver.boot, task)
self.assertTrue(task.node.driver_internal_info.get(
'is_whole_disk_image'))
mock_validate_href.assert_called_once_with(mock.ANY,
'http://127.0.0.1/image')
@mock.patch('ironic.drivers.modules.fake.FakeBoot.validate', autospec=True)
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console',
@ -7410,9 +7402,9 @@ class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
@mock.patch('ironic.drivers.modules.fake.FakeBoot.validate', autospec=True)
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console',
autospec=True)
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.take_over',
@mock.patch('ironic.drivers.modules.ramdisk.RamdiskDeploy.take_over',
autospec=True)
@mock.patch('ironic.drivers.modules.fake.FakeDeploy.prepare',
@mock.patch('ironic.drivers.modules.ramdisk.RamdiskDeploy.prepare',
autospec=True)
def test__do_adoption_boot_validate_failure(self,
mock_prepare,
@ -7428,10 +7420,8 @@ class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
self._start_service()
node = obj_utils.create_test_node(
self.context, driver='fake-hardware',
provision_state=states.ADOPTING,
instance_info={
'capabilities': {'boot_option': 'netboot'},
})
deploy_interface='ramdisk',
provision_state=states.ADOPTING)
task = task_manager.TaskManager(self.context, node.uuid)
self.service._do_adoption(task)

6
ironic/tests/unit/drivers/ipxe_config.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.stage2=http://fake/stage2 initrd=ramdisk || goto boot_anaconda

6
ironic/tests/unit/drivers/ipxe_config_boot_from_anaconda.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.repo=http://1.2.3.4/path/to/os/ initrd=ramdisk || goto boot_anaconda

6
ironic/tests/unit/drivers/ipxe_config_boot_from_iso.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.stage2=http://fake/stage2 initrd=ramdisk || goto boot_anaconda

6
ironic/tests/unit/drivers/ipxe_config_boot_from_ramdisk.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.stage2=http://fake/stage2 initrd=ramdisk || goto boot_anaconda

6
ironic/tests/unit/drivers/ipxe_config_boot_from_volume_extra_volume.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.stage2=http://fake/stage2 initrd=ramdisk || goto boot_anaconda

6
ironic/tests/unit/drivers/ipxe_config_boot_from_volume_multipath.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.stage2=http://fake/stage2 initrd=ramdisk || goto boot_anaconda

6
ironic/tests/unit/drivers/ipxe_config_boot_from_volume_no_extra_volumes.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.stage2=http://fake/stage2 initrd=ramdisk || goto boot_anaconda

6
ironic/tests/unit/drivers/ipxe_config_timeout.template

@ -25,12 +25,6 @@ echo Powering off in 30 seconds.
sleep 30
poweroff
:boot_partition
imgfree
kernel --timeout 120 http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk || goto boot_partition
initrd --timeout 120 http://1.2.3.4:1234/ramdisk || goto boot_partition
boot
:boot_anaconda
imgfree
kernel --timeout 120 http://1.2.3.4:1234/kernel text test_param inst.ks=http://fake/ks.cfg inst.stage2=http://fake/stage2 initrd=ramdisk || goto boot_anaconda

18
ironic/tests/unit/drivers/modules/ansible/test_deploy.py

@ -623,24 +623,6 @@ class TestAnsibleDeploy(AnsibleDeployTestCaseBase):
{'instance_info.image_source': INSTANCE_INFO['image_source']},
mock.ANY)
@mock.patch.object(deploy_utils, 'get_boot_option',
return_value='netboot', autospec=True)
@mock.patch.object(pxe.PXEBoot, 'validate', autospec=True)
def test_validate_not_iwdi_netboot(self, pxe_boot_validate_mock,
get_boot_mock):
driver_internal_info = dict(DRIVER_INTERNAL_INFO)
driver_internal_info['is_whole_disk_image'] = False
self.node.driver_internal_info = driver_internal_info
self.node.save()
with task_manager.acquire(
self.context, self.node['uuid'], shared=False) as task:
self.assertRaises(exception.InvalidParameterValue,
self.driver.validate, task)
pxe_boot_validate_mock.assert_called_once_with(
task.driver.boot, task)
get_boot_mock.assert_called_once_with(task.node)
@mock.patch.object(ansible_deploy, '_calculate_memory_req', autospec=True,
return_value=2000)
@mock.patch.object(utils, 'node_power_action', autospec=True)

123
ironic/tests/unit/drivers/modules/ilo/test_boot.py

@ -452,14 +452,14 @@ class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
spec_set=True, autospec=True)
@mock.patch.object(service_utils, 'is_glance_image', spec_set=True,
autospec=True)
def test_validate_ramdisk_boot_option_glance(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock):
def test_validate_ramdisk_deploy_glance(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock):
instance_info = self.node.instance_info
boot_iso = '6b2f0c0c-79e8-4db6-842e-43c9764204af'
instance_info['boot_iso'] = boot_iso
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
self.node.instance_info = instance_info
self.node.deploy_interface = 'ramdisk'
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@ -475,14 +475,14 @@ class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
spec_set=True, autospec=True)
@mock.patch.object(service_utils, 'is_glance_image', spec_set=True,
autospec=True)
def test_validate_ramdisk_boot_option_webserver(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock):
def test_validate_ramdisk_deploy_webserver(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock):
instance_info = self.node.instance_info
boot_iso = 'http://myserver/boot.iso'
instance_info['boot_iso'] = boot_iso
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
self.node.instance_info = instance_info
self.node.deploy_interface = 'ramdisk'
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@ -499,18 +499,18 @@ class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
spec_set=True, autospec=True)
@mock.patch.object(service_utils, 'is_glance_image', spec_set=True,
autospec=True)
def test_validate_ramdisk_boot_option_webserver_exc(self,
is_glance_image_mock,
validate_href_mock,
val_driver_info_mock,
log_mock):
def test_validate_ramdisk_deploy_webserver_exc(self,
is_glance_image_mock,
validate_href_mock,
val_driver_info_mock,
log_mock):
instance_info = self.node.instance_info
validate_href_mock.side_effect = exception.ImageRefValidationFailed(
image_href='http://myserver/boot.iso', reason='fail')
boot_iso = 'http://myserver/boot.iso'
instance_info['boot_iso'] = boot_iso
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
self.node.instance_info = instance_info
self.node.deploy_interface = 'ramdisk'
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@ -523,7 +523,7 @@ class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
is_glance_image_mock.assert_called_once_with(boot_iso)
validate_href_mock.assert_called_once_with(mock.ANY, boot_iso)
self.assertFalse(val_driver_info_mock.called)
self.assertIn("Virtual media deploy with 'ramdisk' boot_option "
self.assertIn("Virtual media deploy with 'ramdisk' deploy "
"accepts only Glance images or HTTP(S) URLs as "
"instance_info['boot_iso'].",
log_mock.call_args[0][0])
@ -857,7 +857,7 @@ class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
autospec=True)
@mock.patch.object(ilo_common, 'cleanup_vmedia_boot', spec_set=True,
autospec=True)
def _test_prepare_instance_whole_disk_image(
def test_prepare_instance_whole_disk_image(
self, cleanup_vmedia_boot_mock, set_boot_device_mock,
update_boot_mode_mock, update_secure_boot_mode_mock,
is_iscsi_boot_mock):
@ -877,41 +877,31 @@ class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
self.assertIsNone(task.node.driver_internal_info.get(
'ilo_uefi_iscsi_boot'))
def test_prepare_instance_whole_disk_image_local(self):
self.node.instance_info = {'capabilities': '{"boot_option": "local"}'}
self.node.save()
self._test_prepare_instance_whole_disk_image()
def test_prepare_instance_whole_disk_image(self):
self._test_prepare_instance_whole_disk_image()
@mock.patch.object(deploy_utils, 'is_iscsi_boot',
spec_set=True, autospec=True)
@mock.patch.object(boot_mode_utils, 'configure_secure_boot_if_needed',
spec_set=True, autospec=True)
@mock.patch.object(ilo_common, 'update_boot_mode', spec_set=True,
autospec=True)
@mock.patch.object(ilo_boot.IloVirtualMediaBoot,
'_configure_vmedia_boot', spec_set=True,
@mock.patch.object(manager_utils, 'node_set_boot_device', spec_set=True,
autospec=True)
@mock.patch.object(ilo_common, 'cleanup_vmedia_boot', spec_set=True,
autospec=True)
def test_prepare_instance_partition_image(
self, cleanup_vmedia_boot_mock, configure_vmedia_mock,
self, cleanup_vmedia_boot_mock, set_boot_device_mock,
update_boot_mode_mock, update_secure_boot_mode_mock,
is_iscsi_boot_mock):
self.node.driver_internal_info = {'root_uuid_or_disk_id': (
"12312642-09d3-467f-8e09-12385826a123")}
self.node.instance_info = {
'capabilities': {'boot_option': 'netboot'}}
self.node.save()
is_iscsi_boot_mock.return_value = False
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
task.driver.boot.prepare_instance(task)
cleanup_vmedia_boot_mock.assert_called_once_with(task)
configure_vmedia_mock.assert_called_once_with(
mock.ANY, task, "12312642-09d3-467f-8e09-12385826a123")
set_boot_device_mock.assert_called_once_with(task,
boot_devices.DISK,
persistent=True)
update_boot_mode_mock.assert_called_once_with(task)
update_secure_boot_mode_mock.assert_called_once_with(task)
self.assertIsNone(task.node.driver_internal_info.get(
@ -998,9 +988,7 @@ class IloVirtualMediaBootTestCase(test_common.BaseIloTest):
cleanup_vmedia_boot_mock):
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
instance_info = task.node.instance_info
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
task.node.instance_info = instance_info
task.node.deploy_interface = 'ramdisk'
task.node.save()
is_iscsi_boot_mock.return_value = False
url = 'http://myserver/boot.iso'
@ -1377,7 +1365,7 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
self.config(enabled_hardware_types=['ilo5'],
enabled_boot_interfaces=['ilo-uefi-https'],
enabled_console_interfaces=['ilo'],
enabled_deploy_interfaces=['direct'],
enabled_deploy_interfaces=['direct', 'ramdisk'],
enabled_inspect_interfaces=['ilo'],
enabled_management_interfaces=['ilo5'],
enabled_power_interfaces=['ilo'],
@ -1653,16 +1641,16 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
spec_set=True, autospec=True)
@mock.patch.object(service_utils, 'is_glance_image', spec_set=True,
autospec=True)
def test_validate_ramdisk_boot_option_glance(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock,
get_boot_mock):
def test_validate_ramdisk_deploy_glance(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock,
get_boot_mock):
get_boot_mock.return_value = 'UEFI'
instance_info = self.node.instance_info
boot_iso = '6b2f0c0c-79e8-4db6-842e-43c9764204af'
instance_info['boot_iso'] = boot_iso
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
self.node.instance_info = instance_info
self.node.deploy_interface = 'ramdisk'
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@ -1680,16 +1668,16 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
spec_set=True, autospec=True)
@mock.patch.object(service_utils, 'is_glance_image', spec_set=True,
autospec=True)
def test_validate_ramdisk_boot_option_webserver(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock,
get_boot_mock):
def test_validate_ramdisk_deploy_webserver(self, is_glance_image_mock,
validate_href_mock,
val_driver_info_mock,
get_boot_mock):
get_boot_mock.return_value = 'UEFI'
instance_info = self.node.instance_info
boot_iso = 'http://myserver/boot.iso'
instance_info['boot_iso'] = boot_iso
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
self.node.instance_info = instance_info
self.node.deploy_interface = 'ramdisk'
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@ -1708,7 +1696,7 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
spec_set=True, autospec=True)
@mock.patch.object(service_utils, 'is_glance_image', spec_set=True,
autospec=True)
def test_validate_ramdisk_boot_option_webserver_exc(
def test_validate_ramdisk_deploy_webserver_exc(
self, is_glance_image_mock, validate_href_mock,
val_driver_info_mock, log_mock, get_boot_mock):
@ -1718,8 +1706,8 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
image_href='http://myserver/boot.iso', reason='fail')
boot_iso = 'http://myserver/boot.iso'
instance_info['boot_iso'] = boot_iso
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
self.node.instance_info = instance_info
self.node.deploy_interface = 'ramdisk'
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
@ -1732,7 +1720,7 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
is_glance_image_mock.assert_called_once_with(boot_iso)
validate_href_mock.assert_called_once_with(mock.ANY, boot_iso)
self.assertFalse(val_driver_info_mock.called)
self.assertIn("UEFI-HTTPS boot with 'ramdisk' boot_option "
self.assertIn("UEFI-HTTPS boot with 'ramdisk' deploy "
"accepts only Glance images or HTTPS URLs as "
"instance_info['boot_iso'].",
log_mock.call_args[0][0])
@ -1902,7 +1890,7 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
spec_set=True, autospec=True)
@mock.patch.object(manager_utils, 'node_set_boot_device', spec_set=True,
autospec=True)
def _test_prepare_instance_local_or_whole_disk_image(
def test_prepare_instance_local_or_whole_disk_image(
self, set_boot_device_mock,
parse_deploy_mock, prepare_iso_mock, setup_uefi_https_mock,
cleanup_iso_mock, update_secureboot_mock):
@ -1919,16 +1907,6 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
prepare_iso_mock.assert_not_called()
setup_uefi_https_mock.assert_not_called()
def test_prepare_instance_image_local(self):
self.node.instance_info = {'capabilities': '{"boot_option": "local"}'}
self.node.save()
self._test_prepare_instance_local_or_whole_disk_image()
def test_prepare_instance_whole_disk_image(self):
self.node.driver_internal_info = {'is_whole_disk_image': True}
self.node.save()
self._test_prepare_instance_local_or_whole_disk_image()
@mock.patch.object(boot_mode_utils, 'configure_secure_boot_if_needed',
spec_set=True, autospec=True)
@mock.patch.object(image_utils, 'cleanup_iso_image', spec_set=True,
@ -1937,41 +1915,30 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
spec_set=True, autospec=True)
@mock.patch.object(image_utils, 'prepare_boot_iso',
spec_set=True, autospec=True)
@mock.patch.object(ilo_boot.IloUefiHttpsBoot, '_parse_deploy_info',
spec_set=True, autospec=True)
@mock.patch.object(manager_utils, 'node_set_boot_device', spec_set=True,
autospec=True)
def test_prepare_instance_partition_image(
self, set_boot_device_mock,
parse_deploy_mock, prepare_iso_mock, setup_uefi_https_mock,
prepare_iso_mock, setup_uefi_https_mock,
cleanup_iso_mock, update_secureboot_mock):
self.node.instance_info = {
'capabilities': '{"boot_option": "netboot"}'
}
self.node.driver_internal_info = {
'root_uuid_or_disk_id': (
"12312642-09d3-467f-8e09-12385826a123")
}
self.node.driver_internal_info.update({'is_whole_disk_image': False})
self.node.save()
d_info = {'a': 'x', 'b': 'y'}
parse_deploy_mock.return_value = d_info
prepare_iso_mock.return_value = "recreated-iso"
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
task.driver.boot.prepare_instance(task)
cleanup_iso_mock.assert_called_once_with(task)
set_boot_device_mock.assert_not_called()
parse_deploy_mock.assert_called_once_with(mock.ANY, task.node)
prepare_iso_mock.assert_called_once_with(
task, d_info, root_uuid='12312642-09d3-467f-8e09-12385826a123')
set_boot_device_mock.assert_called_once_with(task,
boot_devices.DISK,
persistent=True)
prepare_iso_mock.assert_not_called()
update_secureboot_mock.assert_called_once_with(task)
setup_uefi_https_mock.assert_called_once_with(
task, "recreated-iso", True)
self.assertEqual(task.node.instance_info['boot_iso'],
"recreated-iso")
setup_uefi_https_mock.assert_not_called()
@mock.patch.object(boot_mode_utils, 'configure_secure_boot_if_needed',
spec_set=True, autospec=True)
@ -1998,9 +1965,7 @@ class IloUefiHttpsBootTestCase(db_base.DbTestCase):
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
instance_info = task.node.instance_info
instance_info['capabilities'] = '{"boot_option": "ramdisk"}'
task.node.instance_info = instance_info
task.node.deploy_interface = 'ramdisk'
task.node.save()
task.driver.boot.prepare_instance(task)

39
ironic/tests/unit/drivers/modules/irmc/test_boot.py

@ -1144,8 +1144,9 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
autospec=True)
@mock.patch.object(irmc_boot, '_cleanup_vmedia_boot', spec_set=True,
autospec=True)
def _test_prepare_instance_whole_disk_image(
self, _cleanup_vmedia_boot_mock, set_boot_device_mock):
def test_prepare_instance_whole_disk_image(
self, _cleanup_vmedia_boot_mock, set_boot_device_mock,
check_share_fs_mounted_mock):
self.node.driver_internal_info = {'is_whole_disk_image': True}
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
@ -1157,26 +1158,13 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
boot_devices.DISK,
persistent=True)
def test_prepare_instance_whole_disk_image_local(
self, check_share_fs_mounted_mock):
self.node.instance_info = {'capabilities': '{"boot_option": "local"}'}
self.node.save()
self._test_prepare_instance_whole_disk_image()
def test_prepare_instance_whole_disk_image(self,
check_share_fs_mounted_mock):
self._test_prepare_instance_whole_disk_image()
@mock.patch.object(irmc_boot.IRMCVirtualMediaBoot,
'_configure_vmedia_boot', spec_set=True,
@mock.patch.object(manager_utils, 'node_set_boot_device', spec_set=True,
autospec=True)
@mock.patch.object(irmc_boot, '_cleanup_vmedia_boot', spec_set=True,
autospec=True)
def test_prepare_instance_partition_image(
self, _cleanup_vmedia_boot_mock, _configure_vmedia_mock,
self, _cleanup_vmedia_boot_mock, set_boot_device_mock,
check_share_fs_mounted_mock):
self.node.instance_info = {
'capabilities': {'boot_option': 'netboot'}}
self.node.driver_internal_info = {'root_uuid_or_disk_id': "some_uuid"}
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
@ -1184,8 +1172,9 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
task.driver.boot.prepare_instance(task)
_cleanup_vmedia_boot_mock.assert_called_once_with(task)
_configure_vmedia_mock.assert_called_once_with(mock.ANY, task,
"some_uuid")
set_boot_device_mock.assert_called_once_with(task,
boot_devices.DISK,
persistent=True)
@mock.patch.object(irmc_boot, '_cleanup_vmedia_boot', spec_set=True,
autospec=True)
@ -1253,9 +1242,10 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
self.node.driver_internal_info = {'root_uuid_or_disk_id': "12312642"}
self.node.provision_state = states.DEPLOYING
self.node.target_provision_state = states.ACTIVE
self.node.deploy_interface = 'ramdisk'
self.node.instance_info = {
'capabilities': {
"secure_boot": "true", 'boot_option': 'netboot'
"secure_boot": "true"
}
}
self.node.save()
@ -1281,9 +1271,10 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
self.node.driver_internal_info = {'root_uuid_or_disk_id': "12312642"}
self.node.provision_state = states.DEPLOYING
self.node.target_provision_state = states.ACTIVE
self.node.deploy_interface = 'ramdisk'
self.node.instance_info = {
'capabilities': {
"secure_boot": "false", 'boot_option': 'netboot'
"secure_boot": "false"
}
}
self.node.save()
@ -1308,11 +1299,7 @@ class IRMCVirtualMediaBootTestCase(test_common.BaseIRMCTest):
self.node.driver_internal_info = {'root_uuid_or_disk_id': "12312642"}
self.node.provision_state = states.DEPLOYING
self.node.target_provision_state = states.ACTIVE
self.node.instance_info = {
'capabilities': {
'boot_option': 'netboot'
}
}
self.node.deploy_interface = 'ramdisk'
self.node.save()
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:

60
ironic/tests/unit/drivers/modules/network/test_neutron.py

@ -19,7 +19,6 @@ from oslo_utils import uuidutils
from ironic.common import exception
from ironic.common import neutron as neutron_common
from ironic.common import states
from ironic.conductor import task_manager
from ironic.drivers import base as drivers_base
from ironic.drivers.modules.network import neutron
@ -106,65 +105,6 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
context=task.context)],
validate_mock.call_args_list)
@mock.patch.object(neutron_common, 'validate_network', autospec=True)
def test_validate_boot_option_netboot(self, validate_mock):
driver_internal_info = self.node.driver_internal_info
driver_internal_info['is_whole_disk_image'] = True
self.node.driver_internal_info = driver_internal_info
boot_option = {'capabilities': '{"boot_option": "netboot"}'}
self.node.instance_info = boot_option
self.node.provision_state = states.DEPLOYING
self.node.save()
with task_manager.acquire(self.context, self.node.id) as task:
self.assertRaisesRegex(
exception.InvalidParameterValue,
'cannot perform "local" boot for whole disk image',
self.interface.validate, task)
self.assertEqual([mock.call(CONF.neutron.cleaning_network,
'cleaning network',
context=task.context),
mock.call(CONF.neutron.provisioning_network,
'provisioning network',
context=task.context)],
validate_mock.call_args_list)
@mock.patch.object(neutron_common, 'validate_network', autospec=True)
def test_validate_boot_option_netboot_no_exc(self, validate_mock):
CONF.set_override('default_boot_option', 'netboot', 'deploy')
driver_internal_info = self.node.driver_internal_info
driver_internal_info['is_whole_disk_image'] = True
self.node.driver_internal_info = driver_internal_info
self.node.provision_state = states.AVAILABLE
self.node.save()
with task_manager.acquire(self.context, self.node.id) as task:
self.interface.validate(task)
self.assertEqual([mock.call(CONF.neutron.cleaning_network,
'cleaning network',
context=task.context),
mock.call(CONF.neutron.provisioning_network,
'provisioning network',
context=task.context)],
validate_mock.call_args_list)
@mock.patch.object(neutron_common, 'validate_network', autospec=True)
def test_validate_boot_option_local(self, validate_mock):
driver_internal_info = self.node.driver_internal_info
driver_internal_info['is_whole_disk_image'] = True