[openstack-glance/f17] Update openstack-glance-db-setup, change config permissions.
Russell Bryant
russellb at fedoraproject.org
Wed Mar 28 15:17:11 UTC 2012
commit 97bbaa058acedd0760da9526b6c755dcd91a0319
Author: Russell Bryant <rbryant at redhat.com>
Date: Wed Mar 28 10:51:12 2012 -0400
Update openstack-glance-db-setup, change config permissions.
openstack-glance-db-setup | 72 +++++++++++++++++++++++++++------------------
openstack-glance.spec | 32 ++++++++++++--------
2 files changed, 62 insertions(+), 42 deletions(-)
---
diff --git a/openstack-glance-db-setup b/openstack-glance-db-setup
index 3dc2a34..43d1a89 100755
--- a/openstack-glance-db-setup
+++ b/openstack-glance-db-setup
@@ -2,6 +2,7 @@
#
# Copyright (C) 2011 - 2012, Red Hat, Inc.
# Russell Bryant <rbryant at redhat.com>
+# Alan Pevec <apevec at redhat.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@@ -19,23 +20,28 @@
#
# Print --help output and exit.
#
+
+# TODO put it in common place for all openstack service
+# (nova, glance and keystone) to use
+APP=glance
+
usage() {
cat << EOF
-Set up a local MySQL database for use with openstack-glance.
-This script will create a 'glance' database that is accessible
-only on localhost by user 'glance' with password 'glance'.
+Set up a local MySQL database for use with openstack-$APP.
+This script will create a '$APP' database that is accessible
+only on localhost by user '$APP' with password '$APP'.
The setup of MySQL with a multi-server OpenStack installation
is outside of the scope of this simple helper script.
-Usage: openstack-glance-db-setup [options]
+Usage: openstack-$APP-db-setup [options]
Options:
--help | -h
Print usage information.
- --glancepw <pw> | -n <pw>
- Specify the password for the 'glance' MySQL user that glance will
- use to connect to the 'glance' MySQL database. By default,
- the password 'glance' will be used.
+ --password <pw> | -p <pw>
+ Specify the password for the '$APP' MySQL user that $APP will
+ use to connect to the '$APP' MySQL database. By default,
+ the password '$APP' will be used.
--rootpw <pw> | -r <pw>
Specify the root MySQL password. If the script installs
the MySQL server, it will set the root password to this value
@@ -64,9 +70,13 @@ start_mysql_server() {
systemctl start mysqld.service
}
-MYSQL_GLANCE_PW_DEFAULT="glance"
-MYSQL_GLANCE_PW=${MYSQL_GLANCE_PW_DEFAULT}
-GLANCE_CONFIG="/etc/glance/glance.conf"
+MYSQL_APP_PW_DEFAULT="$APP"
+MYSQL_APP_PW=${MYSQL_APP_PW_DEFAULT}
+if [ "${APP}" = "glance" ]; then
+ APP_CONFIG="/etc/glance/glance-registry.conf"
+else
+ APP_CONFIG="/etc/$APP/$APP.conf"
+fi
ASSUME_YES=""
while [ $# -gt 0 ]
@@ -75,9 +85,9 @@ do
-h|--help)
usage
;;
- -n|--glancepw)
+ -p|--password)
shift
- MYSQL_GLANCE_PW=${1}
+ MYSQL_APP_PW=${1}
;;
-r|--rootpw)
shift
@@ -202,37 +212,41 @@ echo "Verified connectivity to MySQL."
# Now create the db.
-echo "Creating 'glance' database."
+echo "Creating '$APP' database."
cat << EOF | mysql -u root ${MYSQL_ROOT_PW_ARG}
-CREATE DATABASE glance;
-CREATE USER 'glance'@'localhost' IDENTIFIED BY '${MYSQL_GLANCE_PW}';
-CREATE USER 'glance'@'%' IDENTIFIED BY '${MYSQL_GLANCE_PW}';
-GRANT ALL ON glance.* TO 'glance'@'localhost';
-GRANT ALL ON glance.* TO 'glance'@'%';
+CREATE DATABASE $APP;
+CREATE USER '$APP'@'localhost' IDENTIFIED BY '${MYSQL_APP_PW}';
+CREATE USER '$APP'@'%' IDENTIFIED BY '${MYSQL_APP_PW}';
+GRANT ALL ON $APP.* TO '$APP'@'localhost';
+GRANT ALL ON $APP.* TO '$APP'@'%';
flush privileges;
EOF
-# Make sure glance configuration has the right MySQL password.
+# Make sure $APP configuration has the right MySQL password.
-if [ "${MYSQL_GLANCE_PW}" != "${MYSQL_GLANCE_PW_DEFAULT}" ] ; then
- echo "Updating 'glance' database password in ${GLANCE_CONFIG}"
- sed -i -e "s/mysql:\/\/glance:\(.*\)@/mysql:\/\/glance:${MYSQL_GLANCE_PW}@/" ${GLANCE_CONFIG}
+if [ "${MYSQL_APP_PW}" != "${MYSQL_APP_PW_DEFAULT}" ] ; then
+ echo "Updating '$APP' database password in ${APP_CONFIG}"
+ sed -i -e "s/mysql:\/\/$APP:\(.*\)@/mysql:\/\/$APP:${MYSQL_APP_PW}@/" ${APP_CONFIG}
fi
-# Ask openstack-glance to sync the db.
-
-echo "Asking openstack-glance to sync the database."
-glance-manage db_sync
+# Ask openstack-$APP to sync the db.
+echo "Asking openstack-$APP to sync the database."
+if [ "${APP}" = "nova" ]; then
+ nova-manage db sync
+else
+ # glance and keystone
+ $APP-manage db_sync
+fi
# Do a final sanity check on the database.
-echo "SELECT * FROM migrate_version;" | mysql -u glance --password=${MYSQL_GLANCE_PW} glance > /dev/null
+echo "SELECT * FROM migrate_version;" | mysql -u $APP --password=${MYSQL_APP_PW} $APP > /dev/null
if ! [ $? -eq 0 ]
then
- echo "Final sanity check failed. File a bug report on bugzilla.redhat.com against the openstack-glance package."
+ echo "Final sanity check failed. File a bug report on bugzilla.redhat.com against the openstack-$APP package."
exit 1
fi
diff --git a/openstack-glance.spec b/openstack-glance.spec
index c9745d5..b17dd44 100644
--- a/openstack-glance.spec
+++ b/openstack-glance.spec
@@ -1,6 +1,6 @@
Name: openstack-glance
Version: 2012.1
-Release: 0.9.rc1%{?dist}
+Release: 0.10.rc1%{?dist}
Summary: OpenStack Image Service
Group: Applications/System
@@ -130,7 +130,8 @@ install -d -m 755 %{buildroot}%{_sharedstatedir}/glance/images
# Config file
install -p -D -m 644 etc/glance-api.conf %{buildroot}%{_sysconfdir}/glance/glance-api.conf
install -p -D -m 644 etc/glance-api-paste.ini %{buildroot}%{_sysconfdir}/glance/glance-api-paste.ini
-install -p -D -m 644 etc/glance-registry.conf %{buildroot}%{_sysconfdir}/glance/glance-registry.conf
+# glance-registry.conf contains a db password
+install -p -D -m 640 etc/glance-registry.conf %{buildroot}%{_sysconfdir}/glance/glance-registry.conf
install -p -D -m 644 etc/glance-registry-paste.ini %{buildroot}%{_sysconfdir}/glance/glance-registry-paste.ini
install -p -D -m 644 etc/glance-cache.conf %{buildroot}%{_sysconfdir}/glance/glance-cache.conf
install -p -D -m 644 etc/glance-cache-paste.ini %{buildroot}%{_sysconfdir}/glance/glance-cache-paste.ini
@@ -202,16 +203,16 @@ fi
%{_unitdir}/openstack-glance-registry.service
%{_mandir}/man1/glance*.1.gz
%dir %{_sysconfdir}/glance
-%config(noreplace) %{_sysconfdir}/glance/glance-api.conf
-%config(noreplace) %{_sysconfdir}/glance/glance-api-paste.ini
-%config(noreplace) %{_sysconfdir}/glance/glance-registry.conf
-%config(noreplace) %{_sysconfdir}/glance/glance-registry-paste.ini
-%config(noreplace) %{_sysconfdir}/glance/glance-cache.conf
-%config(noreplace) %{_sysconfdir}/glance/glance-cache-paste.ini
-%config(noreplace) %{_sysconfdir}/glance/glance-scrubber.conf
-%config(noreplace) %{_sysconfdir}/glance/glance-scrubber-paste.ini
-%config(noreplace) %{_sysconfdir}/glance/policy.json
-%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-glance
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-api.conf
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-api-paste.ini
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-registry.conf
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-registry-paste.ini
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-cache.conf
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-cache-paste.ini
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-scrubber.conf
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/glance-scrubber-paste.ini
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/glance/policy.json
+%config(noreplace) %attr(-, root, glance) %{_sysconfdir}/logrotate.d/openstack-glance
%dir %attr(0755, glance, nobody) %{_sharedstatedir}/glance
%dir %attr(0755, glance, nobody) %{_localstatedir}/log/glance
%dir %attr(0755, glance, nobody) %{_localstatedir}/run/glance
@@ -225,7 +226,12 @@ fi
%doc doc/build/html
%changelog
-* Tue Mar 27 2012 Russell Bryant <rbryant at redhat.com> - 2012-.1-0.9.rc1
+* Wed Mar 28 2012 Russell Bryant <rbryant at redhat.com> - 2012.1-0.10.rc1
+- Update openstack-glance-db-setup to common script from openstack-keystone package.
+- Change permissions of glance-registry.conf to 0640.
+- Set group on all config files to glance.
+
+* Tue Mar 27 2012 Russell Bryant <rbryant at redhat.com> - 2012.1-0.9.rc1
- Use MySQL by default.
- Add openstack-glance-db-setup script.
More information about the scm-commits
mailing list