Merge "Add heatclient to available clients"

This commit is contained in:
Jenkins 2013-12-03 03:47:45 +00:00 committed by Gerrit Code Review
commit 5a5d1b4c5d
2 changed files with 27 additions and 0 deletions

View File

@ -23,8 +23,10 @@ logger = logging.getLogger(__name__)
from heat.common import heat_keystoneclient as hkc from heat.common import heat_keystoneclient as hkc
from heatclient import client as heatclient
from novaclient import client as novaclient from novaclient import client as novaclient
from novaclient import shell as novashell from novaclient import shell as novashell
try: try:
from swiftclient import client as swiftclient from swiftclient import client as swiftclient
except ImportError: except ImportError:
@ -76,6 +78,7 @@ class OpenStackClients(object):
self._cinder = None self._cinder = None
self._trove = None self._trove = None
self._ceilometer = None self._ceilometer = None
self._heat = None
@property @property
def auth_token(self): def auth_token(self):
@ -265,6 +268,27 @@ class OpenStackClients(object):
cfg.CONF.import_opt(option, 'heat.common.config', group='clients') cfg.CONF.import_opt(option, 'heat.common.config', group='clients')
return getattr(cfg.CONF.clients, option) 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): class ClientBackend(object):
'''Delay choosing the backend client module until the client's class needs '''Delay choosing the backend client module until the client's class needs

View File

@ -344,6 +344,9 @@ class Resource(object):
def ceilometer(self): def ceilometer(self):
return self.stack.clients.ceilometer() return self.stack.clients.ceilometer()
def heat(self):
return self.stack.clients.heat()
def _do_action(self, action, pre_func=None): def _do_action(self, action, pre_func=None):
''' '''
Perform a transition to a new state via a specified action Perform a transition to a new state via a specified action