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>
This commit is contained in:
parent
f1fd9d0982
commit
723bf34caf
|
@ -40,6 +40,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
import tarfile
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import textwrap
|
||||||
import time
|
import time
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
@ -3286,3 +3287,34 @@ def get_ceph_networks(network_data_path,
|
||||||
storage_net_map['ms_bind_ipv6'] = True
|
storage_net_map['ms_bind_ipv6'] = True
|
||||||
|
|
||||||
return storage_net_map
|
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)
|
||||||
|
|
|
@ -218,6 +218,9 @@ class LaunchHeat(command.Command):
|
||||||
msg = _('Heat launch failed.')
|
msg = _('Heat launch failed.')
|
||||||
self.log.error(msg)
|
self.log.error(msg)
|
||||||
raise exceptions.DeploymentError(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):
|
def _configure_logging(self, parsed_args):
|
||||||
formatter = logging.Formatter(
|
formatter = logging.Formatter(
|
||||||
|
|
Loading…
Reference in New Issue