Browse code

Put devstack-version info into separate file

As a follow on to I4c269a7f3d63ee9a976e7c3636fc3e5e8dab9ae3; the
quoting gets tricky when putting arbitrary command-substitution
strings into saved echo-able strings. As they say, "the only winning
move is not to play" :)

An alternative proposal is to not write this into a script but just
dump info into a file. To my mind, this has several advantages --
avoid getting involved in quoting, not dropping a script into the
global environment -- it's just as easy to "cat" -- and the plain-text
file can be collected as an artifact during log collection (also moved
git commit line to separate line for easier parsing during log search,
etc).

Change-Id: Ic7391dd087657c0daf74046e4a052c53f4eb6e1a

Ian Wienand authored on 2017/06/30 11:29:19
Showing 2 changed files
... ...
@@ -750,19 +750,16 @@ function get_random_port {
750 750
     echo $port
751 751
 }
752 752
 
753
-
753
+# Save some state information
754
+#
755
+# Write out various useful state information to /etc/devstack-version
754 756
 function write_devstack_version {
755
-    pushd $TOP_DIR
756
-    local git_version=""
757
-    git_version=$(git log --format="%H %ci" -1)
758 757
     cat - > /tmp/devstack-version <<EOF
759
-#!/bin/bash
760
-
761
-echo "DevStack Version: ${DEVSTACK_SERIES} - ${git_version}"
762
-echo "OS Version: ${os_VENDOR} ${os_RELEASE} ${os_CODENAME}"
763
-
758
+DevStack Version: ${DEVSTACK_SERIES}
759
+Change: $(git log --format="%H %s %ci" -1)
760
+OS Version: ${os_VENDOR} ${os_RELEASE} ${os_CODENAME}
764 761
 EOF
765
-    sudo install -m 755 /tmp/devstack-version /usr/local/bin/devstack-version
762
+    sudo install -m 644 /tmp/devstack-version /etc/devstack-version
766 763
     rm /tmp/devstack-version
767 764
 }
768 765
 
... ...
@@ -216,7 +216,7 @@ if [[ ! -r $TOP_DIR/stackrc ]]; then
216 216
 fi
217 217
 source $TOP_DIR/stackrc
218 218
 
219
-# this installs a devstack-version script to make it easy to report the version back
219
+# write /etc/devstack-version
220 220
 write_devstack_version
221 221
 
222 222
 # Warn users who aren't on an explicitly supported distro, but allow them to
... ...
@@ -1538,8 +1538,8 @@ if [[ "$USE_SYSTEMD" == "True" ]]; then
1538 1538
     echo
1539 1539
 fi
1540 1540
 
1541
-# devstack version
1542
-devstack-version
1541
+# Useful info on current state
1542
+cat /etc/devstack-version
1543 1543
 echo
1544 1544
 
1545 1545
 # Indicate how long this took to run (bash maintained variable ``SECONDS``)