From 23a7fa286973be3bcbfbdb17317b144ef74fa02c Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Tue, 19 May 2015 05:42:26 -0500 Subject: [PATCH] Separate base images into different folders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This moves a few things around. Namely centos/fedora-rdo-base becomes centos/rdo/base fedora/rdo/base I have also separated out RHEL. Moves the current scripts in "base" to a "common" folder common to all images and then recreates the appropriate links to allow all the containers to build the same way they did before. This removes all .buildconfs in the system (though they are still usable) Partially Implements: blueprint refactor-base-image-layout Co-Authored-By: Martin André Change-Id: Id63eac1eb9893ceb775c28bf22842dede85c214a --- .../{centos-binary-base => base}/Dockerfile | 0 .../binary/{centos-binary-base => base}/build | 0 docker/centos/binary/base/kolla-common.sh | 171 +----------------- docker/centos/binary/base/service_hosts.sh | 46 +---- .../binary/centos-binary-base/.buildconf | 1 - .../binary/centos-binary-base/kolla-common.sh | 1 - .../centos-binary-base/service_hosts.sh | 1 - docker/centos/binary/centos-rdo-base | 1 - .../binary/fedora-binary-base/.buildconf | 1 - .../binary/fedora-binary-base/kolla-common.sh | 1 - .../fedora-binary-base/service_hosts.sh | 1 - docker/centos/binary/fedora-rdo-base | 1 - docker/common/kolla-common.sh | 170 +++++++++++++++++ docker/common/service_hosts.sh | 45 +++++ docker/fedora | 1 - docker/fedora/binary/barbican | 1 + .../binary/base}/Dockerfile | 0 .../binary/base}/build | 0 docker/fedora/binary/base/kolla-common.sh | 1 + docker/fedora/binary/base/service_hosts.sh | 1 + docker/fedora/binary/ceilometer | 1 + docker/fedora/binary/cinder | 1 + docker/fedora/binary/designate | 1 + docker/fedora/binary/docker-compose | 1 + docker/fedora/binary/glance | 1 + docker/fedora/binary/hautoproxy | 1 + docker/fedora/binary/heat | 1 + docker/fedora/binary/horizon | 1 + docker/fedora/binary/keystone | 1 + docker/fedora/binary/magnum | 1 + docker/fedora/binary/mariadb-app | 1 + docker/fedora/binary/mariadb-data | 1 + docker/fedora/binary/mongodb | 1 + docker/fedora/binary/neutron | 1 + docker/fedora/binary/nova-base | 1 + docker/fedora/binary/nova-compute | 1 + docker/fedora/binary/nova-controller | 1 + docker/fedora/binary/rabbitmq | 1 + docker/fedora/binary/swift | 1 + docker/fedora/binary/zaqar | 1 + docker/fedora/rdo | 1 + docker/rhel/binary/barbican | 1 + .../binary/base}/Dockerfile | 0 .../rhel-osp-base => rhel/binary/base}/build | 0 docker/rhel/binary/base/kolla-common.sh | 1 + docker/rhel/binary/base/service_hosts.sh | 1 + docker/rhel/binary/ceilometer | 1 + docker/rhel/binary/cinder | 1 + docker/rhel/binary/designate | 1 + docker/rhel/binary/docker-compose | 1 + docker/rhel/binary/glance | 1 + docker/rhel/binary/hautoproxy | 1 + docker/rhel/binary/heat | 1 + docker/rhel/binary/horizon | 1 + docker/rhel/binary/keystone | 1 + docker/rhel/binary/magnum | 1 + docker/rhel/binary/mariadb-app | 1 + docker/rhel/binary/mariadb-data | 1 + docker/rhel/binary/mongodb | 1 + docker/rhel/binary/neutron | 1 + docker/rhel/binary/nova-base | 1 + docker/rhel/binary/nova-compute | 1 + docker/rhel/binary/nova-controller | 1 + docker/rhel/binary/rabbitmq | 1 + docker/rhel/binary/swift | 1 + docker/rhel/binary/zaqar | 1 + docker/rhel/osp | 1 + 67 files changed, 265 insertions(+), 224 deletions(-) rename docker/centos/binary/{centos-binary-base => base}/Dockerfile (100%) rename docker/centos/binary/{centos-binary-base => base}/build (100%) mode change 100644 => 120000 docker/centos/binary/base/kolla-common.sh mode change 100755 => 120000 docker/centos/binary/base/service_hosts.sh delete mode 100644 docker/centos/binary/centos-binary-base/.buildconf delete mode 120000 docker/centos/binary/centos-binary-base/kolla-common.sh delete mode 120000 docker/centos/binary/centos-binary-base/service_hosts.sh delete mode 120000 docker/centos/binary/centos-rdo-base delete mode 100644 docker/centos/binary/fedora-binary-base/.buildconf delete mode 120000 docker/centos/binary/fedora-binary-base/kolla-common.sh delete mode 120000 docker/centos/binary/fedora-binary-base/service_hosts.sh delete mode 120000 docker/centos/binary/fedora-rdo-base create mode 100644 docker/common/kolla-common.sh create mode 100755 docker/common/service_hosts.sh delete mode 120000 docker/fedora create mode 120000 docker/fedora/binary/barbican rename docker/{centos/binary/fedora-binary-base => fedora/binary/base}/Dockerfile (100%) rename docker/{centos/binary/fedora-binary-base => fedora/binary/base}/build (100%) create mode 120000 docker/fedora/binary/base/kolla-common.sh create mode 120000 docker/fedora/binary/base/service_hosts.sh create mode 120000 docker/fedora/binary/ceilometer create mode 120000 docker/fedora/binary/cinder create mode 120000 docker/fedora/binary/designate create mode 120000 docker/fedora/binary/docker-compose create mode 120000 docker/fedora/binary/glance create mode 120000 docker/fedora/binary/hautoproxy create mode 120000 docker/fedora/binary/heat create mode 120000 docker/fedora/binary/horizon create mode 120000 docker/fedora/binary/keystone create mode 120000 docker/fedora/binary/magnum create mode 120000 docker/fedora/binary/mariadb-app create mode 120000 docker/fedora/binary/mariadb-data create mode 120000 docker/fedora/binary/mongodb create mode 120000 docker/fedora/binary/neutron create mode 120000 docker/fedora/binary/nova-base create mode 120000 docker/fedora/binary/nova-compute create mode 120000 docker/fedora/binary/nova-controller create mode 120000 docker/fedora/binary/rabbitmq create mode 120000 docker/fedora/binary/swift create mode 120000 docker/fedora/binary/zaqar create mode 120000 docker/fedora/rdo create mode 120000 docker/rhel/binary/barbican rename docker/{centos/binary/rhel-osp-base => rhel/binary/base}/Dockerfile (100%) rename docker/{centos/binary/rhel-osp-base => rhel/binary/base}/build (100%) create mode 120000 docker/rhel/binary/base/kolla-common.sh create mode 120000 docker/rhel/binary/base/service_hosts.sh create mode 120000 docker/rhel/binary/ceilometer create mode 120000 docker/rhel/binary/cinder create mode 120000 docker/rhel/binary/designate create mode 120000 docker/rhel/binary/docker-compose create mode 120000 docker/rhel/binary/glance create mode 120000 docker/rhel/binary/hautoproxy create mode 120000 docker/rhel/binary/heat create mode 120000 docker/rhel/binary/horizon create mode 120000 docker/rhel/binary/keystone create mode 120000 docker/rhel/binary/magnum create mode 120000 docker/rhel/binary/mariadb-app create mode 120000 docker/rhel/binary/mariadb-data create mode 120000 docker/rhel/binary/mongodb create mode 120000 docker/rhel/binary/neutron create mode 120000 docker/rhel/binary/nova-base create mode 120000 docker/rhel/binary/nova-compute create mode 120000 docker/rhel/binary/nova-controller create mode 120000 docker/rhel/binary/rabbitmq create mode 120000 docker/rhel/binary/swift create mode 120000 docker/rhel/binary/zaqar create mode 120000 docker/rhel/osp diff --git a/docker/centos/binary/centos-binary-base/Dockerfile b/docker/centos/binary/base/Dockerfile similarity index 100% rename from docker/centos/binary/centos-binary-base/Dockerfile rename to docker/centos/binary/base/Dockerfile diff --git a/docker/centos/binary/centos-binary-base/build b/docker/centos/binary/base/build similarity index 100% rename from docker/centos/binary/centos-binary-base/build rename to docker/centos/binary/base/build diff --git a/docker/centos/binary/base/kolla-common.sh b/docker/centos/binary/base/kolla-common.sh deleted file mode 100644 index 8c2ef5ec1c..0000000000 --- a/docker/centos/binary/base/kolla-common.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/bin/bash - -. /opt/kolla/service_hosts.sh - -# Set some generally useful defaults. -MY_IP=$(ip route get $(ip route | awk '$1 == "default" {print $3}') | - awk '$4 == "src" {print $5}') - -: ${PUBLIC_IP:=${MY_IP}} - -# Iterate over a list of variable names and exit if one is -# undefined. -check_required_vars() { - for var in $*; do - if [ -z "${!var}" ]; then - echo "ERROR: missing $var" >&2 - exit 1 - fi - done -} - -# The usage of the wait_for function looks like the following -# wait_for LOOPS_NUMBER SLEEP_TIME ARGS -# -# The ARGS are read and concatenated together into a single command and the -# command is executed in a loop until it succeeds or reaches the max number of -# attempts (LOOPS_NUMBER). -# -# Optional variables SUCCESSFUL_MATCH_OUTPUT and FAIL_MATCH_OUTPUT variable may -# also be set to control if the loop exits early if the commands stdout/stderr -# matches the supplied regex string. Consider using the `wait_for_output` and -# `wait_for_output_unless` functions in case there is a need to check for the -# command output. -# -# The script exits on failure, either when output contains string identified as -# failure, or when it reaches a timeout. -# -# Examples: -# wait_for 30 10 ping -c 1 192.0.2.2 -# wait_for 10 1 ls file_we_are_waiting_for -# wait_for 10 3 date \| grep 8 -wait_for() { - local loops=${1:-""} - local sleeptime=${2:-""} - FAIL_MATCH_OUTPUT=${FAIL_MATCH_OUTPUT:-""} - SUCCESSFUL_MATCH_OUTPUT=${SUCCESSFUL_MATCH_OUTPUT:-""} - shift 2 || true - local command="$@" - - if [ -z "$loops" -o -z "$sleeptime" -o -z "$command" ]; then - echo "wait_for is missing a required parameter" - exit 1 - fi - - local i=0 - while [ $i -lt $loops ]; do - i=$((i + 1)) - local status=0 - local output=$(eval $command 2>&1) || status=$? - if [[ -n "$SUCCESSFUL_MATCH_OUTPUT" ]] \ - && [[ $output =~ $SUCCESSFUL_MATCH_OUTPUT ]]; then - return 0 - elif [[ -n "$FAIL_MATCH_OUTPUT" ]] \ - && [[ $output =~ $FAIL_MATCH_OUTPUT ]]; then - echo "Command output matched '$FAIL_MATCH_OUTPUT'." - exit 1 - elif [[ -z "$SUCCESSFUL_MATCH_OUTPUT" ]] && [[ $status -eq 0 ]]; then - return 0 - fi - sleep $sleeptime - done - local seconds=$((loops * sleeptime)) - printf 'Timing out after %d seconds:\ncommand=%s\nOUTPUT=%s\n' \ - "$seconds" "$command" "$output" - exit 1 -} - -# Helper function to `wait_for` that only succeeds when the given regex is -# matching the command's output. Exit early with a failure when the second -# supplied regexp is matching the output. -# -# Example: -# wait_for_output_unless CREATE_COMPLETE CREATE_FAIL 30 10 heat stack-show undercloud -wait_for_output_unless() { - SUCCESSFUL_MATCH_OUTPUT=$1 - FAIL_MATCH_OUTPUT=$2 - shift 2 - wait_for $@ - local status=$? - unset SUCCESSFUL_MATCH_OUTPUT - unset FAIL_MATCH_OUTPUT - return $status -} - -# Helper function to `wait_for` that only succeeds when the given regex is -# matching the command's output. -# -# Example: -# wait_for_output CREATE_COMPLETE 30 10 heat stack-show undercloud -wait_for_output() { - local expected_output=$1 - shift - wait_for_output_unless $expected_output '' $@ -} - -# Check if we receive a successful response from corresponding OpenStack -# service endpoint. -check_for_os_service_endpoint() { - local name=$1 - local host_var=$2 - local port_var=$3 - local api_version=$4 - - check_required_vars $host_var $port_var - - local endpoint="http://${!host_var}:${!port_var}/$api_version" - - curl -sf -o /dev/null "$endpoint" || { - echo "ERROR: $name is not available @ $endpoint" >&2 - return 1 - } - - echo "$name is active @ $endpoint" -} - -check_for_os_service_running() { - local service=$1 - local args= - case $service in - ("glance") args="GLANCE_API_SERVICE_HOST GLANCE_API_SERVICE_PORT" ;; - ("keystone") args="KEYSTONE_PUBLIC_SERVICE_HOST KEYSTONE_PUBLIC_SERVICE_PORT v2.0" ;; - ("neutron") args="NEUTRON_SERVER_SERVICE_HOST NEUTRON_SERVER_SERVICE_PORT" ;; - ("nova") args="NOVA_API_SERVICE_HOST NOVA_API_SERVICE_PORT" ;; - (*) - echo "Unknown service $service" - return 1 ;; - esac - check_for_os_service_endpoint $service $args -} - -fail_unless_os_service_running() { - check_for_os_service_running $@ || exit $? -} - -# Check if we receive a successful response from the database server. -# Optionally takes a database name to check for. Defaults to 'mysql'. -check_for_db() { - local database=${1:-mysql} - check_required_vars MARIADB_SERVICE_HOST DB_ROOT_PASSWORD - - mysql -h ${MARIADB_SERVICE_HOST} -u root -p"${DB_ROOT_PASSWORD}" \ - -e "select 1" $database > /dev/null 2>&1 || { - echo "ERROR: database $database is not available @ $MARIADB_SERVICE_HOST" >&2 - return 1 - } - - echo "database is active @ ${MARIADB_SERVICE_HOST}" -} - -fail_unless_db() { - check_for_db $@ || exit $? -} - -# Dump shell environment to a file -dump_vars() { - set -o posix - set > /pid_$$_vars.sh - set +o posix -} - diff --git a/docker/centos/binary/base/kolla-common.sh b/docker/centos/binary/base/kolla-common.sh new file mode 120000 index 0000000000..380efbc3d7 --- /dev/null +++ b/docker/centos/binary/base/kolla-common.sh @@ -0,0 +1 @@ +../../../common/kolla-common.sh \ No newline at end of file diff --git a/docker/centos/binary/base/service_hosts.sh b/docker/centos/binary/base/service_hosts.sh deleted file mode 100755 index c3006f720a..0000000000 --- a/docker/centos/binary/base/service_hosts.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Kubernetes currently creates FOO_SERVICE_HOST and FOO_SERVICE_PORT env vars -# as part of starting the containers. However this is not done when starting -# them with plain docker. Defaulting variables to their common version if -# they're not already set allows the usage of --link in plain 'docker run' to -# wire together containers. - -: ${BARBICAN_ADMIN_SERVICE_HOST:=$BARBICAN_ADMIN_PORT_9312_TCP_ADDR} -: ${BARBICAN_ADMIN_SERVICE_PORT:=9312} -: ${BARBICAN_PUBLIC_SERVICE_HOST:=$BARBICAN_PUBLIC_PORT_9311_TCP_ADDR} -: ${BARBICAN_PUBLIC_SERVICE_PORT:=9311} -: ${CEILOMETER_API_SERVICE_HOST:=$CEILOMETER_API_PORT_8777_TCP_ADDR} -: ${CEILOMETER_API_SERVICE_PORT:=8777} -: ${GLANCE_API_SERVICE_HOST:=$GLANCE_API_PORT_9292_TCP_ADDR} -: ${GLANCE_API_SERVICE_PORT:=9292} -: ${GLANCE_REGISTRY_SERVICE_HOST:=$GLANCE_REGISTRY_PORT_9191_TCP_ADDR} -: ${GLANCE_REGISTRY_SERVICE_PORT:=9191} -: ${HEAT_API_SERVICE_HOST:=$HEAT_API_PORT_8004_TCP_ADDR} -: ${HEAT_API_SERVICE_PORT:=8004} -: ${HORIZON_SERVICE_HOST:=$HORIZON_PORT_80_TCP_ADDR} -: ${HORIZON_SERVICE_PORT:=80} -: ${KEYSTONE_ADMIN_SERVICE_HOST:=$KEYSTONE_PORT_35357_TCP_ADDR} -: ${KEYSTONE_ADMIN_SERVICE_PORT:=35357} -: ${KEYSTONE_PUBLIC_SERVICE_HOST:=$KEYSTONE_PORT_5000_TCP_ADDR} -: ${KEYSTONE_PUBLIC_SERVICE_PORT:=5000} -: ${MARIADB_SERVICE_HOST:=$MARIADB_PORT_3306_TCP_ADDR} -: ${MARIADB_SERVICE_PORT:=3306} -: ${MONGODB_SERVICE_HOST:=$MONGODB_PORT_27017_TCP_ADDR} -: ${MONGODB_SERVICE_PORT:=27017} -: ${NEUTRON_SERVER_SERVICE_HOST:=$NEUTRON_SERVER_PORT_9696_TCP_ADDR} -: ${NEUTRON_SERVER_SERVICE_PORT:=9696} -: ${NOVA_API_SERVICE_HOST:=$NOVA_API_PORT_8774_TCP_ADDR} -: ${NOVA_API_SERVICE_PORT:=8774} -: ${NOVA_EC2_API_SERVICE_HOST:=$NOVA_EC2_API_PORT_8773_TCP_ADDR} -: ${NOVA_EC2_API_SERVICE_PORT:=8773} -: ${NOVA_LIBVIRT_SERVICE_HOST:=$NOVA_LIBVIRT_PORT_16509_TCP_ADDR} -: ${NOVA_LIBVIRT_SERVICE_PORT:=16509} -: ${NOVA_METADATA_API_SERVICE_HOST:=$NOVA_METADATA_API_PORT_8775_TCP_ADDR} -: ${NOVA_METADATA_API_SERVICE_PORT:=8775} -: ${RABBITMQ_SERVICE_HOST:=$RABBITMQ_PORT_5672_TCP_ADDR} -: ${RABBITMQ_SERVICE_PORT:=5672} -: ${ZAQAR_SERVER_SERVICE_HOST:=$ZAQAR_SERVER_PORT_8888_TCP_ADDR} -: ${ZAQAR_SERVER_SERVICE_PORT:=8888} - diff --git a/docker/centos/binary/base/service_hosts.sh b/docker/centos/binary/base/service_hosts.sh new file mode 120000 index 0000000000..777b7334d5 --- /dev/null +++ b/docker/centos/binary/base/service_hosts.sh @@ -0,0 +1 @@ +../../../common/service_hosts.sh \ No newline at end of file diff --git a/docker/centos/binary/centos-binary-base/.buildconf b/docker/centos/binary/centos-binary-base/.buildconf deleted file mode 100644 index d552b0d1b0..0000000000 --- a/docker/centos/binary/centos-binary-base/.buildconf +++ /dev/null @@ -1 +0,0 @@ -PREFIX= diff --git a/docker/centos/binary/centos-binary-base/kolla-common.sh b/docker/centos/binary/centos-binary-base/kolla-common.sh deleted file mode 120000 index fcd13a80e1..0000000000 --- a/docker/centos/binary/centos-binary-base/kolla-common.sh +++ /dev/null @@ -1 +0,0 @@ -../base/kolla-common.sh \ No newline at end of file diff --git a/docker/centos/binary/centos-binary-base/service_hosts.sh b/docker/centos/binary/centos-binary-base/service_hosts.sh deleted file mode 120000 index c36eb4203b..0000000000 --- a/docker/centos/binary/centos-binary-base/service_hosts.sh +++ /dev/null @@ -1 +0,0 @@ -../base/service_hosts.sh \ No newline at end of file diff --git a/docker/centos/binary/centos-rdo-base b/docker/centos/binary/centos-rdo-base deleted file mode 120000 index f3b111231c..0000000000 --- a/docker/centos/binary/centos-rdo-base +++ /dev/null @@ -1 +0,0 @@ -centos-binary-base/ \ No newline at end of file diff --git a/docker/centos/binary/fedora-binary-base/.buildconf b/docker/centos/binary/fedora-binary-base/.buildconf deleted file mode 100644 index d552b0d1b0..0000000000 --- a/docker/centos/binary/fedora-binary-base/.buildconf +++ /dev/null @@ -1 +0,0 @@ -PREFIX= diff --git a/docker/centos/binary/fedora-binary-base/kolla-common.sh b/docker/centos/binary/fedora-binary-base/kolla-common.sh deleted file mode 120000 index fcd13a80e1..0000000000 --- a/docker/centos/binary/fedora-binary-base/kolla-common.sh +++ /dev/null @@ -1 +0,0 @@ -../base/kolla-common.sh \ No newline at end of file diff --git a/docker/centos/binary/fedora-binary-base/service_hosts.sh b/docker/centos/binary/fedora-binary-base/service_hosts.sh deleted file mode 120000 index c36eb4203b..0000000000 --- a/docker/centos/binary/fedora-binary-base/service_hosts.sh +++ /dev/null @@ -1 +0,0 @@ -../base/service_hosts.sh \ No newline at end of file diff --git a/docker/centos/binary/fedora-rdo-base b/docker/centos/binary/fedora-rdo-base deleted file mode 120000 index a9be4eebb1..0000000000 --- a/docker/centos/binary/fedora-rdo-base +++ /dev/null @@ -1 +0,0 @@ -fedora-binary-base \ No newline at end of file diff --git a/docker/common/kolla-common.sh b/docker/common/kolla-common.sh new file mode 100644 index 0000000000..8c2ef5ec1c --- /dev/null +++ b/docker/common/kolla-common.sh @@ -0,0 +1,170 @@ +#!/bin/bash + +. /opt/kolla/service_hosts.sh + +# Set some generally useful defaults. +MY_IP=$(ip route get $(ip route | awk '$1 == "default" {print $3}') | + awk '$4 == "src" {print $5}') + +: ${PUBLIC_IP:=${MY_IP}} + +# Iterate over a list of variable names and exit if one is +# undefined. +check_required_vars() { + for var in $*; do + if [ -z "${!var}" ]; then + echo "ERROR: missing $var" >&2 + exit 1 + fi + done +} + +# The usage of the wait_for function looks like the following +# wait_for LOOPS_NUMBER SLEEP_TIME ARGS +# +# The ARGS are read and concatenated together into a single command and the +# command is executed in a loop until it succeeds or reaches the max number of +# attempts (LOOPS_NUMBER). +# +# Optional variables SUCCESSFUL_MATCH_OUTPUT and FAIL_MATCH_OUTPUT variable may +# also be set to control if the loop exits early if the commands stdout/stderr +# matches the supplied regex string. Consider using the `wait_for_output` and +# `wait_for_output_unless` functions in case there is a need to check for the +# command output. +# +# The script exits on failure, either when output contains string identified as +# failure, or when it reaches a timeout. +# +# Examples: +# wait_for 30 10 ping -c 1 192.0.2.2 +# wait_for 10 1 ls file_we_are_waiting_for +# wait_for 10 3 date \| grep 8 +wait_for() { + local loops=${1:-""} + local sleeptime=${2:-""} + FAIL_MATCH_OUTPUT=${FAIL_MATCH_OUTPUT:-""} + SUCCESSFUL_MATCH_OUTPUT=${SUCCESSFUL_MATCH_OUTPUT:-""} + shift 2 || true + local command="$@" + + if [ -z "$loops" -o -z "$sleeptime" -o -z "$command" ]; then + echo "wait_for is missing a required parameter" + exit 1 + fi + + local i=0 + while [ $i -lt $loops ]; do + i=$((i + 1)) + local status=0 + local output=$(eval $command 2>&1) || status=$? + if [[ -n "$SUCCESSFUL_MATCH_OUTPUT" ]] \ + && [[ $output =~ $SUCCESSFUL_MATCH_OUTPUT ]]; then + return 0 + elif [[ -n "$FAIL_MATCH_OUTPUT" ]] \ + && [[ $output =~ $FAIL_MATCH_OUTPUT ]]; then + echo "Command output matched '$FAIL_MATCH_OUTPUT'." + exit 1 + elif [[ -z "$SUCCESSFUL_MATCH_OUTPUT" ]] && [[ $status -eq 0 ]]; then + return 0 + fi + sleep $sleeptime + done + local seconds=$((loops * sleeptime)) + printf 'Timing out after %d seconds:\ncommand=%s\nOUTPUT=%s\n' \ + "$seconds" "$command" "$output" + exit 1 +} + +# Helper function to `wait_for` that only succeeds when the given regex is +# matching the command's output. Exit early with a failure when the second +# supplied regexp is matching the output. +# +# Example: +# wait_for_output_unless CREATE_COMPLETE CREATE_FAIL 30 10 heat stack-show undercloud +wait_for_output_unless() { + SUCCESSFUL_MATCH_OUTPUT=$1 + FAIL_MATCH_OUTPUT=$2 + shift 2 + wait_for $@ + local status=$? + unset SUCCESSFUL_MATCH_OUTPUT + unset FAIL_MATCH_OUTPUT + return $status +} + +# Helper function to `wait_for` that only succeeds when the given regex is +# matching the command's output. +# +# Example: +# wait_for_output CREATE_COMPLETE 30 10 heat stack-show undercloud +wait_for_output() { + local expected_output=$1 + shift + wait_for_output_unless $expected_output '' $@ +} + +# Check if we receive a successful response from corresponding OpenStack +# service endpoint. +check_for_os_service_endpoint() { + local name=$1 + local host_var=$2 + local port_var=$3 + local api_version=$4 + + check_required_vars $host_var $port_var + + local endpoint="http://${!host_var}:${!port_var}/$api_version" + + curl -sf -o /dev/null "$endpoint" || { + echo "ERROR: $name is not available @ $endpoint" >&2 + return 1 + } + + echo "$name is active @ $endpoint" +} + +check_for_os_service_running() { + local service=$1 + local args= + case $service in + ("glance") args="GLANCE_API_SERVICE_HOST GLANCE_API_SERVICE_PORT" ;; + ("keystone") args="KEYSTONE_PUBLIC_SERVICE_HOST KEYSTONE_PUBLIC_SERVICE_PORT v2.0" ;; + ("neutron") args="NEUTRON_SERVER_SERVICE_HOST NEUTRON_SERVER_SERVICE_PORT" ;; + ("nova") args="NOVA_API_SERVICE_HOST NOVA_API_SERVICE_PORT" ;; + (*) + echo "Unknown service $service" + return 1 ;; + esac + check_for_os_service_endpoint $service $args +} + +fail_unless_os_service_running() { + check_for_os_service_running $@ || exit $? +} + +# Check if we receive a successful response from the database server. +# Optionally takes a database name to check for. Defaults to 'mysql'. +check_for_db() { + local database=${1:-mysql} + check_required_vars MARIADB_SERVICE_HOST DB_ROOT_PASSWORD + + mysql -h ${MARIADB_SERVICE_HOST} -u root -p"${DB_ROOT_PASSWORD}" \ + -e "select 1" $database > /dev/null 2>&1 || { + echo "ERROR: database $database is not available @ $MARIADB_SERVICE_HOST" >&2 + return 1 + } + + echo "database is active @ ${MARIADB_SERVICE_HOST}" +} + +fail_unless_db() { + check_for_db $@ || exit $? +} + +# Dump shell environment to a file +dump_vars() { + set -o posix + set > /pid_$$_vars.sh + set +o posix +} + diff --git a/docker/common/service_hosts.sh b/docker/common/service_hosts.sh new file mode 100755 index 0000000000..c3006f720a --- /dev/null +++ b/docker/common/service_hosts.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Kubernetes currently creates FOO_SERVICE_HOST and FOO_SERVICE_PORT env vars +# as part of starting the containers. However this is not done when starting +# them with plain docker. Defaulting variables to their common version if +# they're not already set allows the usage of --link in plain 'docker run' to +# wire together containers. + +: ${BARBICAN_ADMIN_SERVICE_HOST:=$BARBICAN_ADMIN_PORT_9312_TCP_ADDR} +: ${BARBICAN_ADMIN_SERVICE_PORT:=9312} +: ${BARBICAN_PUBLIC_SERVICE_HOST:=$BARBICAN_PUBLIC_PORT_9311_TCP_ADDR} +: ${BARBICAN_PUBLIC_SERVICE_PORT:=9311} +: ${CEILOMETER_API_SERVICE_HOST:=$CEILOMETER_API_PORT_8777_TCP_ADDR} +: ${CEILOMETER_API_SERVICE_PORT:=8777} +: ${GLANCE_API_SERVICE_HOST:=$GLANCE_API_PORT_9292_TCP_ADDR} +: ${GLANCE_API_SERVICE_PORT:=9292} +: ${GLANCE_REGISTRY_SERVICE_HOST:=$GLANCE_REGISTRY_PORT_9191_TCP_ADDR} +: ${GLANCE_REGISTRY_SERVICE_PORT:=9191} +: ${HEAT_API_SERVICE_HOST:=$HEAT_API_PORT_8004_TCP_ADDR} +: ${HEAT_API_SERVICE_PORT:=8004} +: ${HORIZON_SERVICE_HOST:=$HORIZON_PORT_80_TCP_ADDR} +: ${HORIZON_SERVICE_PORT:=80} +: ${KEYSTONE_ADMIN_SERVICE_HOST:=$KEYSTONE_PORT_35357_TCP_ADDR} +: ${KEYSTONE_ADMIN_SERVICE_PORT:=35357} +: ${KEYSTONE_PUBLIC_SERVICE_HOST:=$KEYSTONE_PORT_5000_TCP_ADDR} +: ${KEYSTONE_PUBLIC_SERVICE_PORT:=5000} +: ${MARIADB_SERVICE_HOST:=$MARIADB_PORT_3306_TCP_ADDR} +: ${MARIADB_SERVICE_PORT:=3306} +: ${MONGODB_SERVICE_HOST:=$MONGODB_PORT_27017_TCP_ADDR} +: ${MONGODB_SERVICE_PORT:=27017} +: ${NEUTRON_SERVER_SERVICE_HOST:=$NEUTRON_SERVER_PORT_9696_TCP_ADDR} +: ${NEUTRON_SERVER_SERVICE_PORT:=9696} +: ${NOVA_API_SERVICE_HOST:=$NOVA_API_PORT_8774_TCP_ADDR} +: ${NOVA_API_SERVICE_PORT:=8774} +: ${NOVA_EC2_API_SERVICE_HOST:=$NOVA_EC2_API_PORT_8773_TCP_ADDR} +: ${NOVA_EC2_API_SERVICE_PORT:=8773} +: ${NOVA_LIBVIRT_SERVICE_HOST:=$NOVA_LIBVIRT_PORT_16509_TCP_ADDR} +: ${NOVA_LIBVIRT_SERVICE_PORT:=16509} +: ${NOVA_METADATA_API_SERVICE_HOST:=$NOVA_METADATA_API_PORT_8775_TCP_ADDR} +: ${NOVA_METADATA_API_SERVICE_PORT:=8775} +: ${RABBITMQ_SERVICE_HOST:=$RABBITMQ_PORT_5672_TCP_ADDR} +: ${RABBITMQ_SERVICE_PORT:=5672} +: ${ZAQAR_SERVER_SERVICE_HOST:=$ZAQAR_SERVER_PORT_8888_TCP_ADDR} +: ${ZAQAR_SERVER_SERVICE_PORT:=8888} + diff --git a/docker/fedora b/docker/fedora deleted file mode 120000 index 95e1895490..0000000000 --- a/docker/fedora +++ /dev/null @@ -1 +0,0 @@ -centos \ No newline at end of file diff --git a/docker/fedora/binary/barbican b/docker/fedora/binary/barbican new file mode 120000 index 0000000000..7dd5c24cef --- /dev/null +++ b/docker/fedora/binary/barbican @@ -0,0 +1 @@ +../../centos/binary/barbican \ No newline at end of file diff --git a/docker/centos/binary/fedora-binary-base/Dockerfile b/docker/fedora/binary/base/Dockerfile similarity index 100% rename from docker/centos/binary/fedora-binary-base/Dockerfile rename to docker/fedora/binary/base/Dockerfile diff --git a/docker/centos/binary/fedora-binary-base/build b/docker/fedora/binary/base/build similarity index 100% rename from docker/centos/binary/fedora-binary-base/build rename to docker/fedora/binary/base/build diff --git a/docker/fedora/binary/base/kolla-common.sh b/docker/fedora/binary/base/kolla-common.sh new file mode 120000 index 0000000000..380efbc3d7 --- /dev/null +++ b/docker/fedora/binary/base/kolla-common.sh @@ -0,0 +1 @@ +../../../common/kolla-common.sh \ No newline at end of file diff --git a/docker/fedora/binary/base/service_hosts.sh b/docker/fedora/binary/base/service_hosts.sh new file mode 120000 index 0000000000..777b7334d5 --- /dev/null +++ b/docker/fedora/binary/base/service_hosts.sh @@ -0,0 +1 @@ +../../../common/service_hosts.sh \ No newline at end of file diff --git a/docker/fedora/binary/ceilometer b/docker/fedora/binary/ceilometer new file mode 120000 index 0000000000..b9f08a71f2 --- /dev/null +++ b/docker/fedora/binary/ceilometer @@ -0,0 +1 @@ +../../centos/binary/ceilometer \ No newline at end of file diff --git a/docker/fedora/binary/cinder b/docker/fedora/binary/cinder new file mode 120000 index 0000000000..037fd7f7eb --- /dev/null +++ b/docker/fedora/binary/cinder @@ -0,0 +1 @@ +../../centos/binary/cinder \ No newline at end of file diff --git a/docker/fedora/binary/designate b/docker/fedora/binary/designate new file mode 120000 index 0000000000..5090326fe5 --- /dev/null +++ b/docker/fedora/binary/designate @@ -0,0 +1 @@ +../../centos/binary/designate \ No newline at end of file diff --git a/docker/fedora/binary/docker-compose b/docker/fedora/binary/docker-compose new file mode 120000 index 0000000000..287f1cd132 --- /dev/null +++ b/docker/fedora/binary/docker-compose @@ -0,0 +1 @@ +../../centos/binary/docker-compose \ No newline at end of file diff --git a/docker/fedora/binary/glance b/docker/fedora/binary/glance new file mode 120000 index 0000000000..4b4131254c --- /dev/null +++ b/docker/fedora/binary/glance @@ -0,0 +1 @@ +../../centos/binary/glance \ No newline at end of file diff --git a/docker/fedora/binary/hautoproxy b/docker/fedora/binary/hautoproxy new file mode 120000 index 0000000000..916cfd1974 --- /dev/null +++ b/docker/fedora/binary/hautoproxy @@ -0,0 +1 @@ +../../centos/binary/hautoproxy \ No newline at end of file diff --git a/docker/fedora/binary/heat b/docker/fedora/binary/heat new file mode 120000 index 0000000000..a675ed4cbb --- /dev/null +++ b/docker/fedora/binary/heat @@ -0,0 +1 @@ +../../centos/binary/heat \ No newline at end of file diff --git a/docker/fedora/binary/horizon b/docker/fedora/binary/horizon new file mode 120000 index 0000000000..c460446ee8 --- /dev/null +++ b/docker/fedora/binary/horizon @@ -0,0 +1 @@ +../../centos/binary/horizon \ No newline at end of file diff --git a/docker/fedora/binary/keystone b/docker/fedora/binary/keystone new file mode 120000 index 0000000000..fb666c53b8 --- /dev/null +++ b/docker/fedora/binary/keystone @@ -0,0 +1 @@ +../../centos/binary/keystone \ No newline at end of file diff --git a/docker/fedora/binary/magnum b/docker/fedora/binary/magnum new file mode 120000 index 0000000000..d5c1f84ed3 --- /dev/null +++ b/docker/fedora/binary/magnum @@ -0,0 +1 @@ +../../centos/binary/magnum \ No newline at end of file diff --git a/docker/fedora/binary/mariadb-app b/docker/fedora/binary/mariadb-app new file mode 120000 index 0000000000..017d6c2121 --- /dev/null +++ b/docker/fedora/binary/mariadb-app @@ -0,0 +1 @@ +../../centos/binary/mariadb-app \ No newline at end of file diff --git a/docker/fedora/binary/mariadb-data b/docker/fedora/binary/mariadb-data new file mode 120000 index 0000000000..095a5e84f1 --- /dev/null +++ b/docker/fedora/binary/mariadb-data @@ -0,0 +1 @@ +../../centos/binary/mariadb-data \ No newline at end of file diff --git a/docker/fedora/binary/mongodb b/docker/fedora/binary/mongodb new file mode 120000 index 0000000000..486f6030f4 --- /dev/null +++ b/docker/fedora/binary/mongodb @@ -0,0 +1 @@ +../../centos/binary/mongodb \ No newline at end of file diff --git a/docker/fedora/binary/neutron b/docker/fedora/binary/neutron new file mode 120000 index 0000000000..09ccb9467b --- /dev/null +++ b/docker/fedora/binary/neutron @@ -0,0 +1 @@ +../../centos/binary/neutron \ No newline at end of file diff --git a/docker/fedora/binary/nova-base b/docker/fedora/binary/nova-base new file mode 120000 index 0000000000..7600927f2b --- /dev/null +++ b/docker/fedora/binary/nova-base @@ -0,0 +1 @@ +../../centos/binary/nova-base \ No newline at end of file diff --git a/docker/fedora/binary/nova-compute b/docker/fedora/binary/nova-compute new file mode 120000 index 0000000000..ab70e1c1be --- /dev/null +++ b/docker/fedora/binary/nova-compute @@ -0,0 +1 @@ +../../centos/binary/nova-compute \ No newline at end of file diff --git a/docker/fedora/binary/nova-controller b/docker/fedora/binary/nova-controller new file mode 120000 index 0000000000..d4e6ba4ef3 --- /dev/null +++ b/docker/fedora/binary/nova-controller @@ -0,0 +1 @@ +../../centos/binary/nova-controller \ No newline at end of file diff --git a/docker/fedora/binary/rabbitmq b/docker/fedora/binary/rabbitmq new file mode 120000 index 0000000000..d6f927fc9f --- /dev/null +++ b/docker/fedora/binary/rabbitmq @@ -0,0 +1 @@ +../../centos/binary/rabbitmq \ No newline at end of file diff --git a/docker/fedora/binary/swift b/docker/fedora/binary/swift new file mode 120000 index 0000000000..b4416ea0f9 --- /dev/null +++ b/docker/fedora/binary/swift @@ -0,0 +1 @@ +../../centos/binary/swift \ No newline at end of file diff --git a/docker/fedora/binary/zaqar b/docker/fedora/binary/zaqar new file mode 120000 index 0000000000..1adc217cb2 --- /dev/null +++ b/docker/fedora/binary/zaqar @@ -0,0 +1 @@ +../../centos/binary/zaqar \ No newline at end of file diff --git a/docker/fedora/rdo b/docker/fedora/rdo new file mode 120000 index 0000000000..cab89b7b47 --- /dev/null +++ b/docker/fedora/rdo @@ -0,0 +1 @@ +binary \ No newline at end of file diff --git a/docker/rhel/binary/barbican b/docker/rhel/binary/barbican new file mode 120000 index 0000000000..7dd5c24cef --- /dev/null +++ b/docker/rhel/binary/barbican @@ -0,0 +1 @@ +../../centos/binary/barbican \ No newline at end of file diff --git a/docker/centos/binary/rhel-osp-base/Dockerfile b/docker/rhel/binary/base/Dockerfile similarity index 100% rename from docker/centos/binary/rhel-osp-base/Dockerfile rename to docker/rhel/binary/base/Dockerfile diff --git a/docker/centos/binary/rhel-osp-base/build b/docker/rhel/binary/base/build similarity index 100% rename from docker/centos/binary/rhel-osp-base/build rename to docker/rhel/binary/base/build diff --git a/docker/rhel/binary/base/kolla-common.sh b/docker/rhel/binary/base/kolla-common.sh new file mode 120000 index 0000000000..380efbc3d7 --- /dev/null +++ b/docker/rhel/binary/base/kolla-common.sh @@ -0,0 +1 @@ +../../../common/kolla-common.sh \ No newline at end of file diff --git a/docker/rhel/binary/base/service_hosts.sh b/docker/rhel/binary/base/service_hosts.sh new file mode 120000 index 0000000000..777b7334d5 --- /dev/null +++ b/docker/rhel/binary/base/service_hosts.sh @@ -0,0 +1 @@ +../../../common/service_hosts.sh \ No newline at end of file diff --git a/docker/rhel/binary/ceilometer b/docker/rhel/binary/ceilometer new file mode 120000 index 0000000000..b9f08a71f2 --- /dev/null +++ b/docker/rhel/binary/ceilometer @@ -0,0 +1 @@ +../../centos/binary/ceilometer \ No newline at end of file diff --git a/docker/rhel/binary/cinder b/docker/rhel/binary/cinder new file mode 120000 index 0000000000..037fd7f7eb --- /dev/null +++ b/docker/rhel/binary/cinder @@ -0,0 +1 @@ +../../centos/binary/cinder \ No newline at end of file diff --git a/docker/rhel/binary/designate b/docker/rhel/binary/designate new file mode 120000 index 0000000000..5090326fe5 --- /dev/null +++ b/docker/rhel/binary/designate @@ -0,0 +1 @@ +../../centos/binary/designate \ No newline at end of file diff --git a/docker/rhel/binary/docker-compose b/docker/rhel/binary/docker-compose new file mode 120000 index 0000000000..287f1cd132 --- /dev/null +++ b/docker/rhel/binary/docker-compose @@ -0,0 +1 @@ +../../centos/binary/docker-compose \ No newline at end of file diff --git a/docker/rhel/binary/glance b/docker/rhel/binary/glance new file mode 120000 index 0000000000..4b4131254c --- /dev/null +++ b/docker/rhel/binary/glance @@ -0,0 +1 @@ +../../centos/binary/glance \ No newline at end of file diff --git a/docker/rhel/binary/hautoproxy b/docker/rhel/binary/hautoproxy new file mode 120000 index 0000000000..916cfd1974 --- /dev/null +++ b/docker/rhel/binary/hautoproxy @@ -0,0 +1 @@ +../../centos/binary/hautoproxy \ No newline at end of file diff --git a/docker/rhel/binary/heat b/docker/rhel/binary/heat new file mode 120000 index 0000000000..a675ed4cbb --- /dev/null +++ b/docker/rhel/binary/heat @@ -0,0 +1 @@ +../../centos/binary/heat \ No newline at end of file diff --git a/docker/rhel/binary/horizon b/docker/rhel/binary/horizon new file mode 120000 index 0000000000..c460446ee8 --- /dev/null +++ b/docker/rhel/binary/horizon @@ -0,0 +1 @@ +../../centos/binary/horizon \ No newline at end of file diff --git a/docker/rhel/binary/keystone b/docker/rhel/binary/keystone new file mode 120000 index 0000000000..fb666c53b8 --- /dev/null +++ b/docker/rhel/binary/keystone @@ -0,0 +1 @@ +../../centos/binary/keystone \ No newline at end of file diff --git a/docker/rhel/binary/magnum b/docker/rhel/binary/magnum new file mode 120000 index 0000000000..d5c1f84ed3 --- /dev/null +++ b/docker/rhel/binary/magnum @@ -0,0 +1 @@ +../../centos/binary/magnum \ No newline at end of file diff --git a/docker/rhel/binary/mariadb-app b/docker/rhel/binary/mariadb-app new file mode 120000 index 0000000000..017d6c2121 --- /dev/null +++ b/docker/rhel/binary/mariadb-app @@ -0,0 +1 @@ +../../centos/binary/mariadb-app \ No newline at end of file diff --git a/docker/rhel/binary/mariadb-data b/docker/rhel/binary/mariadb-data new file mode 120000 index 0000000000..095a5e84f1 --- /dev/null +++ b/docker/rhel/binary/mariadb-data @@ -0,0 +1 @@ +../../centos/binary/mariadb-data \ No newline at end of file diff --git a/docker/rhel/binary/mongodb b/docker/rhel/binary/mongodb new file mode 120000 index 0000000000..486f6030f4 --- /dev/null +++ b/docker/rhel/binary/mongodb @@ -0,0 +1 @@ +../../centos/binary/mongodb \ No newline at end of file diff --git a/docker/rhel/binary/neutron b/docker/rhel/binary/neutron new file mode 120000 index 0000000000..09ccb9467b --- /dev/null +++ b/docker/rhel/binary/neutron @@ -0,0 +1 @@ +../../centos/binary/neutron \ No newline at end of file diff --git a/docker/rhel/binary/nova-base b/docker/rhel/binary/nova-base new file mode 120000 index 0000000000..7600927f2b --- /dev/null +++ b/docker/rhel/binary/nova-base @@ -0,0 +1 @@ +../../centos/binary/nova-base \ No newline at end of file diff --git a/docker/rhel/binary/nova-compute b/docker/rhel/binary/nova-compute new file mode 120000 index 0000000000..ab70e1c1be --- /dev/null +++ b/docker/rhel/binary/nova-compute @@ -0,0 +1 @@ +../../centos/binary/nova-compute \ No newline at end of file diff --git a/docker/rhel/binary/nova-controller b/docker/rhel/binary/nova-controller new file mode 120000 index 0000000000..d4e6ba4ef3 --- /dev/null +++ b/docker/rhel/binary/nova-controller @@ -0,0 +1 @@ +../../centos/binary/nova-controller \ No newline at end of file diff --git a/docker/rhel/binary/rabbitmq b/docker/rhel/binary/rabbitmq new file mode 120000 index 0000000000..d6f927fc9f --- /dev/null +++ b/docker/rhel/binary/rabbitmq @@ -0,0 +1 @@ +../../centos/binary/rabbitmq \ No newline at end of file diff --git a/docker/rhel/binary/swift b/docker/rhel/binary/swift new file mode 120000 index 0000000000..b4416ea0f9 --- /dev/null +++ b/docker/rhel/binary/swift @@ -0,0 +1 @@ +../../centos/binary/swift \ No newline at end of file diff --git a/docker/rhel/binary/zaqar b/docker/rhel/binary/zaqar new file mode 120000 index 0000000000..1adc217cb2 --- /dev/null +++ b/docker/rhel/binary/zaqar @@ -0,0 +1 @@ +../../centos/binary/zaqar \ No newline at end of file diff --git a/docker/rhel/osp b/docker/rhel/osp new file mode 120000 index 0000000000..cab89b7b47 --- /dev/null +++ b/docker/rhel/osp @@ -0,0 +1 @@ +binary \ No newline at end of file