Skip to contentSkip to conversation

python-*: fixup postinst scripts

PATCH In review Mark Asselstine 3 participants 7 messages Nov 15, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 python-*: fixup postinst scripts

Checking for "$D" and doing an "exit 1" now results in errors such as:

[log_check] warning: %post(keystone-cronjobs-...) scriptlet failed, exit status 2

during image creation. Instead of escaping the script for "level-1" (image creation postinst) we wrap the "level-2" (first boot) postinst in an if statement. This also ensure the scriptlet in indentity.bbclass is less prone to behaving differently based on the postinsts defined in the classes which inherit 'identity'.

---
 meta-openstack/classes/identity.bbclass            | 11 +++--
 .../recipes-devtools/python/python-barbican_git.bb |  8 ++--
 .../python/python-ceilometer_git.bb                | 24 +++++------
 .../recipes-devtools/python/python-cinder_git.bb   | 48 ++++++++++-----------
 .../recipes-devtools/python/python-glance_git.bb   | 24 +++++------
 .../recipes-devtools/python/python-heat_git.bb     | 24 +++++------
 .../recipes-devtools/python/python-keystone_git.bb | 50 +++++++++++-----------
 .../recipes-devtools/python/python-neutron_git.bb  | 32 ++++++--------
 .../recipes-devtools/python/python-nova_git.bb     | 42 ++++++++----------
 .../recipes-devtools/python/python-rally_git.bb    | 28 ++++++------
 .../recipes-devtools/python/python-swift_git.bb    | 40 ++++++++---------
 .../recipes-devtools/python/python-trove_git.bb    | 45 ++++++++++---------
 .../postgresql/postgresql_9.%.bbappend             | 14 +++---
 13 files changed, 185 insertions(+), 205 deletions(-)
meta-openstack/classes/identity.bbclass +8 -3
index c4b1394..1f4f408 100644
@@ -163,9 +163,11 @@ python populate_packages_append () {
 
         postinst = d.getVar('pkg_postinst_%s' % pkg, True) or d.getVar('pkg_postinst', True)
         if not postinst:
-            postinst = '    if [ "x$D" != "x" ]; then\n' + \
-                       '        exit 1\n' + \
-                       '    fi\n'
+            postinst = ''
+
+        # Only execute on target. Header.
+        postinst += '    if [ -z "$D" ]; then\n'
+
         postinst += servicecreate_postinst_common_copy
 
         if d.getVar('USERCREATE_PARAM_%s' % pkg, True):
@@ -176,6 +178,9 @@ python populate_packages_append () {
             servicecreate_postinst_service = servicecreate_postinst_service_copy.replace("SERVICECREATE_PARAM", servicecreate_param(d, pkg))
             postinst += servicecreate_postinst_service
 
+        # Footer.
+        postinst += '    fi\n'
+
         d.setVar('pkg_postinst_%s' % pkg, postinst)
         bb.debug(1, 'pkg_postinst_%s = %s' % (pkg, d.getVar('pkg_postinst_%s' % pkg, True)))
 }
meta-openstack/recipes-devtools/python/python-barbican_git.bb +3 -5
index 0b3d768..579413c 100644
@@ -85,12 +85,10 @@ FILES_${SRCNAME} = "${sysconfdir}/${SRCNAME}/* \
 
 ALLOW_EMPTY_${SRCNAME}-setup = "1"
 pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+        chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
+        chown -R barbican:barbican ${localstatedir}/lib/barbican
     fi
-
-    chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
-    chown -R barbican:barbican ${localstatedir}/lib/barbican
 }
 
 DEPENDS += " \
meta-openstack/recipes-devtools/python/python-ceilometer_git.bb +11 -13
index 5645626..4b01022 100644
@@ -108,20 +108,18 @@ do_install_append() {
 }
 
 pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+        # This is to make sure postgres is configured and running
+        if ! pidof postmaster > /dev/null; then
+           /etc/init.d/postgresql-init
+           /etc/init.d/postgresql start
+           sleep 2
+        fi
+
+        mkdir /var/log/ceilometer
+        sudo -u postgres createdb ceilometer
+        ceilometer-dbsync
     fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 2
-    fi
-    
-    mkdir /var/log/ceilometer
-    sudo -u postgres createdb ceilometer
-    ceilometer-dbsync
 }
 
 inherit setuptools identity hosts update-rc.d default_configs monitor
meta-openstack/recipes-devtools/python/python-cinder_git.bb +23 -25

54 lines not on this page · raw message

meta-openstack/recipes-devtools/python/python-glance_git.bb +11 -13
index 27c33b9..4042f1b 100644
@@ -122,20 +122,18 @@ do_install_append() {
 }
 
 pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 5
+	fi
+
+	mkdir /var/log/glance
+	sudo -u postgres createdb glance
+	glance-manage db_sync
     fi
-    
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 5
-    fi
-    
-    mkdir /var/log/glance
-    sudo -u postgres createdb glance
-    glance-manage db_sync
 }
 
 PACKAGES += " ${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup ${SRCNAME}-api ${SRCNAME}-registry"
meta-openstack/recipes-devtools/python/python-heat_git.bb +11 -13
index cccaf0a..2cf7ce4 100644
@@ -107,20 +107,18 @@ do_install_append() {
 }
 
 pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 2
+	fi
+
+	mkdir /var/log/heat
+	sudo -u postgres createdb heat
+	heat-manage db_sync
     fi
-    
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 2
-    fi
-    
-    mkdir /var/log/heat
-    sudo -u postgres createdb heat
-    heat-manage db_sync
 }
 
 inherit setuptools identity hosts update-rc.d default_configs monitor
meta-openstack/recipes-devtools/python/python-keystone_git.bb +25 -25

62 lines not on this page · raw message

meta-openstack/recipes-devtools/python/python-neutron_git.bb +14 -18
index 51c2ac4..c837401 100644
@@ -138,29 +138,25 @@ do_install_append() {
 }
 
 pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	    /etc/init.d/postgresql-init
+	    /etc/init.d/postgresql start
+	    sleep 2
+	fi
+
+	sudo -u postgres createdb neutron
+	sudo neutron-db-manage --config-file /etc/neutron/neutron.conf  \
+			       --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head
     fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-        /etc/init.d/postgresql-init
-        /etc/init.d/postgresql start
-        sleep 2
-    fi
-
-    sudo -u postgres createdb neutron
-    sudo neutron-db-manage --config-file /etc/neutron/neutron.conf  \
-                           --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head
 }
 
 pkg_postinst_${SRCNAME}-plugin-openvswitch-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	/etc/init.d/openvswitch-switch start
+	ovs-vsctl --no-wait -- --may-exist add-br br-int
     fi
-   
-    /etc/init.d/openvswitch-switch start
-    ovs-vsctl --no-wait -- --may-exist add-br br-int
 }
 
 ALLOW_EMPTY_${SRCNAME}-setup = "1"
meta-openstack/recipes-devtools/python/python-nova_git.bb +19 -23

52 lines not on this page · raw message

meta-openstack/recipes-devtools/python/python-rally_git.bb +13 -15
index d29e7cb..31d4242 100644
@@ -63,22 +63,20 @@ do_install_append() {
 }
 
 pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	fi
+
+	if [ ! -d /var/log/rally ]; then
+	   mkdir /var/log/rally
+	fi
+
+	sudo -u postgres createdb rally
+	rally-manage db recreate
     fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-    fi
-
-    if [ ! -d /var/log/rally ]; then
-       mkdir /var/log/rally
-    fi
-
-    sudo -u postgres createdb rally
-    rally-manage db recreate
 }
 
 PACKAGES += "${SRCNAME}-tests ${SRCNAME}-api ${SRCNAME} ${SRCNAME}-setup"
meta-openstack/recipes-devtools/python/python-swift_git.bb +19 -21
index 8552ea7..fc7c258 100644
@@ -109,28 +109,26 @@ do_install_append() {
 }
 
 pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "x$D" ]; then
+	CLUSTER_CONF=/etc/swift/cluster.conf
+	SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh'
+
+	for i in `seq 1 3`; do
+	    BACKING_FILE=/etc/swift/swift_backing_$i
+	    if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then
+		truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE
+		sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i $CLUSTER_CONF
+	    else
+		sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF
+	    fi
+	done
+
+	$SWIFT_SETUP createrings
+	$SWIFT_SETUP formatdevs
+	$SWIFT_SETUP mountdevs
+	$SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs
+	$SWIFT_SETUP unmountdevs
     fi
-
-    CLUSTER_CONF=/etc/swift/cluster.conf
-    SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh'
-
-    for i in `seq 1 3`; do
-        BACKING_FILE=/etc/swift/swift_backing_$i
-        if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then
-            truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE
-            sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i $CLUSTER_CONF
-        else
-            sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF
-        fi
-    done
-
-    $SWIFT_SETUP createrings
-    $SWIFT_SETUP formatdevs
-    $SWIFT_SETUP mountdevs
-    $SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs
-    $SWIFT_SETUP unmountdevs
 }
 
 PACKAGES += "${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup"
meta-openstack/recipes-devtools/python/python-trove_git.bb +22 -23

52 lines not on this page · raw message

meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend +6 -8
index 22dae71..b26054e 100644
@@ -41,14 +41,12 @@ ALLOW_EMPTY_${PN}-setup = "1"
 
 pkg_postinst_${PN}-setup () {
     # postgres 9.2.4 postinst
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-      
-    /etc/init.d/postgresql-init
-    if [ $? -ne 0 ]; then
-        echo "[ERROR] postgres: unable to create admin account"
-        exit 1
+    if [ -z "$D" ]; then
+	/etc/init.d/postgresql-init
+	if [ $? -ne 0 ]; then
+	    echo "[ERROR] postgres: unable to create admin account"
+	    exit 1
+	fi
     fi
 }
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 9 lines · Mark Asselstine

Checking for "$D" and doing an "exit 1" now results in errors such as:

[log_check] warning: %post(keystone-cronjobs-...) scriptlet failed, exit status 2

during image creation. Instead of escaping the script for "level-1" (image creation postinst) we wrap the "level-2" (first boot) postinst in an if statement. This also ensure the scriptlet in indentity.bbclass is less prone to behaving differently based on the postinsts defined in the classes which inherit 'identity'.

merged.

Bruce

Quoted 582 lines
---
  meta-openstack/classes/identity.bbclass            | 11 +++--
  .../recipes-devtools/python/python-barbican_git.bb |  8 ++--
  .../python/python-ceilometer_git.bb                | 24 +++++------
  .../recipes-devtools/python/python-cinder_git.bb   | 48 ++++++++++-----------
  .../recipes-devtools/python/python-glance_git.bb   | 24 +++++------
  .../recipes-devtools/python/python-heat_git.bb     | 24 +++++------
  .../recipes-devtools/python/python-keystone_git.bb | 50 +++++++++++-----------
  .../recipes-devtools/python/python-neutron_git.bb  | 32 ++++++--------
  .../recipes-devtools/python/python-nova_git.bb     | 42 ++++++++----------
  .../recipes-devtools/python/python-rally_git.bb    | 28 ++++++------
  .../recipes-devtools/python/python-swift_git.bb    | 40 ++++++++---------
  .../recipes-devtools/python/python-trove_git.bb    | 45 ++++++++++---------
  .../postgresql/postgresql_9.%.bbappend             | 14 +++---
  13 files changed, 185 insertions(+), 205 deletions(-)
meta-openstack/classes/identity.bbclass +8 -3
index c4b1394..1f4f408 100644
@@ -163,9 +163,11 @@ python populate_packages_append () {
 
          postinst = d.getVar('pkg_postinst_%s' % pkg, True) or d.getVar('pkg_postinst', True)
          if not postinst:
-            postinst = '    if [ "x$D" != "x" ]; then\n' + \
-                       '        exit 1\n' + \
-                       '    fi\n'
+            postinst = ''
+
+        # Only execute on target. Header.
+        postinst += '    if [ -z "$D" ]; then\n'
+
          postinst += servicecreate_postinst_common_copy
 
          if d.getVar('USERCREATE_PARAM_%s' % pkg, True):
@@ -176,6 +178,9 @@ python populate_packages_append () {
              servicecreate_postinst_service = servicecreate_postinst_service_copy.replace("SERVICECREATE_PARAM", servicecreate_param(d, pkg))
              postinst += servicecreate_postinst_service
 
+        # Footer.
+        postinst += '    fi\n'
+
          d.setVar('pkg_postinst_%s' % pkg, postinst)
          bb.debug(1, 'pkg_postinst_%s = %s' % (pkg, d.getVar('pkg_postinst_%s' % pkg, True)))
  }
meta-openstack/recipes-devtools/python/python-barbican_git.bb +3 -5
index 0b3d768..579413c 100644
@@ -85,12 +85,10 @@ FILES_${SRCNAME} = "${sysconfdir}/${SRCNAME}/* \
 
  ALLOW_EMPTY_${SRCNAME}-setup = "1"
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+        chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
+        chown -R barbican:barbican ${localstatedir}/lib/barbican
      fi
-
-    chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
-    chown -R barbican:barbican ${localstatedir}/lib/barbican
  }
 
  DEPENDS += " \
meta-openstack/recipes-devtools/python/python-ceilometer_git.bb +11 -13
index 5645626..4b01022 100644
@@ -108,20 +108,18 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+        # This is to make sure postgres is configured and running
+        if ! pidof postmaster > /dev/null; then
+           /etc/init.d/postgresql-init
+           /etc/init.d/postgresql start
+           sleep 2
+        fi
+
+        mkdir /var/log/ceilometer
+        sudo -u postgres createdb ceilometer
+        ceilometer-dbsync
      fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 2
-    fi
-
-    mkdir /var/log/ceilometer
-    sudo -u postgres createdb ceilometer
-    ceilometer-dbsync
  }
 
  inherit setuptools identity hosts update-rc.d default_configs monitor
meta-openstack/recipes-devtools/python/python-cinder_git.bb +23 -25
index e70a3aa..9f70beb 100644
@@ -124,31 +124,29 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-    fi
-
-    if [ ! -d /var/log/cinder ]; then
-       mkdir /var/log/cinder
-    fi
-
-    sudo -u postgres createdb cinder
-    cinder-manage db sync
-
-    # Create Cinder nfs_share config file with default nfs server
-    if [ ! -f /etc/cinder/nfs_shares ]; then
-        /bin/bash /etc/cinder/drivers/nfs_setup.sh
-    fi
-
-    # Create Cinder glusterfs_share config file with default glusterfs server
-    if [ ! -f /etc/cinder/glusterfs_shares ] && [ -f /usr/sbin/glusterfsd ]; then
-        /bin/bash /etc/cinder/drivers/glusterfs_setup.sh
+    if [ -z "$D" ]; then
+	 # This is to make sure postgres is configured and running
+	 if ! pidof postmaster > /dev/null; then
+	    /etc/init.d/postgresql-init
+	    /etc/init.d/postgresql start
+	 fi
+
+	 if [ ! -d /var/log/cinder ]; then
+	    mkdir /var/log/cinder
+	 fi
+
+	 sudo -u postgres createdb cinder
+	 cinder-manage db sync
+
+	 # Create Cinder nfs_share config file with default nfs server
+	 if [ ! -f /etc/cinder/nfs_shares ]; then
+	     /bin/bash /etc/cinder/drivers/nfs_setup.sh
+	 fi
+
+	 # Create Cinder glusterfs_share config file with default glusterfs server
+	 if [ ! -f /etc/cinder/glusterfs_shares ] && [ -f /usr/sbin/glusterfsd ]; then
+	     /bin/bash /etc/cinder/drivers/glusterfs_setup.sh
+	 fi
      fi
  }
 
meta-openstack/recipes-devtools/python/python-glance_git.bb +11 -13
index 27c33b9..4042f1b 100644
@@ -122,20 +122,18 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 5
+	fi
+
+	mkdir /var/log/glance
+	sudo -u postgres createdb glance
+	glance-manage db_sync
      fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 5
-    fi
-
-    mkdir /var/log/glance
-    sudo -u postgres createdb glance
-    glance-manage db_sync
  }
 
  PACKAGES += " ${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup ${SRCNAME}-api ${SRCNAME}-registry"
meta-openstack/recipes-devtools/python/python-heat_git.bb +11 -13
index cccaf0a..2cf7ce4 100644
@@ -107,20 +107,18 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 2
+	fi
+
+	mkdir /var/log/heat
+	sudo -u postgres createdb heat
+	heat-manage db_sync
      fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 2
-    fi
-
-    mkdir /var/log/heat
-    sudo -u postgres createdb heat
-    heat-manage db_sync
  }
 
  inherit setuptools identity hosts update-rc.d default_configs monitor
meta-openstack/recipes-devtools/python/python-keystone_git.bb +25 -25
index 79bd0c8..a26c9bf 100644
@@ -189,28 +189,26 @@ role_tree_dn = ou=Roles,${LDAP_DN} \
 
  pkg_postinst_${SRCNAME}-setup () {
      # python-keystone postinst start
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-        /etc/init.d/postgresql-init
-        /etc/init.d/postgresql start
-        sleep 2
-    fi
-
-    # This is to make sure keystone is configured and running
-    PIDFILE="/var/run/keystone-all.pid"
-    if [ -z `cat $PIDFILE 2>/dev/null` ]; then
-        sudo -u postgres createdb keystone
-        keystone-manage db_sync
-        keystone-manage pki_setup --keystone-user=root --keystone-group=daemon
-
-        if ${@bb.utils.contains('DISTRO_FEATURES', 'OpenLDAP', 'true', 'false', d)}; then
-            /etc/init.d/openldap start
-        fi
-        /etc/init.d/keystone start
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	    /etc/init.d/postgresql-init
+	    /etc/init.d/postgresql start
+	    sleep 2
+	fi
+
+	# This is to make sure keystone is configured and running
+	PIDFILE="/var/run/keystone-all.pid"
+	if [ -z `cat $PIDFILE 2>/dev/null` ]; then
+	    sudo -u postgres createdb keystone
+	    keystone-manage db_sync
+	    keystone-manage pki_setup --keystone-user=root --keystone-group=daemon
+
+	    if ${@bb.utils.contains('DISTRO_FEATURES', 'OpenLDAP', 'true', 'false', d)}; then
+		/etc/init.d/openldap start
+	    fi
+	    /etc/init.d/keystone start
+	fi
      fi
  }
 
@@ -219,9 +217,11 @@ pkg_postinst_${SRCNAME}-setup () {
  KEYSTONE_TOKEN_FLUSH_TIME ??= "0 0 */2 * *"
 
  pkg_postinst_${SRCNAME}-cronjobs () {
-    # By default keystone expired tokens are not automatic removed out of the
-    # database.  So we create a cronjob for cleaning these expired tokens.
-    echo "${KEYSTONE_TOKEN_FLUSH_TIME} root /usr/bin/keystone-manage token_flush" >> /etc/crontab
+    if [ -z "$D" ]; then
+	# By default keystone expired tokens are not automatic removed out of the
+	# database.  So we create a cronjob for cleaning these expired tokens.
+	echo "${KEYSTONE_TOKEN_FLUSH_TIME} root /usr/bin/keystone-manage token_flush" >> /etc/crontab
+    fi
  }
 
  PACKAGES += " ${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup ${SRCNAME}-cronjobs"
meta-openstack/recipes-devtools/python/python-neutron_git.bb +14 -18
index 51c2ac4..c837401 100644
@@ -138,29 +138,25 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	    /etc/init.d/postgresql-init
+	    /etc/init.d/postgresql start
+	    sleep 2
+	fi
+
+	sudo -u postgres createdb neutron
+	sudo neutron-db-manage --config-file /etc/neutron/neutron.conf  \
+			       --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head
      fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-        /etc/init.d/postgresql-init
-        /etc/init.d/postgresql start
-        sleep 2
-    fi
-
-    sudo -u postgres createdb neutron
-    sudo neutron-db-manage --config-file /etc/neutron/neutron.conf  \
-                           --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head
  }
 
  pkg_postinst_${SRCNAME}-plugin-openvswitch-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	/etc/init.d/openvswitch-switch start
+	ovs-vsctl --no-wait -- --may-exist add-br br-int
      fi
-
-    /etc/init.d/openvswitch-switch start
-    ovs-vsctl --no-wait -- --may-exist add-br br-int
  }
 
  ALLOW_EMPTY_${SRCNAME}-setup = "1"
meta-openstack/recipes-devtools/python/python-nova_git.bb +19 -23
index f3a6b86..7b560a7 100644
@@ -160,33 +160,29 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 5
+	fi
+
+	sudo -u postgres createdb nova
+	sleep 2
+	nova-manage db sync
      fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 5
-    fi
-
-    sudo -u postgres createdb nova
-    sleep 2
-    nova-manage db sync
  }
 
  pkg_postinst_${SRCNAME}-common () {
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    if [ -d  /home/root ]; then
-        echo "source /etc/nova/openrc" >> /home/root/.bashrc
-	echo "source /etc/nova/openrc" >> /home/root/.profile
-    else
-        echo "source /etc/nova/openrc" >> /root/.bashrc
-	echo "source /etc/nova/openrc" >> /root/.profile
+    if [ -z "$D" ]; then
+	if [ -d  /home/root ]; then
+	    echo "source /etc/nova/openrc" >> /home/root/.bashrc
+	    echo "source /etc/nova/openrc" >> /home/root/.profile
+	else
+	    echo "source /etc/nova/openrc" >> /root/.bashrc
+	    echo "source /etc/nova/openrc" >> /root/.profile
+	fi
      fi
  }
 
meta-openstack/recipes-devtools/python/python-rally_git.bb +13 -15
index d29e7cb..31d4242 100644
@@ -63,22 +63,20 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	fi
+
+	if [ ! -d /var/log/rally ]; then
+	   mkdir /var/log/rally
+	fi
+
+	sudo -u postgres createdb rally
+	rally-manage db recreate
      fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-    fi
-
-    if [ ! -d /var/log/rally ]; then
-       mkdir /var/log/rally
-    fi
-
-    sudo -u postgres createdb rally
-    rally-manage db recreate
  }
 
  PACKAGES += "${SRCNAME}-tests ${SRCNAME}-api ${SRCNAME} ${SRCNAME}-setup"
meta-openstack/recipes-devtools/python/python-swift_git.bb +19 -21
index 8552ea7..fc7c258 100644
@@ -109,28 +109,26 @@ do_install_append() {
  }
 
  pkg_postinst_${SRCNAME}-setup () {
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "x$D" ]; then
+	CLUSTER_CONF=/etc/swift/cluster.conf
+	SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh'
+
+	for i in `seq 1 3`; do
+	    BACKING_FILE=/etc/swift/swift_backing_$i
+	    if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then
+		truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE
+		sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i $CLUSTER_CONF
+	    else
+		sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF
+	    fi
+	done
+
+	$SWIFT_SETUP createrings
+	$SWIFT_SETUP formatdevs
+	$SWIFT_SETUP mountdevs
+	$SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs
+	$SWIFT_SETUP unmountdevs
      fi
-
-    CLUSTER_CONF=/etc/swift/cluster.conf
-    SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh'
-
-    for i in `seq 1 3`; do
-        BACKING_FILE=/etc/swift/swift_backing_$i
-        if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then
-            truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE
-            sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i $CLUSTER_CONF
-        else
-            sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF
-        fi
-    done
-
-    $SWIFT_SETUP createrings
-    $SWIFT_SETUP formatdevs
-    $SWIFT_SETUP mountdevs
-    $SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs
-    $SWIFT_SETUP unmountdevs
  }
 
  PACKAGES += "${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup"
meta-openstack/recipes-devtools/python/python-trove_git.bb +22 -23
index 830da92..b90e552 100755
@@ -146,30 +146,29 @@ do_install_append() {
 
  pkg_postinst_${SRCNAME}-setup () {
      # python-trove-setup postinst start
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	source /etc/nova/openrc
+
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 5
+	fi
+
+	mkdir /var/log/trove
+	# Create database for trove.
+	sudo -u postgres createdb trove
+
+	# Create default trove database.
+	trove-manage db_sync
+	# Create new datastore.
+	trove-manage datastore_update "postgresql" ""
+	# Set up new version
+	trove-manage datastore_version_update "postgresql" "9.1" "postgresql" 1 "postgresql-server-9.1" 1
+	# Set new default version.
+	trove-manage datastore_update "postgresql" "9.1"
      fi
-    source /etc/nova/openrc
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 5
-    fi
-
-    mkdir /var/log/trove
-    # Create database for trove.
-    sudo -u postgres createdb trove
-
-    # Create default trove database.
-    trove-manage db_sync
-    # Create new datastore.
-    trove-manage datastore_update "postgresql" ""
-    # Set up new version
-    trove-manage datastore_version_update "postgresql" "9.1" "postgresql" 1 "postgresql-server-9.1" 1
-    # Set new default version.
-    trove-manage datastore_update "postgresql" "9.1"
  }
 
 
meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend +6 -8
index 22dae71..b26054e 100644
@@ -41,14 +41,12 @@ ALLOW_EMPTY_${PN}-setup = "1"
 
  pkg_postinst_${PN}-setup () {
      # postgres 9.2.4 postinst
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    /etc/init.d/postgresql-init
-    if [ $? -ne 0 ]; then
-        echo "[ERROR] postgres: unable to create admin account"
-        exit 1
+    if [ -z "$D" ]; then
+	/etc/init.d/postgresql-init
+	if [ $? -ne 0 ]; then
+	    echo "[ERROR] postgres: unable to create admin account"
+	    exit 1
+	fi
      fi
  }
 
#2 lore raw
Quoted 6 lines · EST Bruce Ashfield
Quoted 5 lines · Mark Asselstine

Checking for "$D" and doing an "exit 1" now results in errors such as:

[log_check] warning: %post(keystone-cronjobs-...) scriptlet failed, exit status 2

Quoted 7 lines
Quoted 5 lines

during image creation. Instead of escaping the script for "level-1" (image creation postinst) we wrap the "level-2" (first boot) postinst in an if statement. This also ensure the scriptlet in indentity.bbclass is less prone to behaving differently based on the postinsts defined in the classes which inherit 'identity'.

merged.

I am reading my email in reverse. So you will see my note about not merging this one after the nudge from Richard. No matter I will use this as the new baseline. Nobody can use this stuff currently so no harm in this merge.

Mark

Quoted 346 lines

Bruce

Quoted 343 lines

---

  meta-openstack/classes/identity.bbclass            | 11 +++--
  .../recipes-devtools/python/python-barbican_git.bb |  8 ++--
  .../python/python-ceilometer_git.bb                | 24 +++++------
  .../recipes-devtools/python/python-cinder_git.bb   | 48
  ++++++++++----------- .../recipes-devtools/python/python-glance_git.bb 
   | 24 +++++------ .../recipes-devtools/python/python-heat_git.bb     |
  24 +++++------ .../recipes-devtools/python/python-keystone_git.bb | 50
  +++++++++++-----------
  .../recipes-devtools/python/python-neutron_git.bb  | 32 ++++++--------
  .../recipes-devtools/python/python-nova_git.bb     | 42
  ++++++++---------- .../recipes-devtools/python/python-rally_git.bb    |
  28 ++++++------ .../recipes-devtools/python/python-swift_git.bb    | 40
  ++++++++--------- .../recipes-devtools/python/python-trove_git.bb    |
  45 ++++++++++--------- .../postgresql/postgresql_9.%.bbappend          
    | 14 +++---
  13 files changed, 185 insertions(+), 205 deletions(-)
(quoted diff) +0 -0

b/meta-openstack/classes/identity.bbclass index c4b1394..1f4f408 100644

meta-openstack/classes/identity.bbclass +5 -3
@@ -163,9 +163,11 @@ python populate_packages_append () {
 
          postinst = d.getVar('pkg_postinst_%s' % pkg, True) or
          d.getVar('pkg_postinst', True)> 
          if not postinst:
-            postinst = '    if [ "x$D" != "x" ]; then\n' + \
-                       '        exit 1\n' + \
-                       '    fi\n'
+            postinst = ''
+
+        # Only execute on target. Header.
+        postinst += '    if [ -z "$D" ]; then\n'
+
 
          postinst += servicecreate_postinst_common_copy

if d.getVar('USERCREATE_PARAM_%s' % pkg, True):

meta-openstack/classes/identity.bbclass +3 -0
@@ -176,6 +178,9 @@ python populate_packages_append () {
 
              servicecreate_postinst_service =
              servicecreate_postinst_service_copy.replace("SERVICECREATE_
              PARAM", servicecreate_param(d, pkg)) postinst +=
              servicecreate_postinst_service
 
+        # Footer.
+        postinst += '    fi\n'
+
          d.setVar('pkg_postinst_%s' % pkg, postinst)
          bb.debug(1, 'pkg_postinst_%s = %s' % (pkg,
          d.getVar('pkg_postinst_%s' % pkg, True)))>   

}

(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-barbican_git.bb index 0b3d768..579413c 100644

meta-openstack/recipes-devtools/python/python-barbican_git.bb +3 -5
@@ -85,12 +85,10 @@ FILES_${SRCNAME} = "${sysconfdir}/${SRCNAME}/* \
 
  ALLOW_EMPTY_${SRCNAME}-setup = "1"
  pkg_postinst_${SRCNAME}-setup () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+        chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
+        chown -R barbican:barbican ${localstatedir}/lib/barbican
 
      fi
 
-
-    chown -R barbican:barbican ${sysconfdir}/${SRCNAME}
-    chown -R barbican:barbican ${localstatedir}/lib/barbican
  }
  
  DEPENDS += " \

diff --git a/meta-openstack/recipes-devtools/python/python-ceilometer_git.bb b/meta-openstack/recipes-devtools/python/python-ceilometer_git.bb index 5645626..4b01022 100644

meta-openstack/recipes-devtools/python/python-ceilometer_git.bb +11 -13
@@ -108,20 +108,18 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+        # This is to make sure postgres is configured and running
+        if ! pidof postmaster > /dev/null; then
+           /etc/init.d/postgresql-init
+           /etc/init.d/postgresql start
+           sleep 2
+        fi
+
+        mkdir /var/log/ceilometer
+        sudo -u postgres createdb ceilometer
+        ceilometer-dbsync
 
      fi
 
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 2
-    fi
-
-    mkdir /var/log/ceilometer
-    sudo -u postgres createdb ceilometer
-    ceilometer-dbsync
 
  }
 
  inherit setuptools identity hosts update-rc.d default_configs monitor
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-cinder_git.bb index e70a3aa..9f70beb 100644

meta-openstack/recipes-devtools/python/python-cinder_git.bb +0 -23
@@ -124,31 +124,29 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-    fi
-
-    if [ ! -d /var/log/cinder ]; then
-       mkdir /var/log/cinder
-    fi
-
-    sudo -u postgres createdb cinder
-    cinder-manage db sync
-
-    # Create Cinder nfs_share config file with default nfs server
-    if [ ! -f /etc/cinder/nfs_shares ]; then
-        /bin/bash /etc/cinder/drivers/nfs_setup.sh
-    fi
-
-    # Create Cinder glusterfs_share config file with default glusterfs

server - if [ ! -f /etc/cinder/glusterfs_shares ] && [ -f
/usr/sbin/glusterfsd ]; then - /bin/bash
/etc/cinder/drivers/glusterfs_setup.sh

meta-openstack/recipes-devtools/python/python-cinder_git.bb +20 -0
+    if [ -z "$D" ]; then
+	 # This is to make sure postgres is configured and running
+	 if ! pidof postmaster > /dev/null; then
+	    /etc/init.d/postgresql-init
+	    /etc/init.d/postgresql start
+	 fi
+
+	 if [ ! -d /var/log/cinder ]; then
+	    mkdir /var/log/cinder
+	 fi
+
+	 sudo -u postgres createdb cinder
+	 cinder-manage db sync
+
+	 # Create Cinder nfs_share config file with default nfs server
+	 if [ ! -f /etc/cinder/nfs_shares ]; then
+	     /bin/bash /etc/cinder/drivers/nfs_setup.sh
+	 fi
+
+	 # Create Cinder glusterfs_share config file with default glusterfs

server + if [ ! -f /etc/cinder/glusterfs_shares ] && [ -f
/usr/sbin/glusterfsd ]; then + /bin/bash
/etc/cinder/drivers/glusterfs_setup.sh

meta-openstack/recipes-devtools/python/python-cinder_git.bb +1 -0
+	 fi
 
      fi
 
  }
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-glance_git.bb index 27c33b9..4042f1b 100644

meta-openstack/recipes-devtools/python/python-glance_git.bb +11 -13
@@ -122,20 +122,18 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 5
+	fi
+
+	mkdir /var/log/glance
+	sudo -u postgres createdb glance
+	glance-manage db_sync
 
      fi
 
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 5
-    fi
-
-    mkdir /var/log/glance
-    sudo -u postgres createdb glance
-    glance-manage db_sync
 
  }
 
  PACKAGES += " ${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup
  ${SRCNAME}-api ${SRCNAME}-registry"> 
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-heat_git.bb index cccaf0a..2cf7ce4 100644

meta-openstack/recipes-devtools/python/python-heat_git.bb +11 -13
@@ -107,20 +107,18 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 2
+	fi
+
+	mkdir /var/log/heat
+	sudo -u postgres createdb heat
+	heat-manage db_sync
 
      fi
 
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 2
-    fi
-
-    mkdir /var/log/heat
-    sudo -u postgres createdb heat
-    heat-manage db_sync
 
  }
 
  inherit setuptools identity hosts update-rc.d default_configs monitor
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-keystone_git.bb index 79bd0c8..a26c9bf 100644

meta-openstack/recipes-devtools/python/python-keystone_git.bb +0 -19
@@ -189,28 +189,26 @@ role_tree_dn = ou=Roles,${LDAP_DN} \
 
  pkg_postinst_${SRCNAME}-setup () {
 
      # python-keystone postinst start
 
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-        /etc/init.d/postgresql-init
-        /etc/init.d/postgresql start
-        sleep 2
-    fi
-
-    # This is to make sure keystone is configured and running
-    PIDFILE="/var/run/keystone-all.pid"
-    if [ -z `cat $PIDFILE 2>/dev/null` ]; then
-        sudo -u postgres createdb keystone
-        keystone-manage db_sync
-        keystone-manage pki_setup --keystone-user=root
--keystone-group=daemon -
-        if ${@bb.utils.contains('DISTRO_FEATURES', 'OpenLDAP', 'true',

'false', d)}; then - /etc/init.d/openldap start

meta-openstack/recipes-devtools/python/python-keystone_git.bb +15 -3
-        fi
-        /etc/init.d/keystone start
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	    /etc/init.d/postgresql-init
+	    /etc/init.d/postgresql start
+	    sleep 2
+	fi
+
+	# This is to make sure keystone is configured and running
+	PIDFILE="/var/run/keystone-all.pid"
+	if [ -z `cat $PIDFILE 2>/dev/null` ]; then
+	    sudo -u postgres createdb keystone
+	    keystone-manage db_sync
+	    keystone-manage pki_setup --keystone-user=root
--keystone-group=daemon +
+	    if ${@bb.utils.contains('DISTRO_FEATURES', 'OpenLDAP', 'true',

'false', d)}; then + /etc/init.d/openldap start

meta-openstack/recipes-devtools/python/python-keystone_git.bb +3 -0
+	    fi
+	    /etc/init.d/keystone start
+	fi
 
      fi
 
  }
@@ -219,9 +217,11 @@ pkg_postinst_${SRCNAME}-setup () {
 
  KEYSTONE_TOKEN_FLUSH_TIME ??= "0 0 */2 * *"
 
  pkg_postinst_${SRCNAME}-cronjobs () {
 
Quoted 8 lines

meta-openstack/recipes-devtools/python/python-keystone_git.bb

Quoted 8 lines
meta-openstack/recipes-devtools/python/python-keystone_git.bb +0 -1
-    # By default keystone expired tokens are not automatic removed out of

the - # database. So we create a cronjob for cleaning these expired
tokens. - echo "${KEYSTONE_TOKEN_FLUSH_TIME} root
/usr/bin/keystone-manage token_flush" >> /etc/crontab + if [ -z "$D"
]; then

meta-openstack/recipes-devtools/python/python-keystone_git.bb +1 -0
+	# By default keystone expired tokens are not automatic removed out of

the

meta-openstack/recipes-devtools/python/python-keystone_git.bb +1 -0
+	# database.  So we create a cronjob for cleaning these expired 

tokens.

Quoted 18 lines
Quoted 18 lines
meta-openstack/recipes-devtools/python/python-keystone_git.bb +1 -0
+	echo "${KEYSTONE_TOKEN_FLUSH_TIME} root /usr/bin/keystone-manage

token_flush" >> /etc/crontab + fi

  }

PACKAGES += " ${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup ${SRCNAME}-cronjobs">

(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-neutron_git.bb index 51c2ac4..c837401 100644

meta-openstack/recipes-devtools/python/python-neutron_git.bb +0 -0
@@ -138,29 +138,25 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
Quoted 13 lines

meta-openstack/recipes-devtools/python/python-neutron_git.bb do_install_append() {

Quoted 13 lines
meta-openstack/recipes-devtools/python/python-neutron_git.bb +11 -2
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	    /etc/init.d/postgresql-init
+	    /etc/init.d/postgresql start
+	    sleep 2
+	fi
+
+	sudo -u postgres createdb neutron
+	sudo neutron-db-manage --config-file /etc/neutron/neutron.conf  \
+			       --config-file /etc/neutron/plugins/ml2/ml2_conf.ini 

upgrade

Quoted 161 lines
Quoted 161 lines

head

fi

meta-openstack/recipes-devtools/python/python-neutron_git.bb +0 -11
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-        /etc/init.d/postgresql-init
-        /etc/init.d/postgresql start
-        sleep 2
-    fi
-
-    sudo -u postgres createdb neutron
-    sudo neutron-db-manage --config-file /etc/neutron/neutron.conf  \
-                           --config-file

/etc/neutron/plugins/ml2/ml2_conf.ini upgrade head>
}

  pkg_postinst_${SRCNAME}-plugin-openvswitch-setup () {
meta-openstack/recipes-devtools/python/python-neutron_git.bb +3 -5
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	/etc/init.d/openvswitch-switch start
+	ovs-vsctl --no-wait -- --may-exist add-br br-int
 
      fi
 
-
-    /etc/init.d/openvswitch-switch start
-    ovs-vsctl --no-wait -- --may-exist add-br br-int
 
  }
 
  ALLOW_EMPTY_${SRCNAME}-setup = "1"
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-nova_git.bb index f3a6b86..7b560a7 100644

meta-openstack/recipes-devtools/python/python-nova_git.bb +19 -23
@@ -160,33 +160,29 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 5
+	fi
+
+	sudo -u postgres createdb nova
+	sleep 2
+	nova-manage db sync
 
      fi
 
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 5
-    fi
-
-    sudo -u postgres createdb nova
-    sleep 2
-    nova-manage db sync
 
  }
 
  pkg_postinst_${SRCNAME}-common () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    if [ -d  /home/root ]; then
-        echo "source /etc/nova/openrc" >> /home/root/.bashrc
-	echo "source /etc/nova/openrc" >> /home/root/.profile
-    else
-        echo "source /etc/nova/openrc" >> /root/.bashrc
-	echo "source /etc/nova/openrc" >> /root/.profile
+    if [ -z "$D" ]; then
+	if [ -d  /home/root ]; then
+	    echo "source /etc/nova/openrc" >> /home/root/.bashrc
+	    echo "source /etc/nova/openrc" >> /home/root/.profile
+	else
+	    echo "source /etc/nova/openrc" >> /root/.bashrc
+	    echo "source /etc/nova/openrc" >> /root/.profile
+	fi
 
      fi
 
  }
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-rally_git.bb index d29e7cb..31d4242 100644

meta-openstack/recipes-devtools/python/python-rally_git.bb +13 -15
@@ -63,22 +63,20 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	fi
+
+	if [ ! -d /var/log/rally ]; then
+	   mkdir /var/log/rally
+	fi
+
+	sudo -u postgres createdb rally
+	rally-manage db recreate
 
      fi
 
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-    fi
-
-    if [ ! -d /var/log/rally ]; then
-       mkdir /var/log/rally
-    fi
-
-    sudo -u postgres createdb rally
-    rally-manage db recreate
 
  }
 
  PACKAGES += "${SRCNAME}-tests ${SRCNAME}-api ${SRCNAME}
  ${SRCNAME}-setup"
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-swift_git.bb index 8552ea7..fc7c258 100644

meta-openstack/recipes-devtools/python/python-swift_git.bb +0 -0
@@ -109,28 +109,26 @@ do_install_append() {
 
  }
 
  pkg_postinst_${SRCNAME}-setup () {
 
Quoted 11 lines

meta-openstack/recipes-devtools/python/python-swift_git.bb do_install_append() {

Quoted 11 lines
meta-openstack/recipes-devtools/python/python-swift_git.bb +9 -2
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "x$D" ]; then
+	CLUSTER_CONF=/etc/swift/cluster.conf
+	SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh'
+
+	for i in `seq 1 3`; do
+	    BACKING_FILE=/etc/swift/swift_backing_$i
+	    if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then
+		truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE
+		sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i 

$CLUSTER_CONF

Quoted 62 lines
Quoted 62 lines
meta-openstack/recipes-devtools/python/python-swift_git.bb +10 -9
+	    else
+		sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF
+	    fi
+	done
+
+	$SWIFT_SETUP createrings
+	$SWIFT_SETUP formatdevs
+	$SWIFT_SETUP mountdevs
+	$SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs
+	$SWIFT_SETUP unmountdevs
 
      fi
 
-
-    CLUSTER_CONF=/etc/swift/cluster.conf
-    SWIFT_SETUP='/bin/bash /etc/swift/swift_setup.sh'
-
-    for i in `seq 1 3`; do
-        BACKING_FILE=/etc/swift/swift_backing_$i
-        if [ "x${SWIFT_BACKING_FILE_SIZE}" != "x0G" ]; then
-            truncate -s ${SWIFT_BACKING_FILE_SIZE} $BACKING_FILE
-            sed "s:%SWIFT_BACKING_FILE_${i}%:$BACKING_FILE:g" -i

$CLUSTER_CONF - else

meta-openstack/recipes-devtools/python/python-swift_git.bb +0 -9
-            sed "s:%SWIFT_BACKING_FILE_${i}%::g" -i $CLUSTER_CONF
-        fi
-    done
-
-    $SWIFT_SETUP createrings
-    $SWIFT_SETUP formatdevs
-    $SWIFT_SETUP mountdevs
-    $SWIFT_SETUP -i "${CONTROLLER_IP}" adddevs
-    $SWIFT_SETUP unmountdevs
 
  }
 
  PACKAGES += "${SRCNAME}-tests ${SRCNAME} ${SRCNAME}-setup"
(quoted diff) +0 -0

b/meta-openstack/recipes-devtools/python/python-trove_git.bb index 830da92..b90e552 100755

meta-openstack/recipes-devtools/python/python-trove_git.bb +12 -2
@@ -146,30 +146,29 @@ do_install_append() {
 
  pkg_postinst_${SRCNAME}-setup () {
 
      # python-trove-setup postinst start
 
-    if [ "x$D" != "x" ]; then
-        exit 1
+    if [ -z "$D" ]; then
+	source /etc/nova/openrc
+
+	# This is to make sure postgres is configured and running
+	if ! pidof postmaster > /dev/null; then
+	   /etc/init.d/postgresql-init
+	   /etc/init.d/postgresql start
+	   sleep 5
+	fi
+
+	mkdir /var/log/trove
+	# Create database for trove.
Quoted 8 lines

meta-openstack/recipes-devtools/python/python-trove_git.bb do_install_append() {

Quoted 8 lines
meta-openstack/recipes-devtools/python/python-trove_git.bb +8 -0
+	sudo -u postgres createdb trove
+
+	# Create default trove database.
+	trove-manage db_sync
+	# Create new datastore.
+	trove-manage datastore_update "postgresql" ""
+	# Set up new version
+	trove-manage datastore_version_update "postgresql" "9.1" "postgresql" 

1

Quoted 59 lines
Quoted 59 lines

"postgresql-server-9.1" 1 + # Set new default version.

meta-openstack/recipes-devtools/python/python-trove_git.bb +1 -19
+	trove-manage datastore_update "postgresql" "9.1"
 
      fi
 
-    source /etc/nova/openrc
-
-    # This is to make sure postgres is configured and running
-    if ! pidof postmaster > /dev/null; then
-       /etc/init.d/postgresql-init
-       /etc/init.d/postgresql start
-       sleep 5
-    fi
-
-    mkdir /var/log/trove
-    # Create database for trove.
-    sudo -u postgres createdb trove
-
-    # Create default trove database.
-    trove-manage db_sync
-    # Create new datastore.
-    trove-manage datastore_update "postgresql" ""
-    # Set up new version
-    trove-manage datastore_version_update "postgresql" "9.1" "postgresql"

1 "postgresql-server-9.1" 1 - # Set new default version.
- trove-manage datastore_update "postgresql" "9.1"

  }

diff --git a/meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend b/meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend index 22dae71..b26054e 100644

meta-openstack/recipes-support/postgresql/postgresql_9.%.bbappend +6 -8
@@ -41,14 +41,12 @@ ALLOW_EMPTY_${PN}-setup = "1"
 
  pkg_postinst_${PN}-setup () {
 
      # postgres 9.2.4 postinst
 
-    if [ "x$D" != "x" ]; then
-        exit 1
-    fi
-
-    /etc/init.d/postgresql-init
-    if [ $? -ne 0 ]; then
-        echo "[ERROR] postgres: unable to create admin account"
-        exit 1
+    if [ -z "$D" ]; then
+	/etc/init.d/postgresql-init
+	if [ $? -ne 0 ]; then
+	    echo "[ERROR] postgres: unable to create admin account"
+	    exit 1
+	fi
 

fi

  }
#3 lore raw
In reply to Mark Asselstine
Quoted 11 lines · Mark Asselstine

Checking for "$D" and doing an "exit 1" now results in errors such as:

[log_check] warning: %post(keystone-cronjobs-...) scriptlet failed, exit status 2

during image creation. Instead of escaping the script for "level-1" (image creation postinst) we wrap the "level-2" (first boot) postinst in an if statement. This also ensure the scriptlet in indentity.bbclass is less prone to behaving differently based on the postinsts defined in the classes which inherit 'identity'.

I think this could mean the postinst doesn't get executed at all if there isn't an exit 1, else how would it know to defer to first boot?

Cheers,

Richard

#4 lore raw
Quoted 7 lines · EST Richard Purdie
Quoted 6 lines · Mark Asselstine

Checking for "$D" and doing an "exit 1" now results in errors such as:

[log_check] warning: %post(keystone-cronjobs-...) scriptlet failed, exit status 2

Quoted 8 lines
Quoted 5 lines

during image creation. Instead of escaping the script for "level-1" (image creation postinst) we wrap the "level-2" (first boot) postinst in an if statement. This also ensure the scriptlet in indentity.bbclass is less prone to behaving differently based on the postinsts defined in the classes which inherit 'identity'.

I think this could mean the postinst doesn't get executed at all if there isn't an exit 1, else how would it know to defer to first boot?

Every time I touch the postinst I admittedly end up in a knot. I was inspecting the rpm scripts and all seemed well but I will take another look to ensure I am not being a dolt.

Either way thanks for the nudge Richard. Bruce hold off on this one for now. I have so many little and big changes to get m-c-s back up to snuff I am better off taking the time to ensure I am not messing something up.

Mark

Quoted 4 lines

Cheers,

Richard

#5 lore raw
Quoted 17 lines · Mark Asselstine
Quoted 7 lines · EST Richard Purdie
Quoted 6 lines · Mark Asselstine

Checking for "$D" and doing an "exit 1" now results in errors such as:

[log_check] warning: %post(keystone-cronjobs-...) scriptlet failed, exit status 2

Quoted 8 lines
Quoted 5 lines

during image creation. Instead of escaping the script for "level-1" (image creation postinst) we wrap the "level-2" (first boot) postinst in an if statement. This also ensure the scriptlet in indentity.bbclass is less prone to behaving differently based on the postinsts defined in the classes which inherit 'identity'.

I think this could mean the postinst doesn't get executed at all if there isn't an exit 1, else how would it know to defer to first boot?

Quoted 7 lines

Every time I touch the postinst I admittedly end up in a knot. I was inspecting the rpm scripts and all seemed well but I will take another look to ensure I am not being a dolt.

Either way thanks for the nudge Richard. Bruce hold off on this one for now. I have so many little and big changes to get m-c-s back up to snuff I am better off taking the time to ensure I am not messing something up.

hah. I already merged this one, so rebase and send any fixups.

Bruce

Quoted 9 lines

Mark

Quoted 4 lines

Cheers,

Richard

#6 lore raw
Quoted 22 lines · EST Bruce Ashfield
Quoted 21 lines · Mark Asselstine
Quoted 7 lines · EST Richard Purdie
Quoted 6 lines · Mark Asselstine

Checking for "$D" and doing an "exit 1" now results in errors such as:

[log_check] warning: %post(keystone-cronjobs-...) scriptlet failed, exit status 2

Quoted 8 lines
Quoted 5 lines

during image creation. Instead of escaping the script for "level-1" (image creation postinst) we wrap the "level-2" (first boot) postinst in an if statement. This also ensure the scriptlet in indentity.bbclass is less prone to behaving differently based on the postinsts defined in the classes which inherit 'identity'.

I think this could mean the postinst doesn't get executed at all if there isn't an exit 1, else how would it know to defer to first boot?

Every time I touch the postinst I admittedly end up in a knot. I was inspecting the rpm scripts and all seemed well but I will take another look to ensure I am not being a dolt.

Quoted 5 lines
Quoted 3 lines

Either way thanks for the nudge Richard. Bruce hold off on this one for now. I have so many little and big changes to get m-c-s back up to snuff I am better off taking the time to ensure I am not messing something up.

hah. I already merged this one, so rebase and send any fixups.

No problem. Seems Richard was correct. I saw the scripts in the RPM and see them logged on first boot but they are in fact ineffective. Adding the exit 1, however, marks a return of the log_check warning, so I will have to look at what is going on there.

At any rate I need to go through each of these postinst scripts one by one as they are all out of date, so overall this will not be a cause off any additional noise.

Mark

Quoted 8 lines

Bruce

Quoted 5 lines

Mark

Quoted 3 lines

Cheers,

Richard