예제 #1
0
    def _get_domain_info(self, host):
        """Returns information on Guest

        :param host: a host.Host object with current
                     connection. Unfortunatly we need to pass it
                     because of a workaround with < version 1.2..11

        :returns list: [state, maxMem, memory, nrVirtCpu, cpuTime]
        """
        return compat.get_domain_info(libvirt, host, self._domain)
예제 #2
0
    def _get_domain_info(self, host):
        """Returns information on Guest

        :param host: a host.Host object with current
                     connection. Unfortunately we need to pass it
                     because of a workaround with < version 1.2..11

        :returns list: [state, maxMem, memory, nrVirtCpu, cpuTime]
        """
        return compat.get_domain_info(libvirt, host, self._domain)
예제 #3
0
    def test_get_domain_info(self, mock_has_min_version):
        test_host = host.Host("qemu:///system")
        domain = mock.MagicMock()
        expected = [power_state.RUNNING, 512, 512, None, None]
        race = fakelibvirt.make_libvirtError(
            fakelibvirt.libvirtError,
            'ERR',
            error_code=fakelibvirt.VIR_ERR_OPERATION_FAILED,
            error_message='cannot read cputime for domain')

        mock_has_min_version.return_value = True

        domain.info.return_value = expected
        actual = compat.get_domain_info(fakelibvirt, test_host, domain)
        self.assertEqual(actual, expected)
        self.assertEqual(domain.info.call_count, 1)
        domain.info.reset_mock()

        domain.info.side_effect = race
        self.assertRaises(fakelibvirt.libvirtError,
                          compat.get_domain_info,
                          fakelibvirt, test_host, domain)
        self.assertEqual(domain.info.call_count, 1)
        domain.info.reset_mock()

        mock_has_min_version.return_value = False

        domain.info.side_effect = [race, expected]
        actual = compat.get_domain_info(fakelibvirt, test_host, domain)
        self.assertEqual(actual, expected)
        self.assertEqual(domain.info.call_count, 2)
        domain.info.reset_mock()

        domain.info.side_effect = race
        self.assertRaises(fakelibvirt.libvirtError,
                          compat.get_domain_info,
                          fakelibvirt, test_host, domain)
        self.assertEqual(domain.info.call_count, 2)
예제 #4
0
    def test_get_domain_info(self, mock_has_min_version):
        test_host = host.Host("qemu:///system")
        domain = mock.MagicMock()
        expected = [power_state.RUNNING, 512, 512, None, None]
        race = fakelibvirt.make_libvirtError(
            fakelibvirt.libvirtError,
            'ERR',
            error_code=fakelibvirt.VIR_ERR_OPERATION_FAILED,
            error_message='cannot read cputime for domain')

        mock_has_min_version.return_value = True

        domain.info.return_value = expected
        actual = compat.get_domain_info(fakelibvirt, test_host, domain)
        self.assertEqual(actual, expected)
        self.assertEqual(domain.info.call_count, 1)
        domain.info.reset_mock()

        domain.info.side_effect = race
        self.assertRaises(fakelibvirt.libvirtError, compat.get_domain_info,
                          fakelibvirt, test_host, domain)
        self.assertEqual(domain.info.call_count, 1)
        domain.info.reset_mock()

        mock_has_min_version.return_value = False

        domain.info.side_effect = [race, expected]
        actual = compat.get_domain_info(fakelibvirt, test_host, domain)
        self.assertEqual(actual, expected)
        self.assertEqual(domain.info.call_count, 2)
        domain.info.reset_mock()

        domain.info.side_effect = race
        self.assertRaises(fakelibvirt.libvirtError, compat.get_domain_info,
                          fakelibvirt, test_host, domain)
        self.assertEqual(domain.info.call_count, 2)
예제 #5
0
파일: host.py 프로젝트: Milstein/nova
 def get_domain_info(self, virt_dom):
     return compat.get_domain_info(libvirt, self, virt_dom)
예제 #6
0
 def get_domain_info(self, virt_dom):
     return compat.get_domain_info(libvirt, self, virt_dom)