fix issues with glance scripts

- glance was using wrong var name for admin_password
- also missing "\" in several places, breaking multi-line crudini
  commands.
- glance was using wrong tenant name
- in the registry container, glance-manage appears to reference
  glance-api.conf
- the glance.json config file was not spawning a registry container

Change-Id: I280d1db3ed576988f2bf29ea665e1922a37f8752
This commit is contained in:
Lars Kellogg-Stedman 2014-10-05 09:54:53 -04:00
parent 3c080f9e62
commit d28f83dace
7 changed files with 102 additions and 85 deletions

View File

@ -1,10 +1,10 @@
{
"id": "glanceapimaster",
"id": "glance-api",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 9292,
"containerPort": 9292,
"selector": {
"name": "glance-api-master"
"name": "glance"
}
}

View File

@ -1,5 +1,23 @@
#!/bin/sh
sh /opt/glance/config-glance.sh api
if ! [ "$KEYSTONE_ADMIN_TOKEN" ]; then
echo "*** Missing KEYSTONE_ADMIN_TOKEN" >&2
exit 1
fi
. /opt/glance/config-glance.sh
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="http://${KEYSTONE_ADMIN_PORT_35357_TCP_ADDR}:35357/v2.0"
crux user-create -n "${GLANCE_KEYSTONE_USER}" \
-p "${GLANCE_KEYSTONE_PASSWORD}" \
-t "${ADMIN_TENANT_NAME}" \
-r admin
crux endpoint-create -n glance -t image \
-I "http://${GLANCE_API_PORT_9292_TCP_ADDR}:9292" \
-P "http://${PUBLIC_IP}:9292" \
-A "http://${GLANCE_API_PORT_9292_TCP_ADDR}:9292"
exec /usr/bin/glance-api

View File

@ -1,11 +1,14 @@
FROM kollaglue/fedora-rdo-base
MAINTAINER Dan Radez <dradez@redhat.com>
RUN yum -y install dnf dnf-plugins-core; yum clean all
RUN dnf copr enable -y larsks/crux
RUN yum -y install \
openstack-utils \
openstack-glance \
python-keystoneclient \
mariadb; yum clean all
mariadb crux \
; yum clean all
RUN mkdir /opt/glance
COPY config-glance.sh /opt/glance/config-glance.sh

View File

@ -2,53 +2,76 @@
#
# usage config-glance.sh ( api | registry )
service=$1
cfg=/etc/glance/glance-${service}.conf
[ -f /startconfig ] && . /startconfig
: ${GLANCE_DB_USER:=glance}
MY_IP=$(ip route get $(ip route | awk '$1 == "default" {print $3}') |
awk '$4 == "src" {print $5}')
: ${ADMIN_TENANT_NAME:=admin}
: ${GLANCE_DB_NAME:=glance}
: ${GLANCE_DB_USER:=glance}
: ${GLANCE_KEYSTONE_USER:=glance}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${ADMIN_TENANT_NAME:=admin}
: ${PUBLIC_IP:=$MY_IP}
if ! [ "$GLANCE_DB_PASSWORD" ]; then
echo "*** Missing GLANCE_DB_PASSWORD" >&2
exit 1
GLANCE_DB_PASSWORD=$(openssl rand -hex 15)
export GLANCE_DB_PASSWORD
fi
crudini --del $cfg \
if ! [ "$GLANCE_KEYSTONE_PASSWORD" ]; then
GLANCE_KEYSTONE_PASSWORD=$(openssl rand -hex 15)
export GLANCE_KEYSTONE_PASSWORD
fi
if ! [ -f /startconfig ]; then
cat > /startconfig <<-EOF
ADMIN_TENANT_NAME=${ADMIN_TENANT_NAME}
GLANCE_DB_NAME=${GLANCE_DB_NAME}
GLANCE_DB_USER=${GLANCE_DB_USER}
GLANCE_KEYSTONE_USER=${GLANCE_KEYSTONE_USER}
KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL}
PUBLIC_IP=${PUBLIC_IP}
GLANCE_DB_PASSWORD=${GLANCE_DB_PASSWORD}
GLANCE_KEYSTONE_PASSWORD=${GLANCE_KEYSTONE_PASSWORD}
EOF
fi
for cfg in /etc/glance/glance-api.conf /etc/glance/glance-registry.conf; do
crudini --del $cfg \
DEFAULT \
log_file \
crudini --set $cfg \
keystone_authtoken \
admin_password \
"${GLANCE_KEYSTONE_PASS}"
log_file
for option in auth_protocol auth_host auth_Port; do
for option in auth_protocol auth_host auth_port; do
crudini --del $cfg \
keystone_authtoken \
$option
done
keystone_authtoken \
$option
done
crudini --set $cfg
crudini --set $cfg \
DEFAULT \
bind_host \
$MY_IP
crudini --set $cfg \
keystone_authtoken \
auth_uri \
"${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_PUBLIC_PORT_5000_TCP_ADDR}:5000/"
crudini --set $cfg
"http://${KEYSTONE_PUBLIC_PORT_5000_TCP_ADDR}:5000/"
crudini --set $cfg \
keystone_authtoken \
admin_tenant_name \
"${ADMIN_TENANT_NAME}"
crudini --set $cfg
"${ADMIN_TENANT_NAME}"
crudini --set $cfg \
keystone_authtoken \
admin_user \
"${GLANCE_KEYSTONE_USER}"
crudini --set $cfg
crudini --set $cfg \
keystone_authtoken \
admin_password \
"${GLANCE_KEYSTONE_PASS}"
"${GLANCE_KEYSTONE_PASSWORD}"
crudini --set $cfg \
crudini --set $cfg \
database \
connection \
"mysql://${GLANCE_DB_USER}:${GLANCE_DB_PASSWORD}@${MARIADB_PORT_3306_TCP_ADDR}:${MARIADB_PORT_3306_TCP_PORT}/${GLANCE_DB_NAME}"
"mysql://${GLANCE_DB_USER}:${GLANCE_DB_PASSWORD}@${MARIADB_PORT_3306_TCP_ADDR}/${GLANCE_DB_NAME}"
done

View File

@ -1,10 +1,10 @@
{
"id": "glanceregistrymaster",
"id": "glance-registry",
"kind": "Service",
"apiVersion": "v1beta1",
"port": 9191,
"containerPort": 9191,
"selector": {
"name": "glance-registry-master"
"name": "glance"
}
}

View File

@ -1,27 +1,6 @@
#!/bin/sh
: ${GLANCE_DB_USER:=glance}
: ${GLANCE_DB_NAME:=glance}
: ${KEYSTONE_AUTH_PROTOCOL:=http}
: ${GLANCE_KEYSTONE_USER:=glance}
: ${GLANCE_TENANT_NAME:=services}
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
. /opt/glance/config-glance.sh
mysql -h ${MARIADB_PORT_3306_TCP_ADDR} -u root -p${DB_ROOT_PASSWORD} mysql <<EOF
CREATE DATABASE IF NOT EXISTS ${GLANCE_DB_NAME} DEFAULT CHARACTER SET utf8;
@ -32,10 +11,4 @@ EOF
/usr/bin/glance-manage db_sync
export SERVICE_TOKEN="${KEYSTONE_ADMIN_TOKEN}"
export SERVICE_ENDPOINT="${KEYSTONE_AUTH_PROTOCOL}://${KEYSTONE_ADMIN_PORT_35357_TCP_ADDR}:35357/v2.0"
/usr/bin/keystone user-create --name ${GLANCE_KEYSTONE_USER} --pass ${GLANCE_KEYSTONE_PASS}
/usr/bin/keystone user-role-add --user ${GLANCE_KEYSTONE_USER} --role admin --tenant ${GLANCE_TENANT_NAME}
exec /usr/bin/glance-registry

View File

@ -1,18 +1,31 @@
{
"id": "glance",
"desiredState": {
"manifest": {
"version": "v1beta1",
"id": "glance-1",
"containers": [
{
"name": "glance-registry",
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "GLANCE_DB_PASSWORD",
"value": "password"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
}
],
"image": "kollaglue/fedora-rdo-glance-registry",
"name": "glance-registry",
"ports": [
{
"containerPort": 9191
}
],
]
},
{
"env": [
{
"name": "DB_ROOT_PASSWORD",
@ -20,41 +33,28 @@
},
{
"name": "GLANCE_DB_PASSWORD",
"value": "glancedbpassword"
"value": "password"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
}
]
},
{
"name": "glance-api",
],
"image": "kollaglue/fedora-rdo-glance-api",
"name": "glance-api",
"ports": [
{
"containerPort": 9292
}
],
"env": [
{
"name": "DB_ROOT_PASSWORD",
"value": "password"
},
{
"name": "GLANCE_DB_PASSWORD",
"value": "glancedbpassword"
},
{
"name": "KEYSTONE_ADMIN_TOKEN",
"value": "ADMINTOKEN"
}
]
}
]
],
"id": "glance-1",
"version": "v1beta1"
}
},
"id": "glance",
"labels": {
"name": "glance-master"
"name": "glance"
}
}