diff --git a/docker/centos/binary/magnum/magnum-api/Dockerfile b/docker/centos/binary/magnum/magnum-api/Dockerfile index 84efa2a92d..7b0ab74d2c 100644 --- a/docker/centos/binary/magnum/magnum-api/Dockerfile +++ b/docker/centos/binary/magnum/magnum-api/Dockerfile @@ -8,4 +8,6 @@ RUN yum -y install \ ADD ./start.sh /start.sh ADD ./check.sh /check.sh +COPY config-internal.sh config-external.sh /opt/kolla/ + CMD ["/start.sh"] diff --git a/docker/centos/binary/magnum/magnum-api/config-external.sh b/docker/centos/binary/magnum/magnum-api/config-external.sh new file mode 100644 index 0000000000..51d63c9ec0 --- /dev/null +++ b/docker/centos/binary/magnum/magnum-api/config-external.sh @@ -0,0 +1 @@ +../../../../common/magnum/magnum-api/config-external.sh diff --git a/docker/centos/binary/magnum/magnum-api/config-internal.sh b/docker/centos/binary/magnum/magnum-api/config-internal.sh new file mode 100644 index 0000000000..3637ccaff5 --- /dev/null +++ b/docker/centos/binary/magnum/magnum-api/config-internal.sh @@ -0,0 +1 @@ +../../../../common/magnum/magnum-api/config-internal.sh diff --git a/docker/centos/binary/magnum/magnum-conductor/Dockerfile b/docker/centos/binary/magnum/magnum-conductor/Dockerfile index f3d506cb8f..691d02d093 100644 --- a/docker/centos/binary/magnum/magnum-conductor/Dockerfile +++ b/docker/centos/binary/magnum/magnum-conductor/Dockerfile @@ -10,4 +10,7 @@ RUN yum -y install \ RUN cd /tmp && curl -L https://github.com/GoogleCloudPlatform/kubernetes/releases/download/v0.15.0/kubernetes.tar.gz -o /tmp/kubernetes.tar.gz && /usr/bin/tar -xzvf /tmp/kubernetes.tar.gz && cp -a /tmp/kubernetes/platforms/linux/amd64/kubectl /usr/bin/kubectl && rm -rf /tmp/kubernetes ADD ./start.sh /start.sh + +COPY config-internal.sh config-external.sh /opt/kolla/ + CMD ["/start.sh"] diff --git a/docker/centos/binary/magnum/magnum-conductor/config-external.sh b/docker/centos/binary/magnum/magnum-conductor/config-external.sh new file mode 100644 index 0000000000..a9ca55e4e2 --- /dev/null +++ b/docker/centos/binary/magnum/magnum-conductor/config-external.sh @@ -0,0 +1 @@ +../../../../common/magnum/magnum-conductor/config-external.sh diff --git a/docker/centos/binary/magnum/magnum-conductor/config-internal.sh b/docker/centos/binary/magnum/magnum-conductor/config-internal.sh new file mode 100644 index 0000000000..b2302e7ae3 --- /dev/null +++ b/docker/centos/binary/magnum/magnum-conductor/config-internal.sh @@ -0,0 +1 @@ +../../../../common/magnum/magnum-conductor/config-internal.sh diff --git a/docker/common/magnum/magnum-api/config-external.sh b/docker/common/magnum/magnum-api/config-external.sh new file mode 100644 index 0000000000..573043f7d9 --- /dev/null +++ b/docker/common/magnum/magnum-api/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/magnum/magnum-api/magnum.conf" +TARGET="/etc/magnum/magnum.conf" +OWNER="magnum" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/magnum/magnum-api/config-internal.sh b/docker/common/magnum/magnum-api/config-internal.sh new file mode 100644 index 0000000000..00a51b3cdf --- /dev/null +++ b/docker/common/magnum/magnum-api/config-internal.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-magnum.sh + +check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ + MAGNUM_KEYSTONE_USER MAGNUM_KEYSTONE_PASSWORD \ + KEYSTONE_AUTH_PROTOCOL ADMIN_TENANT_NAME \ + MAGNUM_API_SERVICE_HOST KEYSTONE_ADMIN_SERVICE_PORT \ + MAGNUM_API_SERVICE_PORT + +fail_unless_os_service_running keystone + +export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" +export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0" +crux user-create -n ${MAGNUM_KEYSTONE_USER} \ + -p ${MAGNUM_KEYSTONE_PASSWORD} \ + -t ${ADMIN_TENANT_NAME} \ + -r admin + +crux endpoint-create --remove-all -n ${MAGNUM_KEYSTONE_USER} -t container \ + -I "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \ + -P "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \ + -A "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" + +exec /usr/bin/magnum-api diff --git a/docker/common/magnum/magnum-api/start.sh b/docker/common/magnum/magnum-api/start.sh index 00a51b3cdf..5a47fdf89d 100755 --- a/docker/common/magnum/magnum-api/start.sh +++ b/docker/common/magnum/magnum-api/start.sh @@ -1,27 +1,20 @@ #!/bin/bash -set -e -. /opt/kolla/kolla-common.sh -. /opt/kolla/config-magnum.sh +set -o errexit +CMD="/usr/bin/magnum-api" +ARGS="" -check_required_vars KEYSTONE_ADMIN_TOKEN KEYSTONE_ADMIN_SERVICE_HOST \ - MAGNUM_KEYSTONE_USER MAGNUM_KEYSTONE_PASSWORD \ - KEYSTONE_AUTH_PROTOCOL ADMIN_TENANT_NAME \ - MAGNUM_API_SERVICE_HOST KEYSTONE_ADMIN_SERVICE_PORT \ - MAGNUM_API_SERVICE_PORT +# Loading common functions. +source /opt/kolla/kolla-common.sh -fail_unless_os_service_running keystone +# Config-internal script exec out of this function, it does not return here. +set_configs -export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}" -export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_SERVICE_HOST}:${KEYSTONE_ADMIN_SERVICE_PORT}/v2.0" -crux user-create -n ${MAGNUM_KEYSTONE_USER} \ - -p ${MAGNUM_KEYSTONE_PASSWORD} \ - -t ${ADMIN_TENANT_NAME} \ - -r admin +# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases +# of the KOLLA_BOOTSTRAP variable being set, including empty. +if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then + su -s /bin/sh -c "magnum-manage db_sync" magnum + exit 0 +fi -crux endpoint-create --remove-all -n ${MAGNUM_KEYSTONE_USER} -t container \ - -I "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \ - -P "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" \ - -A "${KEYSTONE_AUTH_PROTOCOL}://${MAGNUM_API_SERVICE_HOST}:${MAGNUM_API_SERVICE_PORT}/v1" - -exec /usr/bin/magnum-api +exec $CMD $ARGS diff --git a/docker/common/magnum/magnum-conductor/config-external.sh b/docker/common/magnum/magnum-conductor/config-external.sh new file mode 100644 index 0000000000..b96e3179e0 --- /dev/null +++ b/docker/common/magnum/magnum-conductor/config-external.sh @@ -0,0 +1,10 @@ +#!/bin/bash +SOURCE="/opt/kolla/magnum/magnum-conductor/magnum.conf" +TARGET="/etc/magnum/magnum.conf" +OWNER="magnum" + +if [[ -f "$SOURCE" ]]; then + cp $SOURCE $TARGET + chown ${OWNER}: $TARGET + chmod 0644 $TARGET +fi diff --git a/docker/common/magnum/magnum-conductor/config-internal.sh b/docker/common/magnum/magnum-conductor/config-internal.sh new file mode 100644 index 0000000000..4cf1291a39 --- /dev/null +++ b/docker/common/magnum/magnum-conductor/config-internal.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +. /opt/kolla/kolla-common.sh +. /opt/kolla/config-magnum.sh + +check_required_vars MAGNUM_DB_NAME MAGNUM_DB_USER MAGNUM_DB_PASSWORD +fail_unless_db + +mysql -h ${MARIADB_SERVICE_HOST} -u root -p${DB_ROOT_PASSWORD} mysql <