Add guest image customization to DevStack plugin.

CI jobs for this plugin use DevStack to install and configure
OpenStack and to upload guest images to be used for tests.

This change allow to customize guest images just before
being sent to image service with the purpose of installing
new packages (like socat), configuring N network devices, etc.

This change has been created because for testing multicast
socat is required, but it was designed with the idea
of being used to allow further guest images customizations.

Change-Id: I88491dbb65031fe3743d1c3d27c38a57b5511794
diff --git a/tools/customize_ubuntu_image b/tools/customize_ubuntu_image
index 9c3fd07..3697265 100755
--- a/tools/customize_ubuntu_image
+++ b/tools/customize_ubuntu_image
@@ -31,8 +31,11 @@
     chown _apt.root -fR "${apt_user_folders[@]}"
 
     # Install desired packages to Ubuntu guest image
-    apt-get update -y
-    apt-get install -y "${INSTALL_GUEST_PACKAGES[@]}"
+    (
+        DEBIAN_FRONTEND=noninteractive
+        apt-get update -y
+        apt-get install -y "${INSTALL_GUEST_PACKAGES[@]}"
+    )
 }
 
 function main {
@@ -64,9 +67,12 @@
     bind_dir "${temp_dir}/tmp" "${mount_dir}/var/tmp"
     bind_dir "${temp_dir}/apt" "${mount_dir}/var/lib/apt"
 
-    # Replace /etc/resolv.conf symlink to use the same DNS as this host
-    sudo rm -f "${mount_dir}/etc/resolv.conf"
-    sudo cp /etc/resolv.conf "${mount_dir}/etc/resolv.conf"
+    # Temporarly replace /etc/resolv.conf symlink to use the same DNS as this
+    # host
+    local resolv_file=${mount_dir}/etc/resolv.conf
+    sudo mv -f "${resolv_file}" "${resolv_file}.orig"
+    sudo cp /etc/resolv.conf "${resolv_file}"
+    add_cleanup sudo mv -f "${resolv_file}.orig" "${resolv_file}"
 
     # Makesure /etc/fstab exists and it is readable because it is required by
     # /sbin/dhclient-script