add kolla-common shell library to base image
This adds a /opt/kolla/kolla-common.sh to the base image as a place to put commonly used functions. The goal is to avoid code duplication across all the images created from this base image. Change-Id: Ib670fe369bb8048aa69979b74a984fa4ddaae7d9
This commit is contained in:
parent
f2a747b353
commit
ff0d4d4c06
@ -1,8 +1,15 @@
|
||||
FROM fedora
|
||||
MAINTAINER Steven Dake <sdake@redhat.com>
|
||||
|
||||
# Set up repositories
|
||||
RUN yum install -y https://rdo.fedorapeople.org/rdo-release.rpm
|
||||
RUN yum -y install dnf dnf-plugins-core; yum clean all
|
||||
RUN dnf copr enable -y larsks/crux
|
||||
|
||||
# Update packages
|
||||
RUN yum update -y; yum clean all
|
||||
|
||||
# Install base packages
|
||||
RUN yum install -y \
|
||||
crux \
|
||||
mariadb \
|
||||
@ -39,12 +46,12 @@ RUN yum install -y \
|
||||
python-jsonschema \
|
||||
python-keyring \
|
||||
python-kombu \
|
||||
python-ldap \
|
||||
python-lesscpy \
|
||||
python-lockfile \
|
||||
python-lxml \
|
||||
python-markdown \
|
||||
python-memcached \
|
||||
python-ldap \
|
||||
python-migrate \
|
||||
python-msgpack \
|
||||
python-netifaces \
|
||||
@ -83,3 +90,7 @@ RUN yum install -y \
|
||||
python-werkzeug \
|
||||
python-wsme \
|
||||
; yum clean all
|
||||
|
||||
RUN mkdir -p /opt/kolla
|
||||
ADD kolla-common.sh /opt/kolla/kolla-common.sh
|
||||
|
||||
|
66
docker/fedora-rdo-base/kolla-common.sh
Normal file
66
docker/fedora-rdo-base/kolla-common.sh
Normal file
@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
# Exit unless we receive a successful response from the Glance API.
|
||||
check_for_glance() {
|
||||
check_required_vars GLANCE_API_SERVICE_HOST
|
||||
GLANCE_API_URL="http://${GLANCE_API_SERVICE_HOST}:9292/"
|
||||
|
||||
curl -sf -o /dev/null "$GLANCE_API_URL" || {
|
||||
echo "ERROR: glance is not available @ $GLANCE_API_URL" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "glance is active @ $GLANCE_API_URL"
|
||||
}
|
||||
|
||||
# Exit unless we receive a successful response from the Keystone API.
|
||||
check_for_keystone() {
|
||||
check_required_vars KEYSTONE_PUBLIC_SERVICE_HOST
|
||||
|
||||
KEYSTONE_URL="http://${KEYSTONE_PUBLIC_SERVICE_HOST}:5000/v2.0"
|
||||
|
||||
curl -sf -o /dev/null "$KEYSTONE_URL" || {
|
||||
echo "ERROR: keystone is not available @ $KEYSTONE_URL" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "keystone is active @ $KEYSTONE_URL"
|
||||
}
|
||||
|
||||
# Exit unless we receive a successful response from the database server.
|
||||
check_for_db() {
|
||||
check_required_vars MARIADB_SERVICE_HOST DB_ROOT_PASSWORD
|
||||
|
||||
mysql -h ${MARIADB_SERVICE_HOST} -u root -p"${DB_ROOT_PASSWORD}" \
|
||||
-e "select 1" mysql > /dev/null 2>&1 || {
|
||||
echo "ERROR: database is not available @ $MARIADB_SERVICE_HOST" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "database is active @ ${MARIADB_SERVICE_HOST}"
|
||||
}
|
||||
|
||||
# Dump shell environment to a file
|
||||
dump_vars() {
|
||||
set -o posix
|
||||
set > /pid_$$_vars.sh
|
||||
set +o posix
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user