From a1475ae2d22139613bd3b089c63d2ccf59a6f3a7 Mon Sep 17 00:00:00 2001 From: Nguyen Van Trung Date: Thu, 26 Jul 2018 14:22:13 +0700 Subject: [PATCH] Refactor RAID configuration via iRMC driver This patch will move resume_clean() to private method for RAID configuration. Due to previous method only mention to RAID info update without generic method for other things. Change-Id: Ic4146b536677b98cc7f66adba7d2e84676f1b095 --- ironic/drivers/modules/irmc/common.py | 8 -------- ironic/drivers/modules/irmc/raid.py | 8 ++++++-- .../tests/unit/drivers/modules/irmc/test_periodic_task.py | 6 +++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/ironic/drivers/modules/irmc/common.py b/ironic/drivers/modules/irmc/common.py index 59fe954500..9f04d74e1e 100644 --- a/ironic/drivers/modules/irmc/common.py +++ b/ironic/drivers/modules/irmc/common.py @@ -21,8 +21,6 @@ import six from ironic.common import exception from ironic.common.i18n import _ -from ironic.common import raid as raid_common -from ironic.conductor import utils as manager_utils from ironic.conf import CONF scci = importutils.try_import('scciclient.irmc.scci') @@ -221,9 +219,3 @@ def set_secure_boot_mode(node, enable): raise exception.IRMCOperationError( operation=_("setting secure boot mode"), error=irmc_exception) - - -def resume_cleaning(task): - raid_common.update_raid_info( - task.node, task.node.raid_config) - manager_utils.notify_conductor_resume_clean(task) diff --git a/ironic/drivers/modules/irmc/raid.py b/ironic/drivers/modules/irmc/raid.py index 1376fe8f68..e366732a37 100644 --- a/ironic/drivers/modules/irmc/raid.py +++ b/ironic/drivers/modules/irmc/raid.py @@ -25,6 +25,7 @@ from ironic.common import exception from ironic.common import raid as raid_common from ironic.common import states from ironic.conductor import task_manager +from ironic.conductor import utils as manager_utils from ironic import conf from ironic.drivers import base from ironic.drivers.modules.irmc import common as irmc_common @@ -478,11 +479,10 @@ class IRMCRAID(base.RAIDInterface): if all(fgi_status == 'Idle' for fgi_status in fgi_status_dict.values()): raid_config.update({'fgi_status': RAID_COMPLETED}) - raid_common.update_raid_info(node, raid_config) LOG.info('RAID configuration has completed on ' 'node %(node)s with fgi_status is %(fgi)s', {'node': node_uuid, 'fgi': RAID_COMPLETED}) - irmc_common.resume_cleaning(task) + self._resume_cleaning(task) except exception.NodeNotFound: LOG.info('During query_raid_config_job_status, node ' @@ -500,3 +500,7 @@ class IRMCRAID(base.RAIDInterface): fgi_message = 'ServerViewRAID not available in Baremetal Server' task.node.last_error = fgi_message task.process_event('fail') + + def _resume_cleaning(self, task): + raid_common.update_raid_info(task.node, task.node.raid_config) + manager_utils.notify_conductor_resume_clean(task) diff --git a/ironic/tests/unit/drivers/modules/irmc/test_periodic_task.py b/ironic/tests/unit/drivers/modules/irmc/test_periodic_task.py index 1874d251d7..15575523cd 100644 --- a/ironic/tests/unit/drivers/modules/irmc/test_periodic_task.py +++ b/ironic/tests/unit/drivers/modules/irmc/test_periodic_task.py @@ -202,7 +202,7 @@ class iRMCPeriodicTaskTestCase(test_common.BaseIRMCTest): fgi_mock.assert_called_once_with(report_mock.return_value, self.node.uuid) - @mock.patch.object(irmc_common, 'resume_cleaning') + @mock.patch('ironic.drivers.modules.irmc.raid.IRMCRAID._resume_cleaning') @mock.patch('ironic.drivers.modules.irmc.raid.IRMCRAID._set_clean_failed') @mock.patch('ironic.drivers.modules.irmc.raid._get_fgi_status') @mock.patch.object(irmc_common, 'get_irmc_report') @@ -230,7 +230,7 @@ class iRMCPeriodicTaskTestCase(test_common.BaseIRMCTest): self.node.uuid) clean_mock.assert_called_once_with(task) - @mock.patch.object(irmc_common, 'resume_cleaning') + @mock.patch('ironic.drivers.modules.irmc.raid.IRMCRAID._resume_cleaning') @mock.patch('ironic.drivers.modules.irmc.raid.IRMCRAID._set_clean_failed') @mock.patch('ironic.drivers.modules.irmc.raid._get_fgi_status') @mock.patch.object(irmc_common, 'get_irmc_report') @@ -260,7 +260,7 @@ class iRMCPeriodicTaskTestCase(test_common.BaseIRMCTest): self.node.uuid) clean_mock.assert_called_once_with(task) - @mock.patch.object(irmc_common, 'resume_cleaning') + @mock.patch('ironic.drivers.modules.irmc.raid.IRMCRAID._resume_cleaning') @mock.patch('ironic.drivers.modules.irmc.raid.IRMCRAID._set_clean_failed') @mock.patch('ironic.drivers.modules.irmc.raid._get_fgi_status') @mock.patch.object(irmc_common, 'get_irmc_report')