summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSirushti Murugesan <sirushti.murugesan@hp.com>2015-03-14 21:51:00 +0530
committerSirushti Murugesan <sirushti.murugesan@hp.com>2015-03-18 09:48:16 +0530
commitdc4947438bbb88cc4dbd08a3ff7279b5e7ea1590 (patch)
tree179bef3fa6fd2ef2fcc48c745c496b46e9c360c8
parent0f1bb1bfb6b34e65e587449c73753df74281cd7a (diff)
downloadironic-dc4947438bbb88cc4dbd08a3ff7279b5e7ea1590.tar.gz
Raise exception for Agent Deploy driver when using partition images
Also, fixed some tests related to common code agent base vendor. Implements blueprint whole-disk-image-support Closes-Bug: #1430454 Change-Id: Ibca9fee3ba86ee29ac9fdcdf19bca6c45bb4856f
-rw-r--r--ironic/drivers/modules/agent.py9
-rw-r--r--ironic/drivers/modules/agent_base_vendor.py9
-rw-r--r--ironic/tests/db/utils.py1
-rw-r--r--ironic/tests/drivers/test_agent.py7
-rw-r--r--ironic/tests/drivers/test_agent_base_vendor.py34
5 files changed, 54 insertions, 6 deletions
diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py
index 505e81205..718e96aa2 100644
--- a/ironic/drivers/modules/agent.py
+++ b/ironic/drivers/modules/agent.py
@@ -223,6 +223,15 @@ class AgentDeploy(base.DeployInterface):
"image_source's image_checksum must be provided in "
"instance_info for node %s") % node.uuid)
+ is_whole_disk_image = node.driver_internal_info.get(
+ 'is_whole_disk_image')
+ # TODO(sirushtim): Remove once IPA has support for partition images.
+ if is_whole_disk_image is False:
+ raise exception.InvalidParameterValue(_(
+ "Node %(node)s is configured to use the %(driver)s driver "
+ "which currently does not support deploying partition "
+ "images.") % {'node': node.uuid, 'driver': node.driver})
+
# Validate the root device hints
deploy_utils.parse_root_device_hints(node)
diff --git a/ironic/drivers/modules/agent_base_vendor.py b/ironic/drivers/modules/agent_base_vendor.py
index 542a1a459..03f37a6d0 100644
--- a/ironic/drivers/modules/agent_base_vendor.py
+++ b/ironic/drivers/modules/agent_base_vendor.py
@@ -346,7 +346,7 @@ class BaseAgentVendor(base.VendorInterface):
task.process_event('done')
LOG.info(_LI('Deployment to node %s done'), task.node.uuid)
- def configure_local_boot(self, task, root_uuid,
+ def configure_local_boot(self, task, root_uuid=None,
efi_system_part_uuid=None):
"""Helper method to configure local boot on the node.
@@ -356,14 +356,17 @@ class BaseAgentVendor(base.VendorInterface):
:param task: a TaskManager object containing the node
:param root_uuid: The UUID of the root partition. This is used
- for identifying the partition which contains the image deployed.
+ for identifying the partition which contains the image deployed
+ or None in case of whole disk images which we expect to already
+ have a bootloader installed.
:param efi_system_part_uuid: The UUID of the efi system partition.
This is used only in uef boot mode.
:raises: InstanceDeployFailure if bootloader installation failed or
on encountering error while setting the boot device on the node.
"""
node = task.node
- if not node.driver_internal_info.get('is_whole_disk_image'):
+ if not node.driver_internal_info.get(
+ 'is_whole_disk_image') and root_uuid:
result = self._client.install_bootloader(
node, root_uuid=root_uuid,
efi_system_part_uuid=efi_system_part_uuid)
diff --git a/ironic/tests/db/utils.py b/ironic/tests/db/utils.py
index 677187e80..40ba2d6fa 100644
--- a/ironic/tests/db/utils.py
+++ b/ironic/tests/db/utils.py
@@ -149,6 +149,7 @@ def get_test_agent_driver_info():
def get_test_agent_driver_internal_info():
return {
'agent_url': 'http://127.0.0.1/foo',
+ 'is_whole_disk_image': True,
}
diff --git a/ironic/tests/drivers/test_agent.py b/ironic/tests/drivers/test_agent.py
index aa3213c23..4a491ccb7 100644
--- a/ironic/tests/drivers/test_agent.py
+++ b/ironic/tests/drivers/test_agent.py
@@ -181,6 +181,13 @@ class TestAgentDeploy(db_base.DbTestCase):
self.assertRaises(exception.MissingParameterValue,
self.driver.validate, task)
+ def test_validate_agent_fail_partition_image(self):
+ with task_manager.acquire(
+ self.context, self.node['uuid'], shared=False) as task:
+ task.node.driver_internal_info['is_whole_disk_image'] = False
+ self.assertRaises(exception.InvalidParameterValue,
+ self.driver.validate, task)
+
def test_validate_invalid_root_device_hints(self):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
diff --git a/ironic/tests/drivers/test_agent_base_vendor.py b/ironic/tests/drivers/test_agent_base_vendor.py
index ba70a9f3f..859ccf241 100644
--- a/ironic/tests/drivers/test_agent_base_vendor.py
+++ b/ironic/tests/drivers/test_agent_base_vendor.py
@@ -336,7 +336,9 @@ class TestBaseAgentVendor(db_base.DbTestCase):
'command_status': 'SUCCESS', 'command_error': None}
with task_manager.acquire(self.context, self.node['uuid'],
shared=False) as task:
- self.passthru.configure_local_boot(task, 'some-root-uuid')
+ task.node.driver_internal_info['is_whole_disk_image'] = False
+ self.passthru.configure_local_boot(task,
+ root_uuid='some-root-uuid')
try_set_boot_device_mock.assert_called_once_with(
task, boot_devices.DISK)
install_bootloader_mock.assert_called_once_with(
@@ -351,6 +353,7 @@ class TestBaseAgentVendor(db_base.DbTestCase):
'command_status': 'SUCCESS', 'command_error': None}
with task_manager.acquire(self.context, self.node['uuid'],
shared=False) as task:
+ task.node.driver_internal_info['is_whole_disk_image'] = False
self.passthru.configure_local_boot(
task, root_uuid='some-root-uuid',
efi_system_part_uuid='efi-system-part-uuid')
@@ -360,6 +363,29 @@ class TestBaseAgentVendor(db_base.DbTestCase):
task.node, root_uuid='some-root-uuid',
efi_system_part_uuid='efi-system-part-uuid')
+ @mock.patch.object(deploy_utils, 'try_set_boot_device')
+ @mock.patch.object(agent_client.AgentClient, 'install_bootloader')
+ def test_configure_local_boot_whole_disk_image(
+ self, install_bootloader_mock, try_set_boot_device_mock):
+ with task_manager.acquire(self.context, self.node['uuid'],
+ shared=False) as task:
+ self.passthru.configure_local_boot(task)
+ self.assertFalse(install_bootloader_mock.called)
+ try_set_boot_device_mock.assert_called_once_with(
+ task, boot_devices.DISK)
+
+ @mock.patch.object(deploy_utils, 'try_set_boot_device')
+ @mock.patch.object(agent_client.AgentClient, 'install_bootloader')
+ def test_configure_local_boot_no_root_uuid(
+ self, install_bootloader_mock, try_set_boot_device_mock):
+ with task_manager.acquire(self.context, self.node['uuid'],
+ shared=False) as task:
+ task.node.driver_internal_info['is_whole_disk_image'] = False
+ self.passthru.configure_local_boot(task)
+ self.assertFalse(install_bootloader_mock.called)
+ try_set_boot_device_mock.assert_called_once_with(
+ task, boot_devices.DISK)
+
@mock.patch.object(agent_client.AgentClient, 'install_bootloader')
def test_configure_local_boot_boot_loader_install_fail(
self, install_bootloader_mock):
@@ -370,9 +396,10 @@ class TestBaseAgentVendor(db_base.DbTestCase):
self.node.save()
with task_manager.acquire(self.context, self.node['uuid'],
shared=False) as task:
+ task.node.driver_internal_info['is_whole_disk_image'] = False
self.assertRaises(exception.InstanceDeployFailure,
self.passthru.configure_local_boot,
- task, 'some-root-uuid')
+ task, root_uuid='some-root-uuid')
install_bootloader_mock.assert_called_once_with(
task.node, root_uuid='some-root-uuid',
efi_system_part_uuid=None)
@@ -391,9 +418,10 @@ class TestBaseAgentVendor(db_base.DbTestCase):
self.node.save()
with task_manager.acquire(self.context, self.node['uuid'],
shared=False) as task:
+ task.node.driver_internal_info['is_whole_disk_image'] = False
self.assertRaises(exception.InstanceDeployFailure,
self.passthru.configure_local_boot,
- task, 'some-root-uuid')
+ task, root_uuid='some-root-uuid')
install_bootloader_mock.assert_called_once_with(
task.node, root_uuid='some-root-uuid',
efi_system_part_uuid=None)