From 24b06ef273e193819624fd2e021282d2735977b0 Mon Sep 17 00:00:00 2001 From: Jude Cross Date: Mon, 2 Apr 2018 15:07:25 -0700 Subject: Fix limits show command without Nova and Cinder This patch implements an endpoint lookup when showing limits. This addresses the issue when showing limits without both Nova and Cinder and will display limits if one is missing. Change-Id: I2214b281e0206f8fe117aae52de2bf4c4e2c6525 Closes-bug: #1707960 --- openstackclient/common/clientmanager.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'openstackclient/common/clientmanager.py') diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index 89781052..aa1045e4 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -125,6 +125,25 @@ class ClientManager(clientmanager.ClientManager): # use Network API by default return self.is_service_available('network') is not False + def is_compute_endpoint_enabled(self): + """Check if Compute endpoint is enabled""" + + return self.is_service_available('compute') is not False + + def is_volume_endpoint_enabled(self, volume_client): + """Check if volume endpoint is enabled""" + # NOTE(jcross): Cinder did some interesting things with their service + # name so we need to figure out which version to look + # for when calling is_service_available() + volume_version = volume_client.api_version.ver_major + if self.is_service_available( + "volumev%s" % volume_version) is not False: + return True + elif self.is_service_available('volume') is not False: + return True + else: + return False + # Plugin Support -- cgit v1.2.1