summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/tests/test_xenapi.py16
-rw-r--r--nova/virt/xenapi/vm_utils.py21
2 files changed, 27 insertions, 10 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 7e9265718..46dd83040 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -272,14 +272,18 @@ class XenAPIVMTestCase(test.TestCase):
fake_diagnostics = {
'vbd_xvdb_write': '0.0',
- 'memory_target': '10961792000.0000',
- 'memory_internal_free': '3612860.6020',
- 'memory': '10961792000.0000',
+ 'memory_target': '4294967296.0000',
+ 'memory_internal_free': '1415564.0000',
+ 'memory': '4294967296.0000',
'vbd_xvda_write': '0.0',
- 'cpu0': '0.0110',
- 'vif_0_tx': '752.4007',
+ 'cpu0': '0.0042',
+ 'vif_0_tx': '287.4134',
'vbd_xvda_read': '0.0',
- 'vif_0_rx': '4837.8805'
+ 'vif_0_rx': '1816.0144',
+ 'vif_2_rx': '0.0',
+ 'vif_2_tx': '0.0',
+ 'vbd_xvdb_read': '0.0',
+ 'last_update': '1328795567',
}
instance = self._create_instance()
expected = self.conn.get_diagnostics(instance)
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py
index deeebbcb9..30f65e1b5 100644
--- a/nova/virt/xenapi/vm_utils.py
+++ b/nova/virt/xenapi/vm_utils.py
@@ -1068,19 +1068,32 @@ class VMHelper(xenapi.HelperBase):
def compile_diagnostics(cls, record):
"""Compile VM diagnostics data"""
try:
+ keys = []
diags = {}
vm_uuid = record["uuid"]
xml = get_rrd(get_rrd_server(), vm_uuid)
if xml:
rrd = minidom.parseString(xml)
for i, node in enumerate(rrd.firstChild.childNodes):
- # We don't want all of the extra garbage
- if i >= 3 and i <= 11:
+ # Provide the last update of the information
+ if node.localName == 'lastupdate':
+ diags['last_update'] = node.firstChild.data
+
+ # Create a list of the diagnostic keys (in their order)
+ if node.localName == 'ds':
ref = node.childNodes
# Name and Value
if len(ref) > 6:
- _ref_zero = ref[0].firstChild.data
- diags[_ref_zero] = ref[6].firstChild.data
+ keys.append(ref[0].firstChild.data)
+
+ # Read the last row of the first RRA to get the latest info
+ if node.localName == 'rra':
+ rows = node.childNodes[4].childNodes
+ last_row = rows[rows.length - 1].childNodes
+ for j, value in enumerate(last_row):
+ diags[keys[j]] = value.firstChild.data
+ break
+
return diags
except expat.ExpatError as e:
LOG.exception(_('Unable to parse rrd of %(vm_uuid)s') % locals())