Use ephemeral Heat client if set
In the cases where custom ansible plugins talk to the Heat API, we need to use the ephemeral Heat client if it has been defined. This will ensure Heat is appropriately configured to talk to the right API. Otherwise, configure a Heat client in the normal fashion. Depends-On: I2c3e9088bf92146b07d46288c2264368e15aa63b Change-Id: I0e45cbed37f2b92dcd1c435f86cf041d03ed2251 Signed-off-by: James Slagle <jslagle@redhat.com>
This commit is contained in:
parent
8fbb53d01c
commit
ac1f255507
|
@ -19,6 +19,8 @@
|
|||
# tripleo-common expects the legacy clients. Once
|
||||
# we've updated tripleo-common to use the SDK we
|
||||
# should revise this.
|
||||
import os
|
||||
|
||||
from glanceclient import client as glanceclient
|
||||
from heatclient.v1 import client as heatclient
|
||||
from ironicclient import client as ironicclient
|
||||
|
@ -30,6 +32,14 @@ from tripleo_common.utils import parameters
|
|||
|
||||
import ironic_inspector_client
|
||||
|
||||
try:
|
||||
# TODO(slagle): the try/except can be removed once tripleo_common is
|
||||
# released with
|
||||
# https://review.opendev.org/c/openstack/tripleo-common/+/787819
|
||||
from tripleo_common.utils import heat
|
||||
except ImportError:
|
||||
heat = None
|
||||
|
||||
|
||||
class DeriveParamsError(Exception):
|
||||
"""Error while performing a derive parameters operation"""
|
||||
|
@ -74,8 +84,14 @@ class TripleOCommon(object):
|
|||
if 'heatclient' in self.client_cache:
|
||||
return self.client_cache['heatclient']
|
||||
else:
|
||||
self.client_cache['heatclient'] = \
|
||||
heatclient.Client(session=self.sess)
|
||||
if heat and os.environ.get('OS_HEAT_TYPE', '') == 'ephemeral':
|
||||
host = os.environ.get('OS_HEAT_HOST', '127.0.0.1')
|
||||
port = os.environ.get('OS_HEAT_PORT', 8006)
|
||||
self.client_cache['heatclient'] = \
|
||||
heat.local_orchestration_client(host, int(port))
|
||||
else:
|
||||
self.client_cache['heatclient'] = \
|
||||
heatclient.Client(session=self.sess)
|
||||
return self.client_cache['heatclient']
|
||||
|
||||
def get_compute_client(self):
|
||||
|
|
Loading…
Reference in New Issue