Browse code

Minor fixes for bashate trunk

We don't have a new bashate release yet, but this fixes some minor
issues when used with bashate trunk.

The only two things triggered are stricter checking of assignment in
local declartions (catches quotes) and one instance of evaluating
arithmetic result in tools/xen/functions.

Therefore, hopefully, this change has no effect!

Change-Id: I3fd5d55236e90c2f2c25243af87adaf0c1b763e2

Ian Wienand authored on 2016/02/16 12:50:53
Showing 6 changed files
... ...
@@ -94,12 +94,14 @@ function upload_image {
94 94
         local path_len
95 95
 
96 96
         # vmdk adapter type
97
-        local vmdk_adapter_type="$(head -25 $image | { grep -a -F -m 1 'ddb.adapterType =' $image || true; })"
97
+        local vmdk_adapter_type
98
+        vmdk_adapter_type="$(head -25 $image | { grep -a -F -m 1 'ddb.adapterType =' $image || true; })"
98 99
         vmdk_adapter_type="${vmdk_adapter_type#*\"}"
99 100
         vmdk_adapter_type="${vmdk_adapter_type%?}"
100 101
 
101 102
         # vmdk disk type
102
-        local vmdk_create_type="$(head -25 $image | { grep -a -F -m 1 'createType=' $image || true; })"
103
+        local vmdk_create_type
104
+        vmdk_create_type="$(head -25 $image | { grep -a -F -m 1 'createType=' $image || true; })"
103 105
         vmdk_create_type="${vmdk_create_type#*\"}"
104 106
         vmdk_create_type="${vmdk_create_type%\"*}"
105 107
 
... ...
@@ -109,7 +111,8 @@ function upload_image {
109 109
             vmdk_disktype="sparse"
110 110
         elif [[ "$vmdk_create_type" = "monolithicFlat" || "$vmdk_create_type" = "vmfs" ]]; then
111 111
             # Attempt to retrieve the ``*-flat.vmdk``
112
-            local flat_fname="$(head -25 $image | { grep -G 'RW\|RDONLY [0-9]+ FLAT\|VMFS' $image || true; })"
112
+            local flat_fname
113
+            flat_fname="$(head -25 $image | { grep -G 'RW\|RDONLY [0-9]+ FLAT\|VMFS' $image || true; })"
113 114
             flat_fname="${flat_fname#*\"}"
114 115
             flat_fname="${flat_fname%?}"
115 116
             if [[ -z "$flat_fname" ]]; then
... ...
@@ -407,8 +410,10 @@ function ping_check {
407 407
 function get_instance_ip {
408 408
     local vm_id=$1
409 409
     local network_name=$2
410
-    local nova_result="$(nova show $vm_id)"
410
+    local nova_result
411 411
     local ip
412
+
413
+    nova_result="$(nova show $vm_id)"
412 414
     ip=$(echo "$nova_result" | grep "$network_name" | get_field 2)
413 415
     if [[ $ip = "" ]];then
414 416
         echo "$nova_result"
... ...
@@ -1211,7 +1211,7 @@ function get_plugin_packages {
1211 1211
     local files_to_parse=""
1212 1212
     local package_dir=""
1213 1213
     for plugin in ${DEVSTACK_PLUGINS//,/ }; do
1214
-        local package_dir="$(_get_package_dir ${GITDIR[$plugin]}/devstack/files)"
1214
+        package_dir="$(_get_package_dir ${GITDIR[$plugin]}/devstack/files)"
1215 1215
         files_to_parse+=" $package_dir/$plugin"
1216 1216
     done
1217 1217
     echo "$(_parse_package_files $files_to_parse)"
... ...
@@ -30,7 +30,8 @@ function iniadd {
30 30
     local option=$3
31 31
     shift 3
32 32
 
33
-    local values="$(iniget_multiline $file $section $option) $@"
33
+    local values
34
+    values="$(iniget_multiline $file $section $option) $@"
34 35
     iniset_multiline $sudo $file $section $option $values
35 36
     $xtrace
36 37
 }
... ...
@@ -689,9 +689,12 @@ function install_neutron_agent_packages {
689 689
 
690 690
 # Start running processes, including screen
691 691
 function start_neutron_service_and_check {
692
-    local cfg_file_options="$(determine_config_files neutron-server)"
693 692
     local service_port=$Q_PORT
694 693
     local service_protocol=$Q_PROTOCOL
694
+    local cfg_file_options
695
+
696
+    cfg_file_options="$(determine_config_files neutron-server)"
697
+
695 698
     if is_service_enabled tls-proxy; then
696 699
         service_port=$Q_PORT_INT
697 700
         service_protocol="http"
... ...
@@ -23,9 +23,10 @@ function create_directory_for_kernels {
23 23
     if [ -d "/boot/guest" ]; then
24 24
         echo "INFO: /boot/guest directory already exists, using that" >&2
25 25
     else
26
-        local LOCALPATH="$(get_local_sr_path)/os-guest-kernels"
27
-        mkdir -p $LOCALPATH
28
-        ln -s $LOCALPATH /boot/guest
26
+        local local_path
27
+        local_path="$(get_local_sr_path)/os-guest-kernels"
28
+        mkdir -p $local_path
29
+        ln -s $local_path /boot/guest
29 30
     fi
30 31
 }
31 32
 
... ...
@@ -33,9 +34,10 @@ function create_directory_for_images {
33 33
     if [ -d "/images" ]; then
34 34
         echo "INFO: /images directory already exists, using that" >&2
35 35
     else
36
-        local LOCALPATH="$(get_local_sr_path)/os-images"
37
-        mkdir -p $LOCALPATH
38
-        ln -s $LOCALPATH /images
36
+        local local_path
37
+        local_path="$(get_local_sr_path)/os-images"
38
+        mkdir -p $local_path
39
+        ln -s $local_path /images
39 40
     fi
40 41
 }
41 42
 
... ...
@@ -73,7 +75,7 @@ function find_ip_by_name {
73 73
 
74 74
         if [ -z "$ipaddress" ]; then
75 75
             sleep $period
76
-            ((i++))
76
+            i=$((i+1))
77 77
         else
78 78
             echo $ipaddress
79 79
             break
... ...
@@ -8,6 +8,9 @@ usedevelop = False
8 8
 install_command = pip install {opts} {packages}
9 9
 
10 10
 [testenv:bashate]
11
+# if you want to test out some changes you have made to bashate
12
+# against devstack, just set BASHATE_INSTALL_PATH=/path/... to your
13
+# modified bashate tree
11 14
 deps =
12 15
    {env:BASHATE_INSTALL_PATH:bashate==0.3.2}
13 16
 whitelist_externals = bash