'Return data about VM diagnostics.'

def get_instance_diagnostics(self, instance):

    data = self._get_diagnostics(instance)
    state = data.get('powerState')
    if state:
        state = power_state.STATE_MAP[constants.POWER_STATES[state]]
    uptime = data.get('uptimeSeconds', 0)
    config_drive = configdrive.required_by(instance)
    diags = objects.Diagnostics(state=state, driver='vmwareapi', config_drive=config_drive, hypervisor_os='esxi', uptime=uptime)
    diags.memory_details = objects.MemoryDiagnostics(maximum=data.get('memorySizeMB', 0), used=data.get('guestMemoryUsage', 0))
    return diags
