def test__set_and_wait_already_target_state(self, mock_ps): target_state = states.POWER_ON mock_ps.side_effect = iter([states.POWER_ON]) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertEqual(states.POWER_ON, amt_power._set_and_wait(task, target_state)) mock_ps.assert_called_with(task.node)
def test__set_and_wait_power_on_without_boot_device(self, mock_sps, mock_ps): target_state = states.POWER_ON mock_ps.side_effect = iter([states.POWER_OFF, states.POWER_ON]) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertEqual(states.POWER_ON, amt_power._set_and_wait(task, target_state)) mock_sps.assert_called_once_with(task.node, states.POWER_ON) mock_ps.assert_called_with(task.node) boot_device = boot_devices.DISK self.node.driver_internal_info['amt_boot_device'] = boot_device mock_ps.side_effect = iter([states.POWER_OFF, states.POWER_ON]) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: self.assertEqual(states.POWER_ON, amt_power._set_and_wait(task, target_state)) mock_sps.assert_called_with(task.node, states.POWER_ON) mock_ps.assert_called_with(task.node)
def test__set_and_wait_power_on_with_boot_device(self, mock_sps, mock_ps, mock_enbd): target_state = states.POWER_ON boot_device = boot_devices.PXE mock_ps.side_effect = iter([states.POWER_OFF, states.POWER_ON]) mock_enbd.return_value = None with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: task.node.driver_internal_info['amt_boot_device'] = boot_device result = amt_power._set_and_wait(task, target_state) self.assertEqual(states.POWER_ON, result) mock_enbd.assert_called_with(task.driver.management, task.node, boot_devices.PXE) mock_sps.assert_called_once_with(task.node, states.POWER_ON) mock_ps.assert_called_with(task.node)