summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-08-04 13:54:09 +0000
committerGerrit Code Review <review@openstack.org>2020-08-04 13:54:09 +0000
commite11e98d072b47d427f196966166f4552d402c830 (patch)
tree6642b81a2516072d017b39d537e19a8f362ac2f2
parent24e7670d51f37015893511f6c2bc83006d20ff3c (diff)
parent0f2836a0e441390ac00ca47ba8097e942a9c9503 (diff)
downloadironic-python-agent-e11e98d072b47d427f196966166f4552d402c830.tar.gz
Merge "Return the final RAID configuration from apply_configuration" into stable/ussuri6.1.1
-rw-r--r--ironic_python_agent/hardware.py2
-rw-r--r--ironic_python_agent/tests/unit/test_hardware.py63
-rw-r--r--releasenotes/notes/apply-raid-aeca7848c6320d6b.yaml6
3 files changed, 70 insertions, 1 deletions
diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py
index cae30228..b8dc644c 100644
--- a/ironic_python_agent/hardware.py
+++ b/ironic_python_agent/hardware.py
@@ -1585,7 +1585,7 @@ class GenericHardwareManager(HardwareManager):
self.validate_configuration(raid_config, node)
if delete_existing:
self.delete_configuration(node, ports)
- self._do_create_configuration(node, ports, raid_config)
+ return self._do_create_configuration(node, ports, raid_config)
def create_configuration(self, node, ports):
"""Create a RAID configuration.
diff --git a/ironic_python_agent/tests/unit/test_hardware.py b/ironic_python_agent/tests/unit/test_hardware.py
index 4a69692f..e298212b 100644
--- a/ironic_python_agent/tests/unit/test_hardware.py
+++ b/ironic_python_agent/tests/unit/test_hardware.py
@@ -2784,6 +2784,69 @@ class TestGenericHardwareManager(base.IronicAgentTest):
self.hardware.validate_configuration,
self.node, [])
+ @mock.patch.object(hardware.GenericHardwareManager,
+ '_do_create_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'delete_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'validate_configuration', autospec=True)
+ def test_apply_configuration(self, mocked_validate, mocked_delete,
+ mocked_create):
+ raid_config = {
+ "logical_disks": [
+ {
+ "size_gb": "10",
+ "raid_level": "1",
+ "controller": "software",
+ },
+ {
+ "size_gb": "MAX",
+ "raid_level": "0",
+ "controller": "software",
+ },
+ ]
+ }
+
+ result = self.hardware.apply_configuration(self.node, [], raid_config)
+ self.assertIs(result, mocked_create.return_value)
+ mocked_validate.assert_called_once_with(self.hardware, raid_config,
+ self.node)
+ mocked_delete.assert_called_once_with(self.hardware, self.node, [])
+ mocked_create.assert_called_once_with(self.hardware, self.node, [],
+ raid_config)
+
+ @mock.patch.object(hardware.GenericHardwareManager,
+ '_do_create_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'delete_configuration', autospec=True)
+ @mock.patch.object(hardware.GenericHardwareManager,
+ 'validate_configuration', autospec=True)
+ def test_apply_configuration_no_delete(self, mocked_validate,
+ mocked_delete, mocked_create):
+ raid_config = {
+ "logical_disks": [
+ {
+ "size_gb": "10",
+ "raid_level": "1",
+ "controller": "software",
+ },
+ {
+ "size_gb": "MAX",
+ "raid_level": "0",
+ "controller": "software",
+ },
+ ]
+ }
+
+ result = self.hardware.apply_configuration(self.node, [], raid_config,
+ delete_existing=False)
+ self.assertIs(result, mocked_create.return_value)
+ mocked_validate.assert_called_once_with(self.hardware, raid_config,
+ self.node)
+ self.assertFalse(mocked_delete.called)
+ mocked_create.assert_called_once_with(self.hardware, self.node, [],
+ raid_config)
+
@mock.patch.object(disk_utils, 'list_partitions', autospec=True)
@mock.patch.object(utils, 'execute', autospec=True)
@mock.patch.object(os.path, 'isdir', autospec=True, return_value=False)
diff --git a/releasenotes/notes/apply-raid-aeca7848c6320d6b.yaml b/releasenotes/notes/apply-raid-aeca7848c6320d6b.yaml
new file mode 100644
index 00000000..aa7c233f
--- /dev/null
+++ b/releasenotes/notes/apply-raid-aeca7848c6320d6b.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+ - |
+ Fixes the return value of the ``apply_configuration`` deploy step: the
+ ``agent`` RAID interface expects the final RAID configuration to be
+ returned.