コード例 #1
0
    def _wait_for_shutting_down_vms(self):
        """
        Wait loop checking remaining VMs in vm container

        This method is helper method that highers the
        probability of engine to properly acknowledge
        that all VMs are terminated by host shutdown.

        The VMs are shutdown by external service: libvirt-guests
        The service pauses system shutdown on systemd shutdown
        and gracefully shutdowns the running VMs.

        This method applies only when the host is in shutdown.
        If the host is running, the method ends immediately.
        """
        # how long to wait before release shutdown
        # we are waiting in whole seconds
        # if config is not present, do not wait
        timeout = config.getint('vars', 'timeout_engine_clear_vms')
        # time to wait in the final phase in seconds
        # it allows host to flush its final state to the engine
        final_wait = 2

        if not host_in_shutdown():
            return

        self.log.info('host in shutdown waiting')

        for _ in range((timeout - final_wait) * 10):
            if not self.vmContainer:
                # once all VMs are cleared exit
                break
            time.sleep(0.1)

        time.sleep(final_wait)
コード例 #2
0
ファイル: clientIF.py プロジェクト: nirs/vdsm
    def _wait_for_shutting_down_vms(self):
        """
        Wait loop checking remaining VMs in vm container

        This method is helper method that highers the
        probability of engine to properly acknowledge
        that all VMs are terminated by host shutdown.

        The VMs are shutdown by external service: libvirt-guests
        The service pauses system shutdown on systemd shutdown
        and gracefully shutdowns the running VMs.

        This method applies only when the host is in shutdown.
        If the host is running, the method ends immediately.
        """
        # how long to wait before release shutdown
        # we are waiting in whole seconds
        # if config is not present, do not wait
        timeout = config.getint('vars', 'timeout_engine_clear_vms')
        # time to wait in the final phase in seconds
        # it allows host to flush its final state to the engine
        final_wait = 2

        if not host_in_shutdown():
            return

        self.log.info('host in shutdown waiting')

        for _ in range((timeout - final_wait) * 10):
            if not self.vmContainer:
                # once all VMs are cleared exit
                break
            time.sleep(0.1)

        time.sleep(final_wait)
コード例 #3
0
ファイル: hostutils_test.py プロジェクト: dong-df/vdsm
    def test_host_not_in_shutdown(self):
        with mock.patch('dbus.SystemBus') as mock_sysbus:
            instance = mock_sysbus()
            obj = instance.get_object()
            obj.ListJobs.return_value = ()
            in_shutdown = hostutils.host_in_shutdown()

        self.assertEqual(in_shutdown, False)
コード例 #4
0
ファイル: hostutils_test.py プロジェクト: nirs/vdsm
    def test_host_not_in_shutdown(self):
        with mock.patch('dbus.SystemBus') as mock_sysbus:
            instance = mock_sysbus()
            obj = instance.get_object()
            obj.ListJobs.return_value = ()
            in_shutdown = hostutils.host_in_shutdown()

        self.assertEqual(in_shutdown, False)
コード例 #5
0
ファイル: hostutils_test.py プロジェクト: dong-df/vdsm
    def test_dbus_exception(self):
        with mock.patch('dbus.SystemBus') as mock_sysbus:
            mock_sysbus.side_effect = dbus.DBusException()
            in_shutdown = hostutils.host_in_shutdown()

        self.assertEqual(in_shutdown, False)
コード例 #6
0
ファイル: hostutils_test.py プロジェクト: nirs/vdsm
    def test_dbus_exception(self):
        with mock.patch('dbus.SystemBus') as mock_sysbus:
            mock_sysbus.side_effect = dbus.DBusException()
            in_shutdown = hostutils.host_in_shutdown()

        self.assertEqual(in_shutdown, False)