From 8a9de631cfa9af7ad0f31fceddf29df90b44712b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Ramalho?= Date: Mon, 31 Jul 2017 15:03:18 +0200 Subject: [PATCH] Fix libvirt plugin project/tenant name dimension Enabling the libvirt plugin to add tenant_name as a dimension is resulting in "Unable to get tenant list from keystone: Unknown Attribute: tenants" when using keystone v3. This is due the v3 keystone client uses projects.list() instead of tenants.list(). This change fixes that by checking which client version is being used and making the function call accordingly. Change-Id: Icfe88b6a1a7ef193fd998db5a72a7a076d23ffe5 --- monasca_agent/collector/checks/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monasca_agent/collector/checks/utils.py b/monasca_agent/collector/checks/utils.py index a4070b93..1e1091d4 100644 --- a/monasca_agent/collector/checks/utils.py +++ b/monasca_agent/collector/checks/utils.py @@ -42,7 +42,10 @@ def get_tenant_list(config, log): try: log.debug("Retrieving Keystone tenant list") client = keystone.get_client(**config) - tenants = client.tenants.list() + if 'v2' in client.__module__: + tenants = client.tenants.list() + else: + tenants = client.projects.list() except Exception as e: msg = "Unable to get tenant list from keystone: {0}" log.error(msg.format(e))