From e18ed85921139d34f015b43075a21335e87fb319 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 23 Aug 2016 16:48:38 -0400 Subject: Import version 0.7.7~bzr1156-0ubuntu1 Imported using git-dsc-commit. --- debian/changelog | 8 +++++ debian/cloud-init.preinst | 75 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 81 insertions(+), 2 deletions(-) (limited to 'debian') diff --git a/debian/changelog b/debian/changelog index 085a2d01..b99e77de 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +cloud-init (0.7.7~bzr1156-0ubuntu1) xenial; urgency=medium + + * New upstream snapshot. + * d/cloud-init.preinst: migrate Azure instance ID from old ID to stable + ID (LP: #1506187). + + -- Ben Howard Tue, 17 Nov 2015 11:59:49 -0700 + cloud-init (0.7.7~bzr1155-0ubuntu1) xenial; urgency=medium * New upstream snapshot. diff --git a/debian/cloud-init.preinst b/debian/cloud-init.preinst index e5c7755f..e383c092 100644 --- a/debian/cloud-init.preinst +++ b/debian/cloud-init.preinst @@ -105,6 +105,73 @@ convert_varlib_05x_06x() { return 0 } +azure_apply_new_instance_id_1506187() { + # With LP: #1506187, the Azure instance ID detection method was changed + # to use the DMI data. In order to prevent existing instances from thinking + # they are new instances, the instance ID needs to be updated here. + + if grep DataSourceAzure /var/lib/cloud/instance/datasource > /dev/null 2>&1; then + + product_id_f="/sys/devices/virtual/dmi/id/product_uuid" + instance_id_f="/var/lib/cloud/data/instance-id" + + if [ ! -e "${product_id_f}" -o ! -e "${instance_id_f}" ]; then + return 0 + fi + + # Get the current instance ID's (new and old) + new_instance_id="$(cat ${product_id_f})" + old_instance_id="$(cat ${instance_id_f})" + + if [ "${new_instance_id}" = "${old_instance_id}" ]; then + # this may have been applied for a prior version, i.e. upgrading + # from 14.04 to 16.04 + return 0 + + elif [ -z "${new_instance_id}" -o -z "${old_instance_id}" ]; then + cat < /var/lib/cloud/data/instance-id + + # Remove the symlink for the instance + rm /var/lib/cloud/instance + + # Rename the old instance id to the new one + mv /var/lib/cloud/instances/${old_instance_id} \ + /var/lib/cloud/instances/${new_instance_id} + + # Link the old id to the new one, just incase + ln -s /var/lib/cloud/instances/${new_instance_id} \ + /var/lib/cloud/instances/${old_instance_id} + + # Make the active instance the new id + ln -s /var/lib/cloud/instances/${new_instance_id} \ + /var/lib/cloud/instance + fi +fi +} + case "$1" in install|upgrade) # removing obsolete conffiles from the 'ec2-init' package @@ -130,7 +197,7 @@ case "$1" in for f in ${old_confs}; do rm_conffile cloud-init "/etc/init/${f}.conf" done - fi + fi if dpkg --compare-versions "$2" le "0.5.11-0ubuntu1"; then # rename the config entries in sem/ so they're not run again @@ -159,7 +226,11 @@ case "$1" in if [ -e /var/lib/cloud/instance/sem/user-scripts ]; then ln -sf user-scripts /var/lib/cloud/instance/sem/config-scripts-user fi - + + # 0.7.7-bzr1556 introduced new instance ID source for Azure + if dpkg --compare-versions "$2" le "0.7.7~bzr1556-0ubuntu1"; then + azure_apply_new_instance_id_1506187 + fi d=/etc/cloud/ if [ -f "$d/distro.cfg" ] && [ ! -f "$d/cloud.cfg.d/90_dpkg.cfg" ]; then -- cgit v1.2.3