From 1018fd5926225b79a9b553f516771f2552e45004 Mon Sep 17 00:00:00 2001 From: Thiago Paiva Date: Mon, 11 Jul 2016 19:18:46 -0300 Subject: [PATCH] Onetime boot when set_boot_device isn't persistent Due to a lack of feature of OneView, python-oneviewclient always set the boot device persistently. Now that one-time boot is implemented, we must use it to save some time deploying instances with *_oneview drivers. Change-Id: I01e6f2917d3077d0dddc298e0810574a5450fe09 Depends-On: I1163048b6edf8778c3a84414804b73eef2c0fd5f Co-Authored-By: Hugo Nicodemos --- ironic/drivers/modules/oneview/management.py | 3 ++- .../drivers/modules/oneview/test_management.py | 16 +++++++++++++++- .../oneview-onetime-boot-64a68e135a45f5e2.yaml | 7 +++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/oneview-onetime-boot-64a68e135a45f5e2.yaml diff --git a/ironic/drivers/modules/oneview/management.py b/ironic/drivers/modules/oneview/management.py index bedcaada49..21aebadb49 100644 --- a/ironic/drivers/modules/oneview/management.py +++ b/ironic/drivers/modules/oneview/management.py @@ -126,7 +126,8 @@ class OneViewManagement(base.ManagementInterface): try: device_to_oneview = BOOT_DEVICE_MAPPING_TO_OV.get(device) self.oneview_client.set_boot_device(oneview_info, - device_to_oneview) + device_to_oneview, + onetime=not persistent) except oneview_exceptions.OneViewException as oneview_exc: msg = (_( "Error setting boot device on OneView. Error: %s") diff --git a/ironic/tests/unit/drivers/modules/oneview/test_management.py b/ironic/tests/unit/drivers/modules/oneview/test_management.py index 8962a00034..6d9f87e23e 100644 --- a/ironic/tests/unit/drivers/modules/oneview/test_management.py +++ b/ironic/tests/unit/drivers/modules/oneview/test_management.py @@ -134,7 +134,21 @@ class OneViewManagementDriverTestCase(db_base.DbTestCase): self.driver.management.set_boot_device(task, boot_devices.PXE) oneview_client.set_boot_device.assert_called_once_with( self.info, - management.BOOT_DEVICE_MAPPING_TO_OV[boot_devices.PXE] + management.BOOT_DEVICE_MAPPING_TO_OV[boot_devices.PXE], + onetime=True + ) + + def test_set_boot_device_persistent(self, mock_get_ov_client): + oneview_client = mock_get_ov_client() + self.driver.management.oneview_client = oneview_client + + with task_manager.acquire(self.context, self.node.uuid) as task: + self.driver.management.set_boot_device(task, boot_devices.PXE, + persistent=True) + oneview_client.set_boot_device.assert_called_once_with( + self.info, + management.BOOT_DEVICE_MAPPING_TO_OV[boot_devices.PXE], + onetime=False ) def test_set_boot_device_invalid_device(self, mock_get_ov_client): diff --git a/releasenotes/notes/oneview-onetime-boot-64a68e135a45f5e2.yaml b/releasenotes/notes/oneview-onetime-boot-64a68e135a45f5e2.yaml new file mode 100644 index 0000000000..b9665fc0a6 --- /dev/null +++ b/releasenotes/notes/oneview-onetime-boot-64a68e135a45f5e2.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - Previously (python-oneviewclient < 2.4.0), due to limitations of + python-oneviewclient, boot device was always set persistenly with + OneView drivers. Now that one-time boot is implemented in python-oneviewclient, + changing the oneview driver to exhibit the expected behavior when + set_boot_device is called with persistent=False.