Write clouds.yaml/heatrc for tripleo launch heat
When "openstack tripleo launch heat" is used to start an ephemeral Heat
process, a clouds.yaml and heatrc file are now written to the Heat
working dir that can be used to interact with the ephemeral Heat API.
Change-Id: I35ad22a77362e73695c16b1e5abf02e05f9fdada
Signed-off-by: James Slagle <jslagle@redhat.com>
(cherry picked from commit 723bf34caf
)
This commit is contained in:
parent
9e3ea87824
commit
0aefaf3f5b
@ -43,6 +43,7 @@ import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import textwrap
|
||||
import time
|
||||
import yaml
|
||||
|
||||
@ -3112,6 +3113,37 @@ def get_ceph_networks(network_data_path,
|
||||
return storage_net_map
|
||||
|
||||
|
||||
def write_ephemeral_heat_clouds_yaml(heat_dir):
|
||||
clouds_yaml_path = os.path.join(heat_dir, 'clouds.yaml')
|
||||
clouds_dict = {}
|
||||
clouds_dict['heat'] = {}
|
||||
clouds_dict['heat']['auth_type'] = "none"
|
||||
clouds_dict['heat']['endpoint'] = \
|
||||
"http://127.0.0.1:8006/v1/admin"
|
||||
heat_yaml = dict(clouds=clouds_dict)
|
||||
with open(clouds_yaml_path, 'w') as f:
|
||||
f.write(yaml.dump(heat_yaml))
|
||||
|
||||
heatrc = textwrap.dedent("""
|
||||
# Clear any old environment that may conflict.
|
||||
for key in $( set | awk -F= '/^OS_/ {print $1}' ); do
|
||||
unset "${key}"
|
||||
done
|
||||
export OS_CLOUD=heat
|
||||
# Add OS_CLOUDNAME to PS1
|
||||
if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
|
||||
export PS1=${PS1:-""}
|
||||
export PS1=${OS_CLOUD:+"($OS_CLOUD)"} $PS1
|
||||
export CLOUDPROMPT_ENABLED=1
|
||||
fi
|
||||
""")
|
||||
|
||||
# Also write a heatrc file
|
||||
heatrc_path = os.path.join(heat_dir, 'heatrc')
|
||||
with open(heatrc_path, 'w') as f:
|
||||
f.write(heatrc)
|
||||
|
||||
|
||||
def get_host_groups_from_ceph_spec(ceph_spec_path, prefix='',
|
||||
key='hostname', get_non_admin=True):
|
||||
"""Get hosts per group based on labels in ceph_spec_path file
|
||||
|
@ -218,6 +218,9 @@ class LaunchHeat(command.Command):
|
||||
msg = _('Heat launch failed.')
|
||||
self.log.error(msg)
|
||||
raise exceptions.DeploymentError(msg)
|
||||
else:
|
||||
self.log.info("Writing heat clouds.yaml")
|
||||
utils.write_ephemeral_heat_clouds_yaml(parsed_args.heat_dir)
|
||||
|
||||
def _configure_logging(self, parsed_args):
|
||||
formatter = logging.Formatter(
|
||||
|
Loading…
Reference in New Issue
Block a user