Permalink
Browse files

Merge "vmware: VM diagnostics (v3 API only)"

  • Loading branch information...
Jenkins authored and openstack-gerrit committed Jul 20, 2014
2 parents 50be0c8 + 6507da5 commit 8dd3c31d9e0ecba6f13f51843a6c825e7b1c27cf
Showing with 56 additions and 3 deletions.
  1. +16 −0 nova/tests/virt/vmwareapi/test_driver_api.py
  2. +15 −2 nova/virt/vmwareapi/driver.py
  3. +25 −1 nova/virt/vmwareapi/vmops.py
@@ -1681,6 +1681,22 @@ def test_get_diagnostics(self):
'node': self.instance_node}),
matchers.DictMatches(expected))
+ def test_get_instance_diagnostics(self):
+ self._create_vm()
+ expected = {'uptime': 0,
+ 'memory_details': {'used': 0, 'maximum': 512},
+ 'nic_details': [],
+ 'driver': 'vmwareapi',
+ 'state': 'running',
+ 'version': '1.0',
+ 'cpu_details': [],
+ 'disk_details': [],
+ 'hypervisor_os': 'esxi',
+ 'config_drive': False}
+ actual = self.conn.get_instance_diagnostics(
+ {'name': 1, 'uuid': self.uuid, 'node': self.instance_node})
+ self.assertThat(actual.serialize(), matchers.DictMatches(expected))
+
def test_get_console_output(self):
self.assertRaises(NotImplementedError, self.conn.get_console_output,
None, None)
@@ -265,7 +265,13 @@ def get_info(self, instance):
def get_diagnostics(self, instance):
"""Return data about VM diagnostics."""
- return self._vmops.get_diagnostics(instance)
+ data = self._vmops.get_diagnostics(instance)
+ return data
+
+ def get_instance_diagnostics(self, instance):
+ """Return data about VM diagnostics."""
+ data = self._vmops.get_instance_diagnostics(instance)
+ return data
def get_vnc_console(self, context, instance):
"""Return link to instance's VNC console."""
@@ -729,7 +735,14 @@ def get_info(self, instance):
def get_diagnostics(self, instance):
"""Return data about VM diagnostics."""
_vmops = self._get_vmops_for_compute_node(instance['node'])
- return _vmops.get_diagnostics(instance)
+ data = _vmops.get_diagnostics(instance)
+ return data
+
+ def get_instance_diagnostics(self, instance):
+ """Return data about VM diagnostics."""
+ _vmops = self._get_vmops_for_compute_node(instance['node'])
+ data = _vmops.get_instance_diagnostics(instance)
+ return data
def host_power_action(self, host, action):
"""Host operations not supported by VC driver.
@@ -41,6 +41,7 @@
from nova.openstack.common import uuidutils
from nova import utils
from nova.virt import configdrive
+from nova.virt import diagnostics
from nova.virt import driver
from nova.virt.vmwareapi import constants
from nova.virt.vmwareapi import ds_util
@@ -1275,7 +1276,7 @@ def get_info(self, instance):
'num_cpu': int(query['summary.config.numCpu']),
'cpu_time': 0}
- def get_diagnostics(self, instance):
+ def _get_diagnostics(self, instance):
"""Return data about VM diagnostics."""
vm_ref = vm_util.get_vm_ref(self._session, instance)
lst_properties = ["summary.config",
@@ -1292,9 +1293,32 @@ def get_diagnostics(self, instance):
for value in query.values():
prop_dict = vim.object_to_dict(value, list_depth=1)
data.update(prop_dict)
+ return data
+
+ def get_diagnostics(self, instance):
+ """Return data about VM diagnostics."""
+ data = self._get_diagnostics(instance)
# Add a namespace to all of the diagnostsics
return dict([('vmware:' + k, v) for k, v in data.items()])
+ def get_instance_diagnostics(self, instance):
+ """Return data about VM diagnostics."""
+ data = self._get_diagnostics(instance)
+ state = data.get('powerState')
+ if state:
+ state = power_state.STATE_MAP[VMWARE_POWER_STATES[state]]
+ uptime = data.get('uptimeSeconds', 0)
+ config_drive = configdrive.required_by(instance)
+ diags = diagnostics.Diagnostics(state=state,
+ driver='vmwareapi',
+ config_drive=config_drive,
+ hypervisor_os='esxi',
+ uptime=uptime)
+ diags.memory_details.maximum = data.get('memorySizeMB', 0)
+ diags.memory_details.used = data.get('guestMemoryUsage', 0)
+ #TODO(garyk): add in cpu, nic and disk stats
+ return diags
+
def _get_vnc_console_connection(self, instance):
"""Return connection info for a vnc console."""
vm_ref = vm_util.get_vm_ref(self._session, instance)

0 comments on commit 8dd3c31

Please sign in to comment.