From d3fee2141cc816b1ae31f2111624b9dd9fa65cd7 Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Fri, 5 Jun 2015 17:19:04 -0700 Subject: [PATCH] Give client plugins the chance to not register This change improves the client plugin registration process by giving each plugin a is_available() class method that can prevent the plugin's registration when there are missing dependencies. Change-Id: Ief965d033f02f795d5be9beccae5e4b0b96d10b1 Closes-Bug: #1462555 --- heat/engine/clients/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/heat/engine/clients/__init__.py b/heat/engine/clients/__init__.py index 81032ba32c..66f4893d5c 100644 --- a/heat/engine/clients/__init__.py +++ b/heat/engine/clients/__init__.py @@ -15,7 +15,7 @@ from oslo_config import cfg from oslo_log import log as logging from oslo_utils import importutils import six -from stevedore import extension +from stevedore import enabled from heat.common import exception from heat.common.i18n import _LE @@ -111,8 +111,17 @@ def initialise(): if _mgr: return - _mgr = extension.ExtensionManager( + def client_is_available(client_plugin): + if not hasattr(client_plugin.plugin, 'is_available'): + # if the client does not have a is_available() class method, then + # we assume it wants to be always available + return True + # let the client plugin decide if it wants to register or not + return client_plugin.plugin.is_available() + + _mgr = enabled.EnabledExtensionManager( namespace='heat.clients', + check_func=client_is_available, invoke_on_load=False)