From 25f4881730d80a9142d9cf181618b38185d33c91 Mon Sep 17 00:00:00 2001 From: vmud213 Date: Mon, 16 Oct 2017 15:00:04 +0530 Subject: [PATCH] Updates 'set_one_time_boot' to accept MAC address. To support setting iscsi target as a one time boot option some code changes were made earlier in the `set_one_time_boot` API of 'RISOperations' class. However this doesn't completely address the issue since the 'RISOperations' object can not be used directly and only can be exposed via 'IloClient' class. This requires the API signature to be changed for the 'IloClient', 'IloOperations' and 'RIBCLOperations' classes. Changes 'set_one_time_boot' API signature to allow to accept MAC value which is required when setting the boot device to iscsi target. Change-Id: Ib47345a69e39e3a8183b84d5645c98c923e80b37 Closes-Bug: 1723863 --- proliantutils/ilo/client.py | 4 ++-- proliantutils/ilo/operations.py | 2 +- proliantutils/ilo/ribcl.py | 11 +++++++++-- proliantutils/tests/ilo/test_client.py | 12 +++++++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/proliantutils/ilo/client.py b/proliantutils/ilo/client.py index 1f7133c5..88d6a0e2 100644 --- a/proliantutils/ilo/client.py +++ b/proliantutils/ilo/client.py @@ -328,9 +328,9 @@ class IloClient(operations.IloOperations): """ return self._call_method('set_host_power', power) - def set_one_time_boot(self, value): + def set_one_time_boot(self, value, mac=None): """Configures a single boot from a specific device.""" - return self._call_method('set_one_time_boot', value) + return self._call_method('set_one_time_boot', value, mac) def insert_virtual_media(self, url, device='FLOPPY'): """Notifies iLO of the location of a virtual media diskette image.""" diff --git a/proliantutils/ilo/operations.py b/proliantutils/ilo/operations.py index c9c8f7e2..dfd2ee0b 100644 --- a/proliantutils/ilo/operations.py +++ b/proliantutils/ilo/operations.py @@ -125,7 +125,7 @@ class IloOperations(object): """ raise exception.IloCommandNotSupportedError(ERRMSG) - def set_one_time_boot(self, value): + def set_one_time_boot(self, value, mac=None): """Configures a single boot from a specific device.""" raise exception.IloCommandNotSupportedError(ERRMSG) diff --git a/proliantutils/ilo/ribcl.py b/proliantutils/ilo/ribcl.py index 3a0b9347..93e1fcd7 100644 --- a/proliantutils/ilo/ribcl.py +++ b/proliantutils/ilo/ribcl.py @@ -407,8 +407,15 @@ class RIBCLOperations(operations.IloOperations): raise exception.IloInvalidInputError( "Invalid input. The expected input is ON or OFF.") - def set_one_time_boot(self, value): - """Configures a single boot from a specific device.""" + def set_one_time_boot(self, value, mac=None): + """Configures a single boot from a specific device. + + :param value: specific device to which the boot option is set + :param mac: MAC value of the data NIC in case ISCSI target is + set as boot device. This value may not be used + here since RIBCL does not support setting ISCSI + target. However included here for consistency. + """ dic = {'value': value} data = self._execute_command( 'SET_ONE_TIME_BOOT', 'SERVER_INFO', 'write', dic) diff --git a/proliantutils/tests/ilo/test_client.py b/proliantutils/tests/ilo/test_client.py index c8121fed..e4216cd3 100644 --- a/proliantutils/tests/ilo/test_client.py +++ b/proliantutils/tests/ilo/test_client.py @@ -428,7 +428,13 @@ class IloClientTestCase(testtools.TestCase): @mock.patch.object(client.IloClient, '_call_method') def test_set_one_time_boot(self, call_mock): self.client.set_one_time_boot('CDROM') - call_mock.assert_called_once_with('set_one_time_boot', 'CDROM') + call_mock.assert_called_once_with('set_one_time_boot', 'CDROM', None) + + @mock.patch.object(client.IloClient, '_call_method') + def test_set_one_time_boot_with_mac(self, call_mock): + mac = '3863bb43683c' + self.client.set_one_time_boot('ISCSI', mac) + call_mock.assert_called_once_with('set_one_time_boot', 'ISCSI', mac) @mock.patch.object(client.IloClient, '_call_method') def test_insert_virtual_media(self, call_mock): @@ -801,13 +807,13 @@ class IloClientTestCase(testtools.TestCase): def test_set_one_time_boot_gen9(self, set_one_time_boot_mock): self.client.model = 'Gen9' self.client.set_one_time_boot('cdrom') - set_one_time_boot_mock.assert_called_once_with('cdrom') + set_one_time_boot_mock.assert_called_once_with('cdrom', None) @mock.patch.object(ribcl.RIBCLOperations, 'set_one_time_boot') def test_set_one_time_boot_gen8(self, set_one_time_boot_mock): self.client.model = 'Gen8' self.client.set_one_time_boot('cdrom') - set_one_time_boot_mock.assert_called_once_with('cdrom') + set_one_time_boot_mock.assert_called_once_with('cdrom', None) @mock.patch.object(ris.RISOperations, 'update_persistent_boot') def test_update_persistent_boot_gen9(self, update_persistent_boot_mock):