#!/bin/env bash
#
# Setup HEAT's output
#
set -euo pipefail

source {{undercloud_rc }}

echo "Setting up HEAT's output for major upgrade"
openstack overcloud upgrade prepare --templates --stack {{ overcloud_stack_name }} \
    {% if tripleo_upgrade_debug|bool %}
    --debug \
    {% endif %}
    {% if tripleo_upgrade_validations_non_fatal|bool %}
    --validation-errors-nonfatal \
    {% endif %}
    --container-registry-file {{ working_dir }}/{{ container_registry_file }} \
    {% if initial_env_file is defined and initial_env_file.stdout_lines|length > 0 %}
    {% for _env in initial_env_file.stdout_lines %}
        -e {{ _env }} \
    {% endfor %}
    {% endif %}
    {% if upgrade_prepare_extra_params %}
    -e {{ upgrade_prepare_extra_params | join(' -e ') }} \
    {% endif %}
    --roles-file {{ roles_data }} 2>&1
