#!/bin/bash

set -o xtrace
set -o errexit

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

function print_failure {
    docker ps -a
    for failed in $(docker ps -a --format "{{.Names}}" --filter status=exited); do
        docker logs --tail=all $failed
    done
    echo "FAILED"
    exit 1
}

# Populate globals.yml
cat << EOF > /etc/kolla/globals.yml
---
kolla_base_distro: "$1"
kolla_install_type: "$2"
kolla_internal_address: "169.254.169.10"
docker_restart_policy: "never"
network_interface: "eth0"
neutron_external_interface: "fake_interface"
EOF

# Create dummy interface for neutron
ip l a fake_interface type dummy

# Actually do the deployment
tools/kolla-ansible deploy || print_failure

# TODO(SamYaple): Actually validate that all containers are started
docker ps -a

# TODO(SamYaple): Actually do functional testing of OpenStack

#!/bin/bash

set -o xtrace
set -o errexit

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

function check_failure {
    docker ps -a
    failed_containers=$(docker ps -a --format "{{.Names}}" --filter status=exited)

    for failed in ${failed_containers}; do
        docker logs --tail all ${failed}
    done

    if [[ -n ${failed_containers} ]]; then
        echo 'FAILED'
        exit 1
    fi
}

# Populate globals.yml
cat << EOF > /etc/kolla/globals.yml
---
kolla_base_distro: "$1"
kolla_install_type: "$2"
kolla_internal_address: "169.254.169.10"
docker_restart_policy: "never"
network_interface: "eth0"
neutron_external_interface: "fake_interface"
EOF

# Create dummy interface for neutron
ip l a fake_interface type dummy

# Actually do the deployment
tools/kolla-ansible deploy

check_failure

# TODO(SamYaple): Actually do functional testing of OpenStack

Validate that all the containers are started
Validate that all the containers are started

Container maybe exit after deployed. But the print_failure
never runs if the kolla-ansible run success.
This PS checks all the containers status after deploy and
failed the test if the container status is exited

TrivialFix
Change-Id: Ia461b280855eda500e143ee1d6cfd5f215eaf6fe
