diff --git a/debian/changelog b/debian/changelog index d0cf249f8c53f828ce9d6895c48237b77ba537df..0f270c95743ba72a9fe3392beba6f376d4f0c3bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,39 @@ +nova (2:18.0.1-2) unstable; urgency=medium + + [ Michal Arbet ] + * d/nova-api-postinst.in: + - Add calling nova-common's trigger nova-common-db-sync + * - Add calling "nova-manage cell_v2 map_cell0" + * - Add calling "nova-manage cell_v2 create_cell --name=cell1" + * d/nova-api.postrm: + - Redesigned to nova-api.postrm.in + * d/nova-api.prerm: + - Add deletion of nova_api database + * d/nova-common.postinst.in + - Add function run_db_sync + - Add function create_cell0_database if configured + via dbconfig-common + - Changed postinst to call create_cell0_database + and after that run_db_sync + - Add if clause triggered which calls nova-common-db-sync + * d/nova-common.postrm.in: + - Add deletion of /etc/nova/placement-policy.json (Closes: #909115) + - Add deletion of nova_cell0 database if configured + * d/nova-common.triggers: + - Add nova-common-db-sync trigger + * d/nova-placement-api.config.in + - Add creation of placement db which is currently not required + in rocky, but now it is possible to do it with dbconfig-common + * d/nova-placement-api.postrm.in + - Add purging dbc config + * d/nova-placement-api.prerm + - Add deletion of placement database + * d/rules: + - Add deletion of __pychache__ in dh_clean + - Add pkgos-merge-templates of nova-placement-api + + -- Michal Arbet Wed, 26 Sep 2018 15:59:53 +0200 + nova (2:18.0.1-1) unstable; urgency=medium * New upstream release. diff --git a/debian/nova-api.postinst.in b/debian/nova-api.postinst.in index 9c2a24a251bc2c1f0a608c7acb0bfd607adae016..aa057926eaec03f3137a93f391fcd3191ea041f0 100755 --- a/debian/nova-api.postinst.in +++ b/debian/nova-api.postinst.in @@ -17,8 +17,13 @@ if [ "$1" = "configure" ] ; then db_get novaapi/configure_db if [ "$RET" = "true" ]; then pkgos_dbc_postinst --suite nova /etc/nova/nova.conf api_database connection novaapi $@ - echo "nova-common: Now running \"nova-manage api_db sync\", this may take a while..." + echo "===> nova-common: Now running \"nova-manage api_db sync\", this may take a while..." su nova -s /bin/sh -c "nova-manage api_db sync" || true + echo "===> nova-common: Registering nova cell0 database" + su nova -s /bin/sh -c "nova-manage cell_v2 map_cell0 2>/dev/null" || true + echo "===> nova-common: Creating nova cell1 database" + su nova -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose 2>/dev/null" || true + dpkg-trigger --no-await nova-common-db-sync fi db_stop diff --git a/debian/nova-api.postrm b/debian/nova-api.postrm deleted file mode 100755 index 61000b998631a0c30d807fcfe1b68da28227a3f3..0000000000000000000000000000000000000000 --- a/debian/nova-api.postrm +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -set -e - -if [ "$1" = "purge" ] ; then - if [ -r /usr/share/debconf/confmodule ] ; then - . /usr/share/debconf/confmodule - db_get nova/configure_db || true - if [ "$RET" = "true" ] ; then - if [ -f /usr/share/dbconfig-common/dpkg/postrm ] ; then - . /usr/share/dbconfig-common/dpkg/postrm - dbc_go nova-api $@ - else - rm -f /etc/dbconfig-common/nova-api.conf - if which ucf >/dev/null 2>&1; then - ucf --purge /etc/dbconfig-common/nova-api.conf - ucfr --purge nova-api /etc/dbconfig-common/nova-api.conf - fi - fi - fi - fi - - rm -f /var/log/nova/nova-api.log* -fi - - -#DEBHELPER# diff --git a/debian/nova-api.postrm.in b/debian/nova-api.postrm.in new file mode 100755 index 0000000000000000000000000000000000000000..cfb589ef04952f5b72211695995313505be62ed4 --- /dev/null +++ b/debian/nova-api.postrm.in @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +#PKGOS-INCLUDE# + +if [ "$1" = "purge" ] ; then + pkgos_dbc_postrm novaapi nova-api $@ + + rm -f /var/log/nova/nova-api.log* +fi + + +#DEBHELPER# diff --git a/debian/nova-api.prerm b/debian/nova-api.prerm new file mode 100755 index 0000000000000000000000000000000000000000..4e4792b3b1b593d3362fe21c4eccdffcafaed309 --- /dev/null +++ b/debian/nova-api.prerm @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +if [ "${1}" = "remove" ] && [ -r /usr/share/debconf/confmodule ] && [ -r /usr/share/dbconfig-common/dpkg/prerm ] ; then + . /usr/share/debconf/confmodule + db_get novaapi/configure_db || true + if [ "$RET" = "true" ] ; then + . /usr/share/dbconfig-common/dpkg/prerm + dbc_go nova-api $@ + fi +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/nova-common.postinst.in b/debian/nova-common.postinst.in index a3c49930750bdb8d20f763e275012f712d370fb7..e2bff9030e92bc1aeeaab35289dd4ed1062c8f15 100755 --- a/debian/nova-common.postinst.in +++ b/debian/nova-common.postinst.in @@ -51,6 +51,37 @@ read_neutron_config () { pkgos_inifile set ${NOVA_CONF} neutron metadata_proxy_shared_secret ${RET} } +run_db_sync (){ + + API_DATABASE_CONFIG_AVAILABLE=None + + # We have to check if connection is set in [api_database] config + pkgos_inifile get ${NOVA_CONF} api_database connection + if echo ${RET} | egrep 'mysql(\+pymysql)?:.*:.*@.*\/.*' > /dev/null; then + echo "===> nova-common: Now running \"nova-manage db sync\", this may take a while..." + su nova -s /bin/sh -c "nova-manage db sync" || true + else + echo "===> nova-common: \"nova-manage db sync\" needs api_database.connection set. Sorry." + fi + +} + +create_cell0_database (){ + if [ "${dbc_install}" = "true" ] ; then + if [ "${dbc_dbtype}" = "mysql" ]; then + # Create nova_cell0 database + echo "===> nova-common: Creating ${dbc_dbname}_cell0 database:" + echo "CREATE DATABASE IF NOT EXISTS ${dbc_dbname}_cell0 CHARACTER SET utf8 COLLATE utf8_unicode_ci;" | mysql -h ${dbc_dbserver} -u ${dbc_dbadmin} -p${dbc_dbadmpass} + echo "===> nova-common: Granting permissions on ${dbc_dbname}_cell0.* to '${dbc_dbuser}'@'${dbc_dballow}'" + echo "GRANT ALL PRIVILEGES ON ${dbc_dbname}_cell0.* TO '${dbc_dbuser}'@'${dbc_dballow}';" | mysql -h ${dbc_dbserver} -u ${dbc_dbadmin} -p${dbc_dbadmpass} + elif [ "$RET" = "sqlite3" ]; then + echo "===> nova-common: Creation of database $sqlite3_db_name in sqlite3 is not currently supported. Please create database manually." + else + echo "===> nova-common: Database configuration available only mysql currently. Please, create database manually." + fi + fi +} + if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then . /usr/share/debconf/confmodule @@ -83,8 +114,8 @@ if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then db_get nova/configure_db if [ "$RET" = "true" ]; then pkgos_dbc_postinst /etc/nova/nova.conf database connection nova $@ - echo "nova-common: Now running \"nova-manage db sync\", this may take a while..." - su nova -s /bin/sh -c "nova-manage db sync" || true + create_cell0_database + run_db_sync fi db_stop @@ -94,6 +125,10 @@ if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ] ; then [ -f /etc/sudoers.d/nova_sudoers ] && rm -f /etc/sudoers.d/nova_sudoers # That's the old file that we get rid of fi +if [ "$1" = "triggered" ]; then + run_db_sync +fi + #DEBHELPER# exit 0 diff --git a/debian/nova-common.postrm.in b/debian/nova-common.postrm.in index f05845d0a723b4573dd6a4a193ac91bc638c0254..86444591e6372296c8d0fb7f00bbde7d594ac16a 100755 --- a/debian/nova-common.postrm.in +++ b/debian/nova-common.postrm.in @@ -14,6 +14,7 @@ if [ "$1" = "purge" ] ; then rm -f /etc/default/nova-common rm -f /etc/nova/api-paste.ini rm -f /etc/nova/logging.conf + rm -f /etc/nova/placement-policy.json rmdir --ignore-fail-on-non-empty /etc/nova fi diff --git a/debian/nova-common.prerm b/debian/nova-common.prerm index e194cbac1082a54e1163de3fc25f4b115c2895e2..fa946271c0e6a0f90cdcd3cc1667e32cc4c21bc6 100755 --- a/debian/nova-common.prerm +++ b/debian/nova-common.prerm @@ -2,12 +2,32 @@ set -e +remove_cell0_database (){ + dump_timestamp=$(date +"%Y-%m-%d-%H-%M-%S") + if [ "${dbc_dbtype}" = "mysql" ]; then + # Drop nova_cell0 database + echo "===> nova-common: Dumping ${dbc_dbname}_cell0 database to /var/tmp/nova-common.${dbc_dbname}_cell0.${dump_timestamp}.mysql" + mysqldump -h ${dbc_dbserver} -u ${dbc_dbadmin} -p${dbc_dbadmpass} ${dbc_dbname}_cell0 > /var/tmp/nova-common.${dbc_dbname}_cell0.${dump_timestamp}.mysql + echo "===> nova-common: Revoking all privileges from '${dbc_dbuser}'@'${dbc_dballow}' for ${dbc_dbname}_cell0" + echo "REVOKE ALL PRIVILEGES ON ${dbc_dbname}_cell0.* FROM '${dbc_dbuser}'@'${dbc_dballow}';" | mysql -h ${dbc_dbserver} -u ${dbc_dbadmin} -p${dbc_dbadmpass} + echo "===> nova-common: Droping database ${dbc_dbname}_cell0" + echo "DROP DATABASE ${dbc_dbname}_cell0" | mysql -h ${dbc_dbserver} -u ${dbc_dbadmin} -p${dbc_dbadmpass} + elif [ "$nova_database_type" = "sqlite3" ]; then + echo "===> nova-common: Creation of database in sqlite3 is not currently supported. If you've created manually, delete also manually." + else + echo "===> nova-common: Database configuration available only for mysql currently. If you've created database manually, delete also manually." + fi +} + if [ "${1}" = "remove" ] && [ -r /usr/share/debconf/confmodule ] && [ -r /usr/share/dbconfig-common/dpkg/prerm ] ; then . /usr/share/debconf/confmodule db_get nova/configure_db || true if [ "$RET" = "true" ] ; then . /usr/share/dbconfig-common/dpkg/prerm dbc_go nova-common $@ + if [ "$dbc_remove" = "true" ]; then + remove_cell0_database + fi fi fi diff --git a/debian/nova-common.triggers b/debian/nova-common.triggers new file mode 100644 index 0000000000000000000000000000000000000000..547126239f8cdb2b3bd41206c9cde0ac34328f68 --- /dev/null +++ b/debian/nova-common.triggers @@ -0,0 +1 @@ +interest nova-common-db-sync diff --git a/debian/nova-placement-api.config.in b/debian/nova-placement-api.config.in index 470a68b0a5e1d66f4c2c0b35afa69189e50cbe5c..d9e42dbd45322336039eafde86cea78842738f9c 100644 --- a/debian/nova-placement-api.config.in +++ b/debian/nova-placement-api.config.in @@ -4,8 +4,11 @@ set -e . /usr/share/debconf/confmodule +NOVA_CONF=/etc/nova/nova.conf + #PKGOS-INCLUDE# pkgos_register_endpoint_config nova-placement-api +pkgos_dbc_read_conf -pkg nova-placement-api ${NOVA_CONF} placement_database connection placement $@ exit 0 diff --git a/debian/nova-placement-api.postinst.in b/debian/nova-placement-api.postinst.in index 1b1a56a5bb0fef572b62d9a569a4aa8214c071f3..a291025bb7cf48a50123b49b5d162f1d99971501 100755 --- a/debian/nova-placement-api.postinst.in +++ b/debian/nova-placement-api.postinst.in @@ -7,6 +7,16 @@ set -e if [ "$1" = "configure" ] ; then . /usr/share/debconf/confmodule pkgos_register_endpoint_postinst nova-placement-api placement placement "Placement API" 8778 "" + + db_get placement/configure_db + if [ "$RET" = "true" ]; then + pkgos_dbc_postinst --suite nova /etc/nova/nova.conf placement_database connection placement $@ + echo "===> nova-common: Now running \"nova-manage api_db sync\", this may take a while..." + # This command is failing when api_database not filled, but it is false positive + # If we have nova api db populated , it is OK , placement db is not required still in rocky + su nova -s /bin/sh -c "nova-manage api_db sync 2>/dev/null" || true + fi + db_stop fi diff --git a/debian/nova-placement-api.postrm.in b/debian/nova-placement-api.postrm.in new file mode 100644 index 0000000000000000000000000000000000000000..31614a6b0356bf9c8af86c448f26c3e01bb7b9f4 --- /dev/null +++ b/debian/nova-placement-api.postrm.in @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +#PKGOS-INCLUDE# + +if [ "$1" = "purge" ] ; then + pkgos_dbc_postrm placement nova-placement-api $@ +fi + + +#DEBHELPER# diff --git a/debian/nova-placement-api.prerm b/debian/nova-placement-api.prerm new file mode 100644 index 0000000000000000000000000000000000000000..d0dbf7ccc6226997168e36875e2ec275b91cdf79 --- /dev/null +++ b/debian/nova-placement-api.prerm @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +if [ "${1}" = "remove" ] && [ -r /usr/share/debconf/confmodule ] && [ -r /usr/share/dbconfig-common/dpkg/prerm ] ; then + . /usr/share/debconf/confmodule + db_get placement/configure_db || true + if [ "$RET" = "true" ] ; then + . /usr/share/dbconfig-common/dpkg/prerm + dbc_go nova-placement-api $@ + fi +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules index 6ddda0a8a98f0f413e9ad56e624aaa4c107ba477..ad7b0998b171186dc58fcafb1137d8921811d1e5 100755 --- a/debian/rules +++ b/debian/rules @@ -20,6 +20,7 @@ override_dh_auto_clean: rm -rf .testrepository subunit.log instances keys rm -rf debian/bla rm -f debian/nova-api.templates debian/nova-common.templates + find . -type d -name __pycache__ -exec rm -r {} \+ override_dh_auto_build: /usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_func nova-common.config @@ -31,7 +32,7 @@ override_dh_auto_build: /usr/share/openstack-pkg-tools/pkgos_insert_include pkgos_postrm nova-common.postrm pkgos-merge-templates nova-api nova endpoint pkgos-merge-templates nova-common nova db rabbit ksat - pkgos-merge-templates nova-placement-api nova-placement-api endpoint + pkgos-merge-templates nova-placement-api nova-placement-api endpoint db override_dh_sphinxdoc: ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))