Merge "Correct reported system memory" into stable/ussuri
This commit is contained in:
commit
4cbeb98c59
|
@ -958,11 +958,9 @@ SwapCached: 0 kB
|
||||||
Active: 8381604 kB
|
Active: 8381604 kB
|
||||||
""")
|
""")
|
||||||
with test.nested(
|
with test.nested(
|
||||||
mock.patch.object(six.moves.builtins, "open", m, create=True),
|
mock.patch.object(builtins, "open", m, create=True),
|
||||||
mock.patch.object(host.Host,
|
mock.patch.object(host.Host, "get_connection"),
|
||||||
"get_connection"),
|
) as (mock_file, mock_conn):
|
||||||
mock.patch('sys.platform', 'linux2'),
|
|
||||||
) as (mock_file, mock_conn, mock_platform):
|
|
||||||
mock_conn().getInfo.return_value = [
|
mock_conn().getInfo.return_value = [
|
||||||
obj_fields.Architecture.X86_64, 15814, 8, 1208, 1, 1, 4, 2]
|
obj_fields.Architecture.X86_64, 15814, 8, 1208, 1, 1, 4, 2]
|
||||||
|
|
||||||
|
@ -1002,8 +1000,7 @@ Active: 8381604 kB
|
||||||
"list_guests"),
|
"list_guests"),
|
||||||
mock.patch.object(libvirt_driver.LibvirtDriver,
|
mock.patch.object(libvirt_driver.LibvirtDriver,
|
||||||
"_conn"),
|
"_conn"),
|
||||||
mock.patch('sys.platform', 'linux2'),
|
) as (mock_file, mock_list, mock_conn):
|
||||||
) as (mock_file, mock_list, mock_conn, mock_platform):
|
|
||||||
mock_list.return_value = [
|
mock_list.return_value = [
|
||||||
libvirt_guest.Guest(DiagFakeDomain(0, 15814)),
|
libvirt_guest.Guest(DiagFakeDomain(0, 15814)),
|
||||||
libvirt_guest.Guest(DiagFakeDomain(1, 750)),
|
libvirt_guest.Guest(DiagFakeDomain(1, 750)),
|
||||||
|
@ -1016,10 +1013,9 @@ Active: 8381604 kB
|
||||||
|
|
||||||
def test_get_memory_used_xen(self):
|
def test_get_memory_used_xen(self):
|
||||||
self.flags(virt_type='xen', group='libvirt')
|
self.flags(virt_type='xen', group='libvirt')
|
||||||
with test.nested(
|
with mock.patch.object(
|
||||||
mock.patch.object(self.host, "_sum_domain_memory_mb"),
|
self.host, "_sum_domain_memory_mb"
|
||||||
mock.patch('sys.platform', 'linux2')
|
) as mock_sumDomainMemory:
|
||||||
) as (mock_sumDomainMemory, mock_platform):
|
|
||||||
mock_sumDomainMemory.return_value = 8192
|
mock_sumDomainMemory.return_value = 8192
|
||||||
self.assertEqual(8192, self.host.get_memory_mb_used())
|
self.assertEqual(8192, self.host.get_memory_mb_used())
|
||||||
mock_sumDomainMemory.assert_called_once_with(include_host=True)
|
mock_sumDomainMemory.assert_called_once_with(include_host=True)
|
||||||
|
@ -1042,11 +1038,7 @@ Active: 8381604 kB
|
||||||
def UUIDString(self):
|
def UUIDString(self):
|
||||||
return uuids.fake
|
return uuids.fake
|
||||||
|
|
||||||
with test.nested(
|
with mock.patch.object(host.Host, 'list_guests') as mock_list:
|
||||||
mock.patch.object(host.Host,
|
|
||||||
"list_guests"),
|
|
||||||
mock.patch('sys.platform', 'linux2'),
|
|
||||||
) as (mock_list, mock_platform):
|
|
||||||
mock_list.return_value = [
|
mock_list.return_value = [
|
||||||
libvirt_guest.Guest(DiagFakeDomain(0, 4096)),
|
libvirt_guest.Guest(DiagFakeDomain(0, 4096)),
|
||||||
libvirt_guest.Guest(DiagFakeDomain(1, 2048)),
|
libvirt_guest.Guest(DiagFakeDomain(1, 2048)),
|
||||||
|
@ -1060,10 +1052,9 @@ Active: 8381604 kB
|
||||||
self.flags(file_backed_memory=1048576,
|
self.flags(file_backed_memory=1048576,
|
||||||
group='libvirt')
|
group='libvirt')
|
||||||
|
|
||||||
with test.nested(
|
with mock.patch.object(
|
||||||
mock.patch.object(self.host, "_sum_domain_memory_mb"),
|
self.host, "_sum_domain_memory_mb"
|
||||||
mock.patch('sys.platform', 'linux2')
|
) as mock_sumDomainMemory:
|
||||||
) as (mock_sumDomainMemory, mock_platform):
|
|
||||||
mock_sumDomainMemory.return_value = 8192
|
mock_sumDomainMemory.return_value = 8192
|
||||||
self.assertEqual(8192, self.host.get_memory_mb_used())
|
self.assertEqual(8192, self.host.get_memory_mb_used())
|
||||||
mock_sumDomainMemory.assert_called_once_with(include_host=False)
|
mock_sumDomainMemory.assert_called_once_with(include_host=False)
|
||||||
|
|
|
@ -32,7 +32,6 @@ import inspect
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import sys
|
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
@ -1103,9 +1102,6 @@ class Host(object):
|
||||||
|
|
||||||
:returns: the total usage of memory(MB).
|
:returns: the total usage of memory(MB).
|
||||||
"""
|
"""
|
||||||
if sys.platform.upper() not in ['LINUX2', 'LINUX3']:
|
|
||||||
return 0
|
|
||||||
|
|
||||||
if CONF.libvirt.virt_type == 'xen':
|
if CONF.libvirt.virt_type == 'xen':
|
||||||
# For xen, report the sum of all domains, with
|
# For xen, report the sum of all domains, with
|
||||||
return self._sum_domain_memory_mb(include_host=True)
|
return self._sum_domain_memory_mb(include_host=True)
|
||||||
|
|
Loading…
Reference in New Issue