aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2014-10-09 10:32:44 -0400
committerLars Kellogg-Stedman <lars@redhat.com>2014-10-13 14:41:37 -0400
commitff0d4d4c061d0ba3831bfe51a753af95c1991fc0 (patch)
treef0907cde989b386aed76847da50d6fcd39e36cae
parentf2a747b353b01431e12e5b298f0ed0ea48485cba (diff)
downloadkolla-ff0d4d4c061d0ba3831bfe51a753af95c1991fc0.tar.gz
kolla-ff0d4d4c061d0ba3831bfe51a753af95c1991fc0.zip
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
-rw-r--r--docker/fedora-rdo-base/Dockerfile13
-rw-r--r--docker/fedora-rdo-base/kolla-common.sh66
2 files changed, 78 insertions, 1 deletions
diff --git a/docker/fedora-rdo-base/Dockerfile b/docker/fedora-rdo-base/Dockerfile
index f3a46e260..6b93274fe 100644
--- a/docker/fedora-rdo-base/Dockerfile
+++ b/docker/fedora-rdo-base/Dockerfile
@@ -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
+
diff --git a/docker/fedora-rdo-base/kolla-common.sh b/docker/fedora-rdo-base/kolla-common.sh
new file mode 100644
index 000000000..b625588b3
--- /dev/null
+++ b/docker/fedora-rdo-base/kolla-common.sh
@@ -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
+}
+