added a bunch of glance stuff

This commit is contained in:
Lars Kellogg-Stedman 2014-09-18 21:41:38 -04:00
parent 2b686c5ffd
commit 25cfe70226
8 changed files with 177 additions and 69 deletions

10
docker/glance/build-all Normal file
View File

@ -0,0 +1,10 @@
#!/bin/sh
for image in glance-base glance-api glance-registry; do
(
cd $image
docker build -t docker.usersys.redhat.com/larsks/${image}:latest .
docker push docker.usersys.redhat.com/larsks/${image}:latest
)
done

View File

@ -1,11 +1,6 @@
FROM docker.usersys.redhat.com/lhh1/rhel-osp-base
FROM docker.usersys.redhat.com/larsks/glance-base
MAINTAINER Lars Kellogg-Stedman <lars@redhat.com>
yum -y install \
openstack-utils \
openstack-glance \
mariadb; yum clean all
ADD ./start.sh /start.sh
CMD ["/start.sh"]

View File

@ -1,60 +1,5 @@
#!/bin/bash
#!/bin/sh
: ${GLANCE_DB_USER:=glance}
: ${GLANCE_DB_NAME:=glance}
: ${KEYSTONE_ADMIN_PASSWORD:=redhat}
if ! [ "$KEYSTONE_ADMIN_TOKEN" ]; then
echo "*** Missing KEYSTONE_ADMIN_TOKEN."
exit 1
fi
if ! [ "$GLANCE_DB_PASSWORD" ]; then
GLANCE_DB_PASSWORD=$(openssl rand -hex 15)
fi
if ! [ "$GLANCE_KEYSTONE_PASSWORD" ]; then
GLANCE_KEYSTONE_PASSWORD=$(openssl rand -hex 15)
fi
mysql -h ${MARIADBMASTER_PORT_3306_TCP_ADDR} -u root -p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS glance;
GRANT ALL PRIVILEGES ON glance* TO
'glance'@'%' IDENTIFIED BY '${GLANCE_DB_PASSWORD}'
EOF
for service in api registry; do
crudini --set /etc/glance/glance-$service \
database \
connection \
mysql://${GLANCE_DB_USER}:${GLANCE_DB_PASSWORD}@${MARIADBMASTER_PORT_3306_TCP_ADDR}/${GLANCE_DB_NAME}
crudini --set /etc/glance/glance-$service \
keystone_authtoken \
admin_password \
"$GLANCE_KEYSTONE_PASSWORD"
crudini --set /etc/glance/glance-$service \
keystone_authtoken \
auth_uri \
"http://${KEYSTONEMASTER_5000_PORT_5000_TCP_ADDR}:5000/"
for option in auth_host auth_port auth_protocol; do
crudini --del /etc/glance/glance-$service \
keystone_authtoken \
$optoin
done
done
/usr/bin/glance-manage db sync
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="http://${KEYSTONEMASTER_35357_PORT_35357_TCP_ADDR}:35357/v2.0"
/bin/keystone user-create --name admin --pass ${KEYSTONE_ADMIN_PASSWORD}
/bin/keystone role-create --name admin
/bin/keystone tenant-create --name admin
/bin/keystone user-role-add --user admin --role admin --tenant admin
sh /opt/glance/config-glance.sh api
exec /usr/bin/glance-api

View File

@ -0,0 +1,12 @@
FROM docker.usersys.redhat.com/lhh1/rhel-osp-base
MAINTAINER Lars Kellogg-Stedman <lars@redhat.com>
RUN yum -y install \
openstack-utils \
openstack-glance \
python-keystoneclient \
mariadb; yum clean all
RUN mkdir /opt/glance
COPY config-glance.sh /opt/glance/config-glance.sh

View File

@ -0,0 +1,55 @@
#!/bin/sh
#
# usage config-glance.sh ( api | registry )
service=$1
cfg=/etc/glance/glance-${service}.conf
: ${GLANCE_DB_USER:=glance}
: ${GLANCE_DB_NAME:=glance}
: ${GLANCE_KEYSTONE_USER:=glance}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${ADMIN_TENANT_NAME:=admin}
if ! [ "$GLANCE_DB_PASSWORD" ]; then
echo "*** Missing GLANCE_DB_PASSWORD" >&2
exit 1
fi
crudini --del $cfg \
DEFAULT \
log_file \
crudini --set $cfg \
keystone_authtoken \
admin_password \
"${GLANCE_KEYSTONE_PASS}"
for option in auth_protocol auth_host auth_Port; do
crudini --del $cfg \
keystone_authtoken \
$option
done
crudini --set $cfg
keystone_authtoken \
auth_uri \
"${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONEMASTER_5000_PORT_5000_TCP_ADDR}:5000/"
crudini --set $cfg
keystone_authtoken \
admin_tenant_name \
"${ADMIN_TENANT_NAME}"
crudini --set $cfg
keystone_authtoken \
admin_user \
"${GLANCE_KEYSTONE_USER}"
crudini --set $cfg
keystone_authtoken \
admin_password \
"${GLANCE_KEYSTONE_PASS}"
crudini --set $cfg \
database \
connection \
"mysql://${GLANCE_DB_USER}:${GLANCE_DB_PASSWORD}@${MARIADBMASTER_PORT_3306_TCP_ADDR}:${MARIADBMASTER_PORT_3306_TCP_PORT}/${GLANCE_DB_NAME}"

View File

@ -1,11 +1,6 @@
FROM docker.usersys.redhat.com/lhh1/rhel-osp-base
FROM docker.usersys.redhat.com/larsks/glance-base
MAINTAINER Lars Kellogg-Stedman <lars@redhat.com>
yum -y install \
openstack-utils \
openstack-glance \
mariadb; yum clean all
ADD ./start.sh /start.sh
CMD ["/start.sh"]

View File

@ -0,0 +1,40 @@
#!/bin/sh
: ${GLANCE_DB_USER:=glance}
: ${GLANCE_DB_NAME:=glance}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${GLANCE_KEYSTONE_USER:=glance}
: ${ADMIN_TENANT_NAME:=admin}
if ! [ "$KEYSTONE_ADMIN_TOKEN" ]; then
echo "*** Missing KEYSTONE_ADMIN_TOKEN" >&2
exit 1
fi
if ! [ "$DB_ROOT_PASSWORD" ]; then
echo "*** Missing DB_ROOT_PASSWORD" >&2
exit 1
fi
if ! [ "$GLANCE_DB_PASSWORD" ]; then
GLANCE_DB_PASSWORD=$(openssl rand -hex 15)
export GLANCE_DB_PASSWORD
fi
sh /opt/glance/config-glance.sh registry
mysql -h ${MARIADBMASTER_PORT_3306_TCP_ADDR} -u root \
-p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS ${GLANCE_DB_NAME};
GRANT ALL PRIVILEGES ON glance* TO
'${GLANCE_DB_USER}'@'%' IDENTIFIED BY '${GLANCE_DB_PASSWORD}'
EOF
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONEMASTER_35357_PORT_35357_TCP_ADDR}:35357/v2.0"
/bin/keystone user-create --name ${GLANCE_KEYSTONE_USER} --pass ${GLANCE_ADMIN_PASSWORD}
/bin/keystone role-create --name ${GLANCE_KEYSTONE_USER}
/bin/keystone user-role-add --user ${GLANCE_KEYSTONE_USER} --role admin --tenant ${ADMIN_TENANT_NAME}
exec /usr/bin/glance-registry

56
docker/glance/glance.json Normal file
View File

@ -0,0 +1,56 @@
{
"id": "glance",
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "glance-1",
"containers": [
{
"name": "glance-registry",
"image": "docker.usersys.redhat.com/larsks/glance-registry",
"ports": [
{"containerPort": 9292},
],
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "GLANCE_DB_PASSWORD",
"value": "glancedbpassword"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
},
]
},
{
"name": "glance-api",
"image": "docker.usersys.redhat.com/larsks/glance-api",
"ports": [
{"containerPort": 9292},
],
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "GLANCE_DB_PASSWORD",
"value": "glancedbpassword"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
},
]
},
]
}
},
"labels": {
"name": "keystone-master"
}
}