Esempio n. 1
0
 def test__set_and_wait_already_target_state(self, mock_ps):
     target_state = states.POWER_ON
     mock_ps.side_effect = [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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 def test__set_and_wait_power_off(self, mock_sps, mock_ps):
     target_state = states.POWER_OFF
     mock_ps.side_effect = iter([states.POWER_ON, states.POWER_OFF])
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=True) as task:
         self.assertEqual(states.POWER_OFF,
                          amt_power._set_and_wait(task, target_state))
         mock_sps.assert_called_once_with(task.node, states.POWER_OFF)
         mock_ps.assert_called_with(task.node)
Esempio n. 4
0
 def test__set_and_wait_power_off(self, mock_sps, mock_ps):
     target_state = states.POWER_OFF
     mock_ps.side_effect = [states.POWER_ON, states.POWER_OFF]
     with task_manager.acquire(self.context, self.node.uuid,
                               shared=True) as task:
         self.assertEqual(states.POWER_OFF,
                          amt_power._set_and_wait(task, target_state))
         mock_sps.assert_called_once_with(task.node, states.POWER_OFF)
         mock_ps.assert_called_with(task.node)
Esempio n. 5
0
    def test__set_and_wait_power_on_without_boot_device(self, mock_sps,
                                                        mock_ps):
        target_state = states.POWER_ON
        mock_ps.side_effect = [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 = [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)
Esempio n. 6
0
    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)
Esempio n. 7
0
 def test__set_and_wait_power_on_with_boot_device(self, mock_sps,
                                                  mock_ps, mock_snbd):
     target_state = states.POWER_ON
     boot_device = boot_devices.PXE
     mock_ps.side_effect = [states.POWER_OFF, states.POWER_ON]
     mock_snbd.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
         self.assertEqual(states.POWER_ON,
                          amt_power._set_and_wait(task, target_state))
         mock_snbd.assert_called_with(task.node, boot_devices.PXE)
         mock_sps.assert_called_once_with(task.node, states.POWER_ON)
         mock_ps.assert_called_with(task.node)
Esempio n. 8
0
 def test__set_and_wait_power_on_with_boot_device(self, mock_sps, mock_ps,
                                                  mock_snbd):
     target_state = states.POWER_ON
     boot_device = boot_devices.PXE
     mock_ps.side_effect = [states.POWER_OFF, states.POWER_ON]
     mock_snbd.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
         self.assertEqual(states.POWER_ON,
                          amt_power._set_and_wait(task, target_state))
         mock_snbd.assert_called_with(task.node, boot_devices.PXE)
         mock_sps.assert_called_once_with(task.node, states.POWER_ON)
         mock_ps.assert_called_with(task.node)