Browse Source

Merge "Use ephemeral Heat client if set"

changes/95/788595/1
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
c72a83c30c
1 changed files with 18 additions and 2 deletions
  1. +18
    -2
      tripleo_ansible/ansible_plugins/module_utils/tripleo_common_utils.py

+ 18
- 2
tripleo_ansible/ansible_plugins/module_utils/tripleo_common_utils.py View File

@ -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…
Cancel
Save