Implement inspector method - inspect_memory_usage

zvm inspector method inspect_memory_usage will return memory usage
to ceilometer memory pollster.

Change-Id: Ibbe1030516fd960211d009d4bfa863bad99227af
This commit is contained in:
Huang Rui 2015-09-17 10:41:21 +08:00
parent 4836e860e2
commit 8838e435ec
2 changed files with 10 additions and 1 deletions

View File

@ -134,7 +134,8 @@ class ZVMInspector(virt_inspector.Inspector):
time=inst_stat['used_cpu_time'])
def inspect_memory_usage(self, instance, duration=None):
pass
inst_stat = self._get_inst_stat('memory.usage', instance)
return virt_inspector.MemoryUsageStats(usage=inst_stat['used_memory'])
def inspect_vnics(self, instance):
pass

View File

@ -155,3 +155,11 @@ class TestZVMInspector(base.BaseTestCase):
self.assertEqual(2, cpu_stat.number)
self.assertEqual(99999999, cpu_stat.time)
get_stat.assert_called_once_with('cpus', None)
@mock.patch("ceilometer_zvm.compute.virt.zvm.inspector.ZVMInspector."
"_get_inst_stat")
def test_inspect_memory_usage(self, get_stat):
get_stat.return_value = {'used_memory': 1998}
mem_usage = self.inspector.inspect_memory_usage(None)
self.assertEqual(1998, mem_usage.usage)
get_stat.assert_called_once_with('memory.usage', None)