From 26dfc1eddb88f0a6abccdf2a510bd4a5ba2c9c90 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 20 Nov 2013 14:30:15 +1300 Subject: [PATCH] Add heatclient to available clients The first resource to use this will need to ensure that this method has test coverage. There appears to be no convention for writing separate unit tests for these client methods. This will currently not work with standalone heat as the heat endpoint will not be in the keystone catalog, see related-bug: #1255713 partial blueprint: hot-software-config Change-Id: I325664dcb0ca4d01be41614496c92e65bea52310 --- heat/engine/clients.py | 24 ++++++++++++++++++++++++ heat/engine/resource.py | 3 +++ 2 files changed, 27 insertions(+) diff --git a/heat/engine/clients.py b/heat/engine/clients.py index aa9a529614..8024eb5116 100644 --- a/heat/engine/clients.py +++ b/heat/engine/clients.py @@ -23,8 +23,10 @@ logger = logging.getLogger(__name__) from heat.common import heat_keystoneclient as hkc +from heatclient import client as heatclient from novaclient import client as novaclient from novaclient import shell as novashell + try: from swiftclient import client as swiftclient except ImportError: @@ -69,6 +71,7 @@ class OpenStackClients(object): self._neutron = None self._cinder = None self._ceilometer = None + self._heat = None @property def auth_token(self): @@ -232,6 +235,27 @@ class OpenStackClients(object): cfg.CONF.import_opt(option, 'heat.common.config', group='clients') return getattr(cfg.CONF.clients, option) + def heat(self): + if self._heat: + return self._heat + + con = self.context + if self.auth_token is None: + logger.error(_("Heat connection failed, no auth_token!")) + return None + + args = { + 'auth_url': con.auth_url, + 'token': self.auth_token, + 'username': None, + 'password': None + } + + endpoint = self.url_for(service_type='orchestration') + self._heat = heatclient.Client('1', endpoint, **args) + + return self._heat + class ClientBackend(object): '''Delay choosing the backend client module until the client's class needs diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 98c59ba73a..fbf82ac088 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -341,6 +341,9 @@ class Resource(object): def ceilometer(self): return self.stack.clients.ceilometer() + def heat(self): + return self.stack.clients.heat() + def _do_action(self, action, pre_func=None): ''' Perform a transition to a new state via a specified action