Пример #1
0
    def reboot(self,
               context,
               instance,
               network_info,
               reboot_type,
               block_device_info=None,
               bad_volumes_callback=None):
        """Reboot the specified instance.

        After this is called successfully, the instance's state
        goes back to power_state.RUNNING. The virtualization
        platform should ensure that the reboot action has completed
        successfully even in cases in which the underlying domain/vm
        is paused or halted/stopped.

        :param instance: nova.objects.instance.Instance
        :param network_info:
           :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
        :param reboot_type: Either a HARD or SOFT reboot
        :param block_device_info: Info pertaining to attached volumes
        :param bad_volumes_callback: Function to handle any bad volumes
            encountered
        """
        self._log_operation(reboot_type + ' reboot', instance)
        vm.reboot(self.adapter, instance, reboot_type == 'HARD')
Пример #2
0
    def test_reboot(self, mock_wrap, mock_lock, mock_pwroff, mock_pwron):
        entry = mock.Mock(state=pvm_bp.LPARState.NOT_ACTIVATED)
        mock_wrap.return_value = entry

        # No power_off
        vm.reboot('adap', self.inst, False)
        mock_lock.assert_called_once_with('power_%s' % self.inst.uuid)
        mock_wrap.assert_called_once_with('adap', self.inst)
        mock_pwron.assert_called_once_with(entry, None)
        self.assertEqual(0, mock_pwroff.call_count)

        mock_pwron.reset_mock()

        # power_off (no power_on)
        entry.state = pvm_bp.LPARState.RUNNING
        for force in (False, True):
            mock_pwroff.reset_mock()
            vm.reboot('adap', self.inst, force)
            self.assertEqual(0, mock_pwron.call_count)
            mock_pwroff.assert_called_once_with(
                entry, None, force_immediate=force, restart=True)

        # PowerVM error is converted
        mock_pwroff.side_effect = pvm_exc.TimeoutError("Timed out")
        self.assertRaises(exception.InstanceRebootFailure,
                          vm.reboot, 'adap', self.inst, True)

        # Non-PowerVM error is raised directly
        mock_pwroff.side_effect = ValueError
        self.assertRaises(ValueError, vm.reboot, 'adap', self.inst, True)
Пример #3
0
    def reboot(self,
               context,
               instance,
               network_info,
               reboot_type,
               block_device_info=None,
               bad_volumes_callback=None,
               accel_info=None):
        """Reboot the specified instance.

        After this is called successfully, the instance's state
        goes back to power_state.RUNNING. The virtualization
        platform should ensure that the reboot action has completed
        successfully even in cases in which the underlying domain/vm
        is paused or halted/stopped.

        :param instance: nova.objects.instance.Instance
        :param network_info: `nova.network.models.NetworkInfo` object
            describing the network metadata.
        :param reboot_type: Either a HARD or SOFT reboot
        :param block_device_info: Info pertaining to attached volumes
        :param bad_volumes_callback: Function to handle any bad volumes
            encountered
        :param accel_info: List of accelerator request dicts. The exact
            data struct is doc'd in nova/virt/driver.py::spawn().
        """
        self._log_operation(reboot_type + ' reboot', instance)
        vm.reboot(self.adapter, instance, reboot_type == 'HARD')
Пример #4
0
    def test_reboot(self, mock_wrap, mock_lock, mock_pwroff, mock_pwron):
        entry = mock.Mock(state=pvm_bp.LPARState.NOT_ACTIVATED)
        mock_wrap.return_value = entry

        # No power_off
        vm.reboot('adap', self.inst, False)
        mock_lock.assert_called_once_with('power_%s' % self.inst.uuid)
        mock_wrap.assert_called_once_with('adap', self.inst)
        mock_pwron.assert_called_once_with(entry, None)
        self.assertEqual(0, mock_pwroff.call_count)

        mock_pwron.reset_mock()

        # power_off (no power_on)
        entry.state = pvm_bp.LPARState.RUNNING
        for force in (False, True):
            mock_pwroff.reset_mock()
            vm.reboot('adap', self.inst, force)
            self.assertEqual(0, mock_pwron.call_count)
            mock_pwroff.assert_called_once_with(entry,
                                                None,
                                                force_immediate=force,
                                                restart=True)

        # PowerVM error is converted
        mock_pwroff.side_effect = pvm_exc.TimeoutError("Timed out")
        self.assertRaises(exception.InstanceRebootFailure, vm.reboot, 'adap',
                          self.inst, True)

        # Non-PowerVM error is raised directly
        mock_pwroff.side_effect = ValueError
        self.assertRaises(ValueError, vm.reboot, 'adap', self.inst, True)
Пример #5
0
    def reboot(self, context, instance, network_info, reboot_type,
               block_device_info=None, bad_volumes_callback=None):
        """Reboot the specified instance.

        After this is called successfully, the instance's state
        goes back to power_state.RUNNING. The virtualization
        platform should ensure that the reboot action has completed
        successfully even in cases in which the underlying domain/vm
        is paused or halted/stopped.

        :param instance: nova.objects.instance.Instance
        :param network_info:
           :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
        :param reboot_type: Either a HARD or SOFT reboot
        :param block_device_info: Info pertaining to attached volumes
        :param bad_volumes_callback: Function to handle any bad volumes
            encountered
        """
        self._log_operation(reboot_type + ' reboot', instance)
        vm.reboot(self.adapter, instance, reboot_type == 'HARD')
Пример #6
0
    def test_reboot(self, mock_wrap, mock_lock, mock_pop, mock_pwroff,
                    mock_pwron):
        entry = mock.Mock(state=pvm_bp.LPARState.NOT_ACTIVATED)
        mock_wrap.return_value = entry

        # No power_off
        vm.reboot('adap', self.inst, False)
        mock_lock.assert_called_once_with('power_%s' % self.inst.uuid)
        mock_wrap.assert_called_once_with('adap', self.inst)
        mock_pwron.assert_called_once_with(entry, None)
        self.assertEqual(0, mock_pwroff.call_count)
        self.assertEqual(0, mock_pop.stop.call_count)

        mock_pwron.reset_mock()

        # power_off (no power_on) hard
        entry.state = pvm_bp.LPARState.RUNNING
        vm.reboot('adap', self.inst, True)
        self.assertEqual(0, mock_pwron.call_count)
        self.assertEqual(0, mock_pwroff.call_count)
        mock_pop.stop.assert_called_once_with(entry, opts=mock.ANY)
        self.assertEqual(
            'PowerOff(immediate=true, operation=shutdown, restart=true)',
            str(mock_pop.stop.call_args[1]['opts']))

        mock_pop.reset_mock()

        # power_off (no power_on) soft
        entry.state = pvm_bp.LPARState.RUNNING
        vm.reboot('adap', self.inst, False)
        self.assertEqual(0, mock_pwron.call_count)
        mock_pwroff.assert_called_once_with(entry, restart=True)
        self.assertEqual(0, mock_pop.stop.call_count)

        mock_pwroff.reset_mock()

        # PowerVM error is converted
        mock_pop.stop.side_effect = pvm_exc.TimeoutError("Timed out")
        self.assertRaises(exception.InstanceRebootFailure, vm.reboot, 'adap',
                          self.inst, True)

        # Non-PowerVM error is raised directly
        mock_pwroff.side_effect = ValueError
        self.assertRaises(ValueError, vm.reboot, 'adap', self.inst, False)
Пример #7
0
    def test_reboot(self, mock_wrap, mock_lock, mock_pop, mock_pwroff,
                    mock_pwron):
        entry = mock.Mock(state=pvm_bp.LPARState.NOT_ACTIVATED)
        mock_wrap.return_value = entry

        # No power_off
        vm.reboot('adap', self.inst, False)
        mock_lock.assert_called_once_with('power_%s' % self.inst.uuid)
        mock_wrap.assert_called_once_with('adap', self.inst)
        mock_pwron.assert_called_once_with(entry, None)
        self.assertEqual(0, mock_pwroff.call_count)
        self.assertEqual(0, mock_pop.stop.call_count)

        mock_pwron.reset_mock()

        # power_off (no power_on) hard
        entry.state = pvm_bp.LPARState.RUNNING
        vm.reboot('adap', self.inst, True)
        self.assertEqual(0, mock_pwron.call_count)
        self.assertEqual(0, mock_pwroff.call_count)
        mock_pop.stop.assert_called_once_with(entry, opts=mock.ANY)
        self.assertEqual(
            'PowerOff(immediate=true, operation=shutdown, restart=true)',
            str(mock_pop.stop.call_args[1]['opts']))

        mock_pop.reset_mock()

        # power_off (no power_on) soft
        entry.state = pvm_bp.LPARState.RUNNING
        vm.reboot('adap', self.inst, False)
        self.assertEqual(0, mock_pwron.call_count)
        mock_pwroff.assert_called_once_with(entry, restart=True)
        self.assertEqual(0, mock_pop.stop.call_count)

        mock_pwroff.reset_mock()

        # PowerVM error is converted
        mock_pop.stop.side_effect = pvm_exc.TimeoutError("Timed out")
        self.assertRaises(exception.InstanceRebootFailure,
                          vm.reboot, 'adap', self.inst, True)

        # Non-PowerVM error is raised directly
        mock_pwroff.side_effect = ValueError
        self.assertRaises(ValueError, vm.reboot, 'adap', self.inst, False)