diff --git a/ironic/drivers/modules/oneview/deploy.py b/ironic/drivers/modules/oneview/deploy.py index 0465c386a8..282fce83cb 100644 --- a/ironic/drivers/modules/oneview/deploy.py +++ b/ironic/drivers/modules/oneview/deploy.py @@ -232,7 +232,7 @@ class OneViewIscsiDeploy(iscsi_deploy.ISCSIDeploy, OneViewPeriodicTasks): self.oneview_client = common.get_oneview_client() def get_properties(self): - deploy_utils.get_properties() + return deploy_utils.get_properties() @METRICS.timer('OneViewIscsiDeploy.validate') def validate(self, task): @@ -255,7 +255,7 @@ class OneViewIscsiDeploy(iscsi_deploy.ISCSIDeploy, OneViewPeriodicTasks): if (common.is_dynamic_allocation_enabled(task.node) and not CONF.conductor.automated_clean): deploy_utils.tear_down(self.oneview_client, task) - super(OneViewIscsiDeploy, self).tear_down(task) + return super(OneViewIscsiDeploy, self).tear_down(task) @METRICS.timer('OneViewIscsiDeploy.prepare_cleaning') def prepare_cleaning(self, task): @@ -267,7 +267,7 @@ class OneViewIscsiDeploy(iscsi_deploy.ISCSIDeploy, OneViewPeriodicTasks): def tear_down_cleaning(self, task): if common.is_dynamic_allocation_enabled(task.node): deploy_utils.tear_down_cleaning(self.oneview_client, task) - return super(OneViewIscsiDeploy, self).tear_down_cleaning(task) + super(OneViewIscsiDeploy, self).tear_down_cleaning(task) # NOTE (thiagop): We overwrite this interface because we cannot change the boot @@ -367,7 +367,7 @@ class OneViewAgentDeploy(OneViewAgentDeployMixin, agent.AgentDeploy, self.oneview_client = common.get_oneview_client() def get_properties(self): - deploy_utils.get_properties() + return deploy_utils.get_properties() @METRICS.timer('OneViewAgentDeploy.validate') def validate(self, task): @@ -390,7 +390,7 @@ class OneViewAgentDeploy(OneViewAgentDeployMixin, agent.AgentDeploy, if (common.is_dynamic_allocation_enabled(task.node) and not CONF.conductor.automated_clean): deploy_utils.tear_down(self.oneview_client, task) - super(OneViewAgentDeploy, self).tear_down(task) + return super(OneViewAgentDeploy, self).tear_down(task) @METRICS.timer('OneViewAgentDeploy.prepare_cleaning') def prepare_cleaning(self, task): @@ -402,4 +402,4 @@ class OneViewAgentDeploy(OneViewAgentDeployMixin, agent.AgentDeploy, def tear_down_cleaning(self, task): if common.is_dynamic_allocation_enabled(task.node): deploy_utils.tear_down_cleaning(self.oneview_client, task) - return super(OneViewAgentDeploy, self).tear_down_cleaning(task) + super(OneViewAgentDeploy, self).tear_down_cleaning(task) diff --git a/ironic/tests/unit/drivers/modules/oneview/test_deploy.py b/ironic/tests/unit/drivers/modules/oneview/test_deploy.py index ed31c4c1a2..db9098f2b0 100644 --- a/ironic/tests/unit/drivers/modules/oneview/test_deploy.py +++ b/ironic/tests/unit/drivers/modules/oneview/test_deploy.py @@ -585,6 +585,10 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase): node_id=self.node.id) self.info = common.get_oneview_info(self.node) + def test_get_properties(self, mock_get_ov_client): + expected = common.COMMON_PROPERTIES + self.assertEqual(expected, self.driver.deploy.get_properties()) + @mock.patch.object(iscsi_deploy.ISCSIDeploy, 'validate', spec_set=True, autospec=True) def test_validate(self, iscsi_deploy_validate_mock, mock_get_ov_client): @@ -655,8 +659,9 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase): iscsi_tear_down_mock.return_value = states.DELETED with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: - task.driver.deploy.tear_down(task) + returned_state = task.driver.deploy.tear_down(task) iscsi_tear_down_mock.assert_called_once_with(mock.ANY, task) + self.assertEqual(states.DELETED, returned_state) @mock.patch.object(iscsi_deploy.ISCSIDeploy, 'tear_down', spec_set=True, autospec=True) @@ -674,8 +679,10 @@ class OneViewIscsiDeployTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: - task.driver.deploy.tear_down(task) + returned_state = task.driver.deploy.tear_down(task) iscsi_tear_down_mock.assert_called_once_with(mock.ANY, task) + self.assertEqual(states.DELETED, returned_state) + self.assertTrue(deallocate_server_hardware_mock.called) @mock.patch.object(iscsi_deploy.ISCSIDeploy, 'prepare_cleaning', spec_set=True, autospec=True) @@ -760,6 +767,10 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase): node_id=self.node.id) self.info = common.get_oneview_info(self.node) + def test_get_properties(self, mock_get_ov_client): + expected = common.COMMON_PROPERTIES + self.assertEqual(expected, self.driver.deploy.get_properties()) + @mock.patch.object(agent.AgentDeploy, 'validate', spec_set=True, autospec=True) def test_validate(self, agent_deploy_validate_mock, mock_get_ov_client): @@ -830,8 +841,9 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase): agent_tear_down_mock.return_value = states.DELETED with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: - task.driver.deploy.tear_down(task) + returned_state = task.driver.deploy.tear_down(task) agent_tear_down_mock.assert_called_once_with(mock.ANY, task) + self.assertEqual(states.DELETED, returned_state) @mock.patch.object(agent.AgentDeploy, 'tear_down', spec_set=True, autospec=True) @@ -849,8 +861,10 @@ class OneViewAgentDeployTestCase(db_base.DbTestCase): with task_manager.acquire(self.context, self.node.uuid, shared=False) as task: - task.driver.deploy.tear_down(task) + returned_state = task.driver.deploy.tear_down(task) agent_tear_down_mock.assert_called_once_with(mock.ANY, task) + self.assertEqual(states.DELETED, returned_state) + self.assertTrue(deallocate_server_hardware_mock.called) @mock.patch.object(agent.AgentDeploy, 'prepare_cleaning', spec_set=True, autospec=True) diff --git a/releasenotes/notes/fix-oneview-deploy-return-values-ab2ec6ae568d95a5.yaml b/releasenotes/notes/fix-oneview-deploy-return-values-ab2ec6ae568d95a5.yaml new file mode 100644 index 0000000000..08e75379ac --- /dev/null +++ b/releasenotes/notes/fix-oneview-deploy-return-values-ab2ec6ae568d95a5.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Fixes an issue where the OneView deploy interface does not + return the node properties and in the tear down phase does + not return the state of the node.