aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@windriver.com>2013-10-04 00:27:53 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2013-10-04 13:16:33 -0400
commit608fa75973c111c61cf55e99cf3172ff3f3f00b1 (patch)
treefa3b3a3d457dc1daafdefa5c100379bcf3de1928
parent6806482a7ba6f020b0cff44b2b797eede2b702af (diff)
downloadmeta-cloud-services-608fa75973c111c61cf55e99cf3172ff3f3f00b1.tar.gz
meta-cloud-services-608fa75973c111c61cf55e99cf3172ff3f3f00b1.tar.bz2
meta-cloud-services-608fa75973c111c61cf55e99cf3172ff3f3f00b1.zip
postgresql: unify startup and initialization
Since we can't count on package postinst order, many components check for a configured postgresql daemon, and if not found, initialize it. Rather than sprinkling the knowledge of how to initialize the database through all these packages, we create a more robust, central postgresql-init script, and call it when any component needs the database configured. Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r--meta-openstack-qemu/recipes-devtools/python/python-nova-controller_2013.1.3.bbappend11
-rw-r--r--meta-openstack-qemu/recipes-devtools/python/python-nova_2013.1.3.bbappend (renamed from meta-openstack-qemu/recipes-devtools/python/python-nova-compute_2013.1.3.bbappend)0
-rw-r--r--meta-openstack/recipes-devtools/python/python-cinder_2013.1.3.bb4
-rw-r--r--meta-openstack/recipes-devtools/python/python-glance_2013.1.3.bb5
-rw-r--r--meta-openstack/recipes-devtools/python/python-keystone_2013.1.3.bb4
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova_2013.1.3.bb13
-rw-r--r--meta-openstack/recipes-devtools/python/python-quantum_2013.1.3.bb5
-rw-r--r--meta-openstack/recipes-support/postgresql/postgresql/postgresql-init46
-rw-r--r--meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend46
9 files changed, 76 insertions, 58 deletions
diff --git a/meta-openstack-qemu/recipes-devtools/python/python-nova-controller_2013.1.3.bbappend b/meta-openstack-qemu/recipes-devtools/python/python-nova-controller_2013.1.3.bbappend
deleted file mode 100644
index f45a02b..0000000
--- a/meta-openstack-qemu/recipes-devtools/python/python-nova-controller_2013.1.3.bbappend
+++ /dev/null
@@ -1,11 +0,0 @@
-do_install_append() {
- if [ ! -f "${WORKDIR}/nova.conf" ]; then
- return
- fi
-
- TEMPLATE_CONF_DIR=${S}${sysconfdir}/${SRCNAME}
- NOVA_CONF_DIR=${D}/${sysconfdir}/nova
-
- sed -e "s:^libvirt_type.*=.*$:libvirt_type = qemu:" \
- -i ${NOVA_CONF_DIR}/nova.conf
-} \ No newline at end of file
diff --git a/meta-openstack-qemu/recipes-devtools/python/python-nova-compute_2013.1.3.bbappend b/meta-openstack-qemu/recipes-devtools/python/python-nova_2013.1.3.bbappend
index 45f4307..45f4307 100644
--- a/meta-openstack-qemu/recipes-devtools/python/python-nova-compute_2013.1.3.bbappend
+++ b/meta-openstack-qemu/recipes-devtools/python/python-nova_2013.1.3.bbappend
diff --git a/meta-openstack/recipes-devtools/python/python-cinder_2013.1.3.bb b/meta-openstack/recipes-devtools/python/python-cinder_2013.1.3.bb
index 1cdcd98..a6a10e5 100644
--- a/meta-openstack/recipes-devtools/python/python-cinder_2013.1.3.bb
+++ b/meta-openstack/recipes-devtools/python/python-cinder_2013.1.3.bb
@@ -57,10 +57,8 @@ pkg_postinst_${SRCNAME} () {
# This is to make sure postgres is configured and running
if ! pidof postmaster > /dev/null; then
- sudo -u postgres initdb -D /etc/postgresql/
+ /etc/init.d/postgresql-init
/etc/init.d/postgresql start
- sleep 0.2
- sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'"
fi
sudo -u postgres createdb cinder
diff --git a/meta-openstack/recipes-devtools/python/python-glance_2013.1.3.bb b/meta-openstack/recipes-devtools/python/python-glance_2013.1.3.bb
index 9bfd262..ff81a0c 100644
--- a/meta-openstack/recipes-devtools/python/python-glance_2013.1.3.bb
+++ b/meta-openstack/recipes-devtools/python/python-glance_2013.1.3.bb
@@ -65,10 +65,9 @@ pkg_postinst_${SRCNAME} () {
# This is to make sure postgres is configured and running
if ! pidof postmaster > /dev/null; then
- sudo -u postgres initdb -D /etc/postgresql/
+ /etc/init.d/postgresql-init
/etc/init.d/postgresql start
- sleep 0.2
- sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'"
+ sleep 5
fi
mkdir /var/log/glance
diff --git a/meta-openstack/recipes-devtools/python/python-keystone_2013.1.3.bb b/meta-openstack/recipes-devtools/python/python-keystone_2013.1.3.bb
index e124583..387fa68 100644
--- a/meta-openstack/recipes-devtools/python/python-keystone_2013.1.3.bb
+++ b/meta-openstack/recipes-devtools/python/python-keystone_2013.1.3.bb
@@ -58,11 +58,9 @@ pkg_postinst_${SRCNAME} () {
# This is to make sure postgres is configured and running
if ! pidof postmaster > /dev/null; then
- sudo -u postgres initdb -D /etc/postgresql/
- sleep 10
+ /etc/init.d/postgresql-init
/etc/init.d/postgresql start
sleep 5
- sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'"
fi
sudo -u postgres createdb keystone
diff --git a/meta-openstack/recipes-devtools/python/python-nova_2013.1.3.bb b/meta-openstack/recipes-devtools/python/python-nova_2013.1.3.bb
index c2dd1f3..3552592 100644
--- a/meta-openstack/recipes-devtools/python/python-nova_2013.1.3.bb
+++ b/meta-openstack/recipes-devtools/python/python-nova_2013.1.3.bb
@@ -16,6 +16,7 @@ SRC_URI = "https://launchpad.net/${SRCNAME}/grizzly/${PV}/+download/${SRCNAME}-$
"
SRC_URI += "file://nova-all \
+ file://nova-compute \
file://nova-consoleauth \
file://nova-novncproxy \
file://nova.conf \
@@ -93,6 +94,7 @@ do_install_append() {
if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/nova-all ${D}${sysconfdir}/init.d/nova-all
+ install -m 0755 ${WORKDIR}/nova-compute ${D}${sysconfdir}/init.d/nova-compute
install -m 0755 ${WORKDIR}/nova-consoleauth ${D}${sysconfdir}/init.d/nova-consoleauth
install -m 0755 ${WORKDIR}/nova-novncproxy ${D}${sysconfdir}/init.d/nova-novncproxy
fi
@@ -197,14 +199,15 @@ RDEPENDS_${SRCNAME}-common = "${PN} openssl openssl-misc libxml2 libxslt \
iptables curl dnsmasq sudo procps"
RDEPENDS_${SRCNAME}-controller = "${PN} ${SRCNAME}-common \
- ${SRCNAME}-consoleauth \
- ${SRCNAME}-novncproxy \
- postgresql postgresql-client python-psycopg2"
+ ${SRCNAME}-consoleauth \
+ ${SRCNAME}-novncproxy \
+ postgresql postgresql-client python-psycopg2"
RDEPENDS_${SRCNAME}-compute = "${PN} ${SRCNAME}-common \
- qemu libvirt libvirt-libvirtd libvirt-python libvirt-virsh"
+ qemu libvirt libvirt-libvirtd libvirt-python libvirt-virsh"
-INITSCRIPT_PACKAGES = "${SRCNAME}-controller ${SRCNAME}-consoleauth ${SRCNAME}-novncproxy"
+INITSCRIPT_PACKAGES = "${SRCNAME}-compute ${SRCNAME}-controller ${SRCNAME}-consoleauth ${SRCNAME}-novncproxy"
INITSCRIPT_NAME_${SRCNAME}-controller = "nova-all"
+INITSCRIPT_NAME_${SRCNAME}-compute = "nova-compute"
INITSCRIPT_NAME_${SRCNAME}-consoleauth = "nova-consoleauth"
INITSCRIPT_NAME_${SRCNAME}-novncproxy = "nova-novncproxy"
diff --git a/meta-openstack/recipes-devtools/python/python-quantum_2013.1.3.bb b/meta-openstack/recipes-devtools/python/python-quantum_2013.1.3.bb
index 34da3c9..8198e6a 100644
--- a/meta-openstack/recipes-devtools/python/python-quantum_2013.1.3.bb
+++ b/meta-openstack/recipes-devtools/python/python-quantum_2013.1.3.bb
@@ -74,10 +74,9 @@ pkg_postinst_${SRCNAME} () {
# This is to make sure postgres is configured and running
if ! pidof postmaster > /dev/null; then
- sudo -u postgres initdb -D /etc/postgresql/
+ /etc/init.d/postgresql-init
/etc/init.d/postgresql start
- sleep 0.2
- sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'"
+ sleep 5
fi
sudo -u postgres createdb ovs_quantum
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init b/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
new file mode 100644
index 0000000..d9850da
--- /dev/null
+++ b/meta-openstack/recipes-support/postgresql/postgresql/postgresql-init
@@ -0,0 +1,46 @@
+#!/bin/sh
+# set -x
+
+PN=postgresql
+CONTROLLER_IP=%CONTROLLER_IP%
+COMPUTE_IP=%COMPUTE_IP%
+DB_USER=%DB_USER%
+DB_PASSWORD=%DB_PASSWORD%
+
+if [ -e /etc/${PN}/PG_VERSION ]; then
+ # the database has already been initialized, return
+ exit 0
+fi
+
+sudo -u postgres initdb -D /etc/${PN}/
+sleep 2
+echo "listen_addresses = '*'" >> /etc/${PN}/postgresql.conf
+echo "host all all ${CONTROLLER_IP}/32 trust" >> /etc/${PN}/pg_hba.conf
+echo "host all all ${COMPUTE_IP}/32 trust" >> /etc/${PN}/pg_hba.conf
+sleep 2
+/etc/init.d/postgresql start
+sleep 10
+
+count=0
+done=0
+while [ $count -le 10 ] && [ $done -eq 0 ]; do
+ sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'" 2> /dev/null
+ if [ $? -ne 0 ]; then
+ echo "[INFO] postgres: failed to create account for ${DB_USER}, trying again"
+ /etc/init.d/postgresql stop
+ sleep 3
+ /etc/init.d/postgresql start
+ sleep 3
+ else
+ echo "[INFO] postgres: created account for ${DB_USER}, continuing .. "
+ done=1
+ fi
+ count=`expr $count + 1`
+done
+
+if [ $done -eq 0 ]; then
+ echo "[ERROR] postgres: unable to create admin account"
+ exit 1
+fi
+
+ln -s /usr/share/zoneinfo /usr/share/postgresql/timezone
diff --git a/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend b/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend
index 7c28fa1..3174e94 100644
--- a/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend
+++ b/meta-openstack/recipes-support/postgresql/postgresql_9.2.4.bbappend
@@ -1,7 +1,8 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
PRINC := "${@int(PRINC) + 1}"
-SRC_URI += "file://postgresql"
+SRC_URI += "file://postgresql \
+ file://postgresql-init"
inherit useradd update-rc.d identity hosts
@@ -11,6 +12,18 @@ do_install_append() {
install -d ${D}${sysconfdir}/init.d/
install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql
+
+ sed -e "s:%DB_USER%:${DB_USER}:g" -i ${WORKDIR}/postgresql-init
+ sed -e "s:%DB_PASSWORD%:${DB_PASSWORD}:g" -i ${WORKDIR}/postgresql-init
+
+ sed -e "s:%CONTROLLER_IP%:${CONTROLLER_IP}:g" -i ${WORKDIR}/postgresql-init
+ sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${WORKDIR}/postgresql-init
+
+ sed -e "s:%COMPUTE_IP%:${COMPUTE_IP}:g" -i ${WORKDIR}/postgresql-init
+ sed -e "s:%COMPUTE_HOST%:${COMPUTE_HOST}:g" -i ${WORKDIR}/postgresql-init
+
+ install -m 0755 ${WORKDIR}/postgresql-init ${D}${sysconfdir}/init.d/postgresql-init
+
}
USERADD_PACKAGES = "${PN}"
@@ -24,38 +37,11 @@ pkg_postinst_${PN} () {
exit 1
fi
- sudo -u postgres initdb -D /etc/${PN}/
- sleep 2
- echo "listen_addresses = '*'" >> /etc/${PN}/postgresql.conf
- echo "host all all ${CONTROLLER_IP}/32 trust" >> /etc/${PN}/pg_hba.conf
- echo "host all all ${COMPUTE_IP}/32 trust" >> /etc/${PN}/pg_hba.conf
- sleep 2
- /etc/init.d/postgresql start
- sleep 5
-
- count=0
- done=0
- while [ $count -le 10 ] && [ $done -eq 0 ]; do
- sudo -u postgres psql -c "CREATE ROLE ${DB_USER} WITH SUPERUSER LOGIN PASSWORD '${DB_PASSWORD}'" 2> /dev/null
- if [ $? -ne 0 ]; then
- echo "[INFO] postgres: failed to create account for ${DB_USER}, trying again"
- /etc/init.d/postgresql stop
- sleep 2
- /etc/init.d/postgresql start
- sleep 1
- else
- done=1
- fi
- count=`expr $count + 1`
- done
-
- if [ $done -eq 0 ]; then
+ /etc/init.d/postgresql-init
+ if [ $? -eq 0 ]; then
echo "[ERROR] postgres: unable to create admin account"
exit 1
fi
-
- ln -s /usr/share/zoneinfo /usr/share/postgresql/timezone
- # end postgres 9.2.4 postinst
}
FILES_${PN} += "${localstatedir}/run/${PN}"