Browse code

Merge "Make changes such that -o nounset runs"

Jenkins authored on 2015/01/18 02:45:29
Showing 26 changed files
... ...
@@ -18,7 +18,7 @@ source $TOP_DIR/functions
18 18
 FILES=$TOP_DIR/files
19 19
 
20 20
 # Load local configuration
21
-source $TOP_DIR/stackrc
21
+source $TOP_DIR/openrc
22 22
 
23 23
 # Get the variables that are set in stack.sh
24 24
 if [[ -r $TOP_DIR/.stackenv ]]; then
... ...
@@ -65,7 +65,7 @@ TUSKARCLIENT_BRANCH=${TUSKARCLIENT_BRANCH:-master}
65 65
 TUSKAR_DIR=$DEST/tuskar
66 66
 TUSKARCLIENT_DIR=$DEST/python-tuskarclient
67 67
 TUSKAR_AUTH_CACHE_DIR=${TUSKAR_AUTH_CACHE_DIR:-/var/cache/tuskar}
68
-TUSKAR_STANDALONE=`trueorfalse False $TUSKAR_STANDALONE`
68
+TUSKAR_STANDALONE=$(trueorfalse False TUSKAR_STANDALONE)
69 69
 TUSKAR_CONF_DIR=/etc/tuskar
70 70
 TUSKAR_CONF=$TUSKAR_CONF_DIR/tuskar.conf
71 71
 TUSKAR_API_HOST=${TUSKAR_API_HOST:-$HOST_IP}
... ...
@@ -353,7 +353,7 @@ function _ping_check_novanet {
353 353
     local boot_timeout=$3
354 354
     local expected=${4:-"True"}
355 355
     local check_command=""
356
-    MULTI_HOST=`trueorfalse False $MULTI_HOST`
356
+    MULTI_HOST=$(trueorfalse False MULTI_HOST)
357 357
     if [[ "$MULTI_HOST" = "True" && "$from_net" = "$PRIVATE_NETWORK_NAME" ]]; then
358 358
         return
359 359
     fi
... ...
@@ -21,7 +21,6 @@
21 21
 #
22 22
 # The following variables are assumed to be defined by certain functions:
23 23
 #
24
-# - ``GIT_DEPTH``
25 24
 # - ``ENABLED_SERVICES``
26 25
 # - ``ERROR_ON_CLONE``
27 26
 # - ``FILES``
... ...
@@ -43,6 +42,8 @@ declare -A GITREPO
43 43
 declare -A GITBRANCH
44 44
 declare -A GITDIR
45 45
 
46
+TRACK_DEPENDS=${TRACK_DEPENDS:-False}
47
+
46 48
 # Config Functions
47 49
 # ================
48 50
 
... ...
@@ -243,7 +244,8 @@ function trueorfalse {
243 243
     local xtrace=$(set +o | grep xtrace)
244 244
     set +o xtrace
245 245
     local default=$1
246
-    local testval=$2
246
+    local literal=$2
247
+    local testval=${!literal}
247 248
 
248 249
     [[ -z "$testval" ]] && { echo "$default"; return; }
249 250
     [[ "0 no No NO false False FALSE" =~ "$testval" ]] && { echo "False"; return; }
... ...
@@ -252,6 +254,14 @@ function trueorfalse {
252 252
     $xtrace
253 253
 }
254 254
 
255
+function isset {
256
+    nounset=$(set +o | grep nounset)
257
+    set +o nounset
258
+    [[ -n "${!1+x}" ]]
259
+    result=$?
260
+    $nounset
261
+    return $result
262
+}
255 263
 
256 264
 # Control Functions
257 265
 # =================
... ...
@@ -381,7 +391,11 @@ function warn {
381 381
 # ``os_UPDATE`` - update: ex. the ``5`` in ``RHEL6.5``
382 382
 # ``os_PACKAGE`` - package type: ``deb`` or ``rpm``
383 383
 # ``os_CODENAME`` - vendor's codename for release: ``snow leopard``, ``trusty``
384
-declare os_VENDOR os_RELEASE os_UPDATE os_PACKAGE os_CODENAME
384
+os_VENDOR=""
385
+os_RELEASE=""
386
+os_UPDATE=""
387
+os_PACKAGE=""
388
+os_CODENAME=""
385 389
 
386 390
 # GetOSVersion
387 391
 function GetOSVersion {
... ...
@@ -577,8 +591,7 @@ function get_release_name_from_branch {
577 577
 # Set global ``RECLONE=yes`` to simulate a clone when dest-dir exists
578 578
 # Set global ``ERROR_ON_CLONE=True`` to abort execution with an error if the git repo
579 579
 # does not exist (default is False, meaning the repo will be cloned).
580
-# Set global ``GIT_DEPTH=<number>`` to limit the history depth of the git clone
581
-# Uses globals ``ERROR_ON_CLONE``, ``OFFLINE``, ``RECLONE``, ``GIT_DEPTH``
580
+# Uses globals ``ERROR_ON_CLONE``, ``OFFLINE``, ``RECLONE``
582 581
 # git_clone remote dest-dir branch
583 582
 function git_clone {
584 583
     local git_remote=$1
... ...
@@ -587,8 +600,7 @@ function git_clone {
587 587
     local orig_dir=$(pwd)
588 588
     local git_clone_flags=""
589 589
 
590
-    RECLONE=$(trueorfalse False $RECLONE)
591
-
590
+    RECLONE=$(trueorfalse False RECLONE)
592 591
     if [[ -n "${GIT_DEPTH}" ]]; then
593 592
         git_clone_flags="$git_clone_flags --depth $GIT_DEPTH"
594 593
     fi
... ...
@@ -995,9 +1007,10 @@ function apt_get {
995 995
     [[ "$(id -u)" = "0" ]] && sudo="env"
996 996
 
997 997
     $xtrace
998
+
998 999
     $sudo DEBIAN_FRONTEND=noninteractive \
999
-        http_proxy=$http_proxy https_proxy=$https_proxy \
1000
-        no_proxy=$no_proxy \
1000
+        http_proxy=${http_proxy:-} https_proxy=${https_proxy:-} \
1001
+        no_proxy=${no_proxy:-} \
1001 1002
         apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
1002 1003
 }
1003 1004
 
... ...
@@ -1016,10 +1029,10 @@ function get_packages {
1016 1016
     set +o xtrace
1017 1017
     local services=$@
1018 1018
     local package_dir=$(_get_package_dir)
1019
-    local file_to_parse
1020
-    local service
1019
+    local file_to_parse=""
1020
+    local service=""
1021 1021
 
1022
-    INSTALL_TESTONLY_PACKAGES=$(trueorfalse False $INSTALL_TESTONLY_PACKAGES)
1022
+    INSTALL_TESTONLY_PACKAGES=$(trueorfalse False INSTALL_TESTONLY_PACKAGES)
1023 1023
 
1024 1024
     if [[ -z "$package_dir" ]]; then
1025 1025
         echo "No package directory supplied"
... ...
@@ -1129,6 +1142,10 @@ function get_packages {
1129 1129
 # Uses globals ``NO_UPDATE_REPOS``, ``REPOS_UPDATED``, ``RETRY_UPDATE``
1130 1130
 # install_package package [package ...]
1131 1131
 function update_package_repo {
1132
+    NO_UPDATE_REPOS=${NO_UPDATE_REPOS:-False}
1133
+    REPOS_UPDATED=${REPOS_UPDATED:-False}
1134
+    RETRY_UPDATE=${RETRY_UPDATE:-False}
1135
+
1132 1136
     if [[ "$NO_UPDATE_REPOS" = "True" ]]; then
1133 1137
         return 0
1134 1138
     fi
... ...
@@ -1338,7 +1355,7 @@ function screen_process {
1338 1338
 
1339 1339
     SCREEN_NAME=${SCREEN_NAME:-stack}
1340 1340
     SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
1341
-    USE_SCREEN=$(trueorfalse True $USE_SCREEN)
1341
+    USE_SCREEN=$(trueorfalse True USE_SCREEN)
1342 1342
 
1343 1343
     # Append the process to the screen rc file
1344 1344
     screen_rc "$name" "$command"
... ...
@@ -1411,7 +1428,7 @@ function screen_stop_service {
1411 1411
 
1412 1412
     SCREEN_NAME=${SCREEN_NAME:-stack}
1413 1413
     SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
1414
-    USE_SCREEN=$(trueorfalse True $USE_SCREEN)
1414
+    USE_SCREEN=$(trueorfalse True USE_SCREEN)
1415 1415
 
1416 1416
     if is_service_enabled $service; then
1417 1417
         # Clean up the screen window
... ...
@@ -1429,7 +1446,7 @@ function stop_process {
1429 1429
     local service=$1
1430 1430
 
1431 1431
     SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
1432
-    USE_SCREEN=$(trueorfalse True $USE_SCREEN)
1432
+    USE_SCREEN=$(trueorfalse True USE_SCREEN)
1433 1433
 
1434 1434
     if is_service_enabled $service; then
1435 1435
         # Kill via pid if we have one available
... ...
@@ -1479,7 +1496,7 @@ function tail_log {
1479 1479
     local name=$1
1480 1480
     local logfile=$2
1481 1481
 
1482
-    USE_SCREEN=$(trueorfalse True $USE_SCREEN)
1482
+    USE_SCREEN=$(trueorfalse True USE_SCREEN)
1483 1483
     if [[ "$USE_SCREEN" = "True" ]]; then
1484 1484
         screen_process "$name" "sudo tail -f $logfile"
1485 1485
     fi
... ...
@@ -1589,7 +1606,8 @@ function get_python_exec_prefix {
1589 1589
 function pip_install {
1590 1590
     local xtrace=$(set +o | grep xtrace)
1591 1591
     set +o xtrace
1592
-    if [[ "$OFFLINE" = "True" || -z "$@" ]]; then
1592
+    local offline=${OFFLINE:-False}
1593
+    if [[ "$offline" == "True" || -z "$@" ]]; then
1593 1594
         $xtrace
1594 1595
         return
1595 1596
     fi
... ...
@@ -1618,20 +1636,20 @@ function pip_install {
1618 1618
 
1619 1619
     $xtrace
1620 1620
     $sudo_pip \
1621
-        http_proxy=$http_proxy \
1622
-        https_proxy=$https_proxy \
1623
-        no_proxy=$no_proxy \
1621
+        http_proxy=${http_proxy:-} \
1622
+        https_proxy=${https_proxy:-} \
1623
+        no_proxy=${no_proxy:-} \
1624 1624
         $cmd_pip install \
1625 1625
         $@
1626 1626
 
1627
-    INSTALL_TESTONLY_PACKAGES=$(trueorfalse False $INSTALL_TESTONLY_PACKAGES)
1627
+    INSTALL_TESTONLY_PACKAGES=$(trueorfalse False INSTALL_TESTONLY_PACKAGES)
1628 1628
     if [[ "$INSTALL_TESTONLY_PACKAGES" == "True" ]]; then
1629 1629
         local test_req="$@/test-requirements.txt"
1630 1630
         if [[ -e "$test_req" ]]; then
1631 1631
             $sudo_pip \
1632
-                http_proxy=$http_proxy \
1633
-                https_proxy=$https_proxy \
1634
-                no_proxy=$no_proxy \
1632
+                http_proxy=${http_proxy:-} \
1633
+                https_proxy=${https_proxy:-} \
1634
+                no_proxy=${no_proxy:-} \
1635 1635
                 $cmd_pip install \
1636 1636
                 -r $test_req
1637 1637
         fi
... ...
@@ -2101,13 +2119,13 @@ function cp_it {
2101 2101
 #     http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
2102 2102
 
2103 2103
 function export_proxy_variables {
2104
-    if [[ -n "$http_proxy" ]]; then
2104
+    if isset http_proxy ; then
2105 2105
         export http_proxy=$http_proxy
2106 2106
     fi
2107
-    if [[ -n "$https_proxy" ]]; then
2107
+    if isset https_proxy ; then
2108 2108
         export https_proxy=$https_proxy
2109 2109
     fi
2110
-    if [[ -n "$no_proxy" ]]; then
2110
+    if isset no_proxy ; then
2111 2111
         export no_proxy=$no_proxy
2112 2112
     fi
2113 2113
 }
... ...
@@ -75,11 +75,14 @@ CEILOMETER_BACKEND=${CEILOMETER_BACKEND:-mysql}
75 75
 CEILOMETER_SERVICE_PROTOCOL=http
76 76
 CEILOMETER_SERVICE_HOST=$SERVICE_HOST
77 77
 CEILOMETER_SERVICE_PORT=${CEILOMETER_SERVICE_PORT:-8777}
78
-CEILOMETER_USE_MOD_WSGI=$(trueorfalse False $CEILOMETER_USE_MOD_WSGI)
78
+CEILOMETER_USE_MOD_WSGI=$(trueorfalse False CEILOMETER_USE_MOD_WSGI)
79 79
 
80 80
 # To enable OSprofiler change value of this variable to "notifications,profiler"
81 81
 CEILOMETER_NOTIFICATION_TOPICS=${CEILOMETER_NOTIFICATION_TOPICS:-notifications}
82 82
 
83
+CEILOMETER_COORDINATION_URL=${CEILOMETER_COORDINATION_URL:-}
84
+CEILOMETER_PIPELINE_INTERVAL=${CEILOMETER_PIPELINE_INTERVAL:-}
85
+
83 86
 # Tell Tempest this project is present
84 87
 TEMPEST_SERVICES+=,ceilometer
85 88
 
... ...
@@ -68,7 +68,7 @@ fi
68 68
 # Maintain this here for backward-compatibility with the old configuration
69 69
 # DEPRECATED: Use CINDER_ENABLED_BACKENDS instead
70 70
 # Support for multi lvm backend configuration (default is no support)
71
-CINDER_MULTI_LVM_BACKEND=$(trueorfalse False $CINDER_MULTI_LVM_BACKEND)
71
+CINDER_MULTI_LVM_BACKEND=$(trueorfalse False CINDER_MULTI_LVM_BACKEND)
72 72
 
73 73
 # Default backends
74 74
 # The backend format is type:name where type is one of the supported backend
... ...
@@ -85,7 +85,7 @@ fi
85 85
 # Should cinder perform secure deletion of volumes?
86 86
 # Defaults to true, can be set to False to avoid this bug when testing:
87 87
 # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1023755
88
-CINDER_SECURE_DELETE=`trueorfalse True $CINDER_SECURE_DELETE`
88
+CINDER_SECURE_DELETE=$(trueorfalse True CINDER_SECURE_DELETE)
89 89
 
90 90
 # Cinder reports allocations back to the scheduler on periodic intervals
91 91
 # it turns out we can get an "out of space" issue when we run tests too
... ...
@@ -33,6 +33,7 @@ set +o xtrace
33 33
 # If ``VOLUME_GROUP`` is set, use it, otherwise we'll build a VG name based
34 34
 # on ``VOLUME_GROUP_NAME`` that includes the backend name
35 35
 # Grenade doesn't use ``VOLUME_GROUP2`` so it is left out
36
+VOLUME_GROUP=${VOLUME_GROUP:-}
36 37
 VOLUME_GROUP_NAME=${VOLUME_GROUP:-${VOLUME_GROUP_NAME:-stack-volumes}}
37 38
 
38 39
 # TODO: resurrect backing device...need to know how to set values
... ...
@@ -23,6 +23,7 @@
23 23
 XTRACE=$(set +o | grep xtrace)
24 24
 set +o xtrace
25 25
 
26
+DATABASE_BACKENDS=""
26 27
 
27 28
 # Register a database backend
28 29
 #
... ...
@@ -30,7 +31,7 @@ set +o xtrace
30 30
 #
31 31
 # This is required to be defined before the specific database scripts are sourced
32 32
 function register_database {
33
-    [ -z "$DATABASE_BACKENDS" ] && DATABASE_BACKENDS=$1 || DATABASE_BACKENDS+=" $1"
33
+    DATABASE_BACKENDS+=" $1"
34 34
 }
35 35
 
36 36
 # Sourcing the database libs sets DATABASE_BACKENDS with the available list
... ...
@@ -14,12 +14,22 @@ set +o xtrace
14 14
 
15 15
 register_database mysql
16 16
 
17
+# Linux distros, thank you for being incredibly consistent
18
+MYSQL=mysql
19
+if is_fedora; then
20
+    if [[ $DISTRO =~ (rhel6) ]]; then
21
+        MYSQL=mysqld
22
+    else
23
+        MYSQL=mariadb
24
+    fi
25
+fi
17 26
 
18 27
 # Functions
19 28
 # ---------
20 29
 
21 30
 # Get rid of everything enough to cleanly change database backends
22 31
 function cleanup_database_mysql {
32
+    stop_service $MYSQL
23 33
     if is_ubuntu; then
24 34
         # Get ruthless with mysql
25 35
         stop_service $MYSQL
... ...
@@ -26,7 +26,7 @@ TIE_DIR=$DEST/tripleo-image-elements
26 26
 # NOTE: Setting DIB_APT_SOURCES assumes you will be building
27 27
 # Debian/Ubuntu based images. Leave unset for other flavors.
28 28
 DIB_APT_SOURCES=${DIB_APT_SOURCES:-""}
29
-DIB_BUILD_OFFLINE=$(trueorfalse False $DIB_BUILD_OFFLINE)
29
+DIB_BUILD_OFFLINE=$(trueorfalse False DIB_BUILD_OFFLINE)
30 30
 DIB_IMAGE_CACHE=$DATA_DIR/diskimage-builder/image-create
31 31
 DIB_PIP_REPO=$DATA_DIR/diskimage-builder/pip-repo
32 32
 DIB_PIP_REPO_PORT=${DIB_PIP_REPO_PORT:-8899}
... ...
@@ -37,13 +37,13 @@ HEAT_DIR=$DEST/heat
37 37
 HEAT_CFNTOOLS_DIR=$DEST/heat-cfntools
38 38
 HEAT_TEMPLATES_REPO_DIR=$DEST/heat-templates
39 39
 HEAT_AUTH_CACHE_DIR=${HEAT_AUTH_CACHE_DIR:-/var/cache/heat}
40
-HEAT_STANDALONE=`trueorfalse False $HEAT_STANDALONE`
41
-HEAT_ENABLE_ADOPT_ABANDON=`trueorfalse False $HEAT_ENABLE_ADOPT_ABANDON`
40
+HEAT_STANDALONE=$(trueorfalse False HEAT_STANDALONE)
41
+HEAT_ENABLE_ADOPT_ABANDON=$(trueorfalse False HEAT_ENABLE_ADOPT_ABANDON)
42 42
 HEAT_CONF_DIR=/etc/heat
43 43
 HEAT_CONF=$HEAT_CONF_DIR/heat.conf
44 44
 HEAT_ENV_DIR=$HEAT_CONF_DIR/environment.d
45 45
 HEAT_TEMPLATES_DIR=$HEAT_CONF_DIR/templates
46
-HEAT_STACK_DOMAIN=`trueorfalse True $HEAT_STACK_DOMAIN`
46
+HEAT_STACK_DOMAIN=$(trueorfalse True HEAT_STACK_DOMAIN)
47 47
 HEAT_API_HOST=${HEAT_API_HOST:-$HOST_IP}
48 48
 HEAT_API_PORT=${HEAT_API_PORT:-8004}
49 49
 
... ...
@@ -173,7 +173,7 @@ function install_horizon {
173 173
     # Apache installation, because we mark it NOPRIME
174 174
     install_apache_wsgi
175 175
 
176
-    git_clone $HORIZON_REPO $HORIZON_DIR $HORIZON_BRANCH $HORIZON_TAG
176
+    git_clone $HORIZON_REPO $HORIZON_DIR $HORIZON_BRANCH
177 177
 }
178 178
 
179 179
 # start_horizon() - Start running processes, including screen
... ...
@@ -60,7 +60,7 @@ IRONIC_IPMIINFO_FILE=${IRONIC_IPMIINFO_FILE:-$IRONIC_DATA_DIR/hardware_info}
60 60
 # Set up defaults for functional / integration testing
61 61
 IRONIC_SCRIPTS_DIR=${IRONIC_SCRIPTS_DIR:-$TOP_DIR/tools/ironic/scripts}
62 62
 IRONIC_TEMPLATES_DIR=${IRONIC_TEMPLATES_DIR:-$TOP_DIR/tools/ironic/templates}
63
-IRONIC_BAREMETAL_BASIC_OPS=$(trueorfalse False $IRONIC_BAREMETAL_BASIC_OPS)
63
+IRONIC_BAREMETAL_BASIC_OPS=$(trueorfalse False IRONIC_BAREMETAL_BASIC_OPS)
64 64
 IRONIC_ENABLED_DRIVERS=${IRONIC_ENABLED_DRIVERS:-fake,pxe_ssh,pxe_ipmitool}
65 65
 IRONIC_SSH_USERNAME=${IRONIC_SSH_USERNAME:-`whoami`}
66 66
 IRONIC_SSH_KEY_DIR=${IRONIC_SSH_KEY_DIR:-$IRONIC_DATA_DIR/ssh_keys}
... ...
@@ -87,7 +87,7 @@ IRONIC_VM_LOG_CONSOLE=${IRONIC_VM_LOG_CONSOLE:-True}
87 87
 IRONIC_VM_LOG_DIR=${IRONIC_VM_LOG_DIR:-$IRONIC_DATA_DIR/logs/}
88 88
 
89 89
 # Use DIB to create deploy ramdisk and kernel.
90
-IRONIC_BUILD_DEPLOY_RAMDISK=`trueorfalse True $IRONIC_BUILD_DEPLOY_RAMDISK`
90
+IRONIC_BUILD_DEPLOY_RAMDISK=$(trueorfalse True IRONIC_BUILD_DEPLOY_RAMDISK)
91 91
 # If not use DIB, these files are used as deploy ramdisk/kernel.
92 92
 # (The value must be a absolute path)
93 93
 IRONIC_DEPLOY_RAMDISK=${IRONIC_DEPLOY_RAMDISK:-}
... ...
@@ -116,7 +116,7 @@ IRONIC_HOSTPORT=${IRONIC_HOSTPORT:-$SERVICE_HOST:$IRONIC_SERVICE_PORT}
116 116
 TEMPEST_SERVICES+=,ironic
117 117
 
118 118
 # Enable iPXE
119
-IRONIC_IPXE_ENABLED=$(trueorfalse False $IRONIC_IPXE_ENABLED)
119
+IRONIC_IPXE_ENABLED=$(trueorfalse False IRONIC_IPXE_ENABLED)
120 120
 IRONIC_HTTP_DIR=${IRONIC_HTTP_DIR:-$IRONIC_DATA_DIR/httpboot}
121 121
 IRONIC_HTTP_SERVER=${IRONIC_HTTP_SERVER:-$HOST_IP}
122 122
 IRONIC_HTTP_PORT=${IRONIC_HTTP_PORT:-8088}
... ...
@@ -71,6 +71,7 @@ KEYSTONE_ASSIGNMENT_BACKEND=${KEYSTONE_ASSIGNMENT_BACKEND:-sql}
71 71
 
72 72
 # Select Keystone's token format
73 73
 # Choose from 'UUID', 'PKI', or 'PKIZ'
74
+KEYSTONE_TOKEN_FORMAT=${KEYSTONE_TOKEN_FORMAT:-}
74 75
 KEYSTONE_TOKEN_FORMAT=$(echo ${KEYSTONE_TOKEN_FORMAT} | tr '[:upper:]' '[:lower:]')
75 76
 
76 77
 # Set Keystone interface configuration
... ...
@@ -106,7 +106,7 @@ GUEST_INTERFACE_DEFAULT=$(ip link \
106 106
 
107 107
 # $NOVA_VNC_ENABLED can be used to forcibly enable vnc configuration.
108 108
 # In multi-node setups allows compute hosts to not run n-novnc.
109
-NOVA_VNC_ENABLED=$(trueorfalse False $NOVA_VNC_ENABLED)
109
+NOVA_VNC_ENABLED=$(trueorfalse False NOVA_VNC_ENABLED)
110 110
 
111 111
 # Get hypervisor configuration
112 112
 # ----------------------------
... ...
@@ -145,11 +145,11 @@ FLAT_INTERFACE=${FLAT_INTERFACE:-$GUEST_INTERFACE_DEFAULT}
145 145
 # ``MULTI_HOST`` is a mode where each compute node runs its own network node.  This
146 146
 # allows network operations and routing for a VM to occur on the server that is
147 147
 # running the VM - removing a SPOF and bandwidth bottleneck.
148
-MULTI_HOST=`trueorfalse False $MULTI_HOST`
148
+MULTI_HOST=$(trueorfalse False MULTI_HOST)
149 149
 
150 150
 # ``NOVA_ALLOW_MOVE_TO_SAME_HOST` can be set to False in multi node devstack,
151 151
 # where there are at least two nova-computes.
152
-NOVA_ALLOW_MOVE_TO_SAME_HOST=`trueorfalse True $NOVA_ALLOW_MOVE_TO_SAME_HOST`
152
+NOVA_ALLOW_MOVE_TO_SAME_HOST=$(trueorfalse True NOVA_ALLOW_MOVE_TO_SAME_HOST)
153 153
 
154 154
 # Test floating pool and range are used for testing.  They are defined
155 155
 # here until the admin APIs can replace nova-manage
... ...
@@ -657,7 +657,7 @@ function install_nova {
657 657
 
658 658
     if is_service_enabled n-novnc; then
659 659
         # a websockets/html5 or flash powered VNC console for vm instances
660
-        NOVNC_FROM_PACKAGE=`trueorfalse False $NOVNC_FROM_PACKAGE`
660
+        NOVNC_FROM_PACKAGE=$(trueorfalse False NOVNC_FROM_PACKAGE)
661 661
         if [ "$NOVNC_FROM_PACKAGE" = "True" ]; then
662 662
             NOVNC_WEB_DIR=/usr/share/novnc
663 663
             install_package novnc
... ...
@@ -669,7 +669,7 @@ function install_nova {
669 669
 
670 670
     if is_service_enabled n-spice; then
671 671
         # a websockets/html5 or flash powered SPICE console for vm instances
672
-        SPICE_FROM_PACKAGE=`trueorfalse True $SPICE_FROM_PACKAGE`
672
+        SPICE_FROM_PACKAGE=$(trueorfalse True SPICE_FROM_PACKAGE)
673 673
         if [ "$SPICE_FROM_PACKAGE" = "True" ]; then
674 674
             SPICE_WEB_DIR=/usr/share/spice-html5
675 675
             install_package spice-html5
... ...
@@ -15,7 +15,7 @@ set +o xtrace
15 15
 # --------
16 16
 
17 17
 # if we should turn on massive libvirt debugging
18
-DEBUG_LIBVIRT=$(trueorfalse False $DEBUG_LIBVIRT)
18
+DEBUG_LIBVIRT=$(trueorfalse False DEBUG_LIBVIRT)
19 19
 
20 20
 # Installs required distro-specific libvirt packages.
21 21
 function install_libvirt {
... ...
@@ -54,7 +54,7 @@ function configure_nova_hypervisor {
54 54
         iniset $NOVA_CONF DEFAULT vnc_enabled "false"
55 55
     fi
56 56
 
57
-    ENABLE_FILE_INJECTION=$(trueorfalse False $ENABLE_FILE_INJECTION)
57
+    ENABLE_FILE_INJECTION=$(trueorfalse False ENABLE_FILE_INJECTION)
58 58
     if [[ "$ENABLE_FILE_INJECTION" = "True" ]] ; then
59 59
         # When libguestfs is available for file injection, enable using
60 60
         # libguestfs to inspect the image and figure out the proper
... ...
@@ -21,6 +21,11 @@
21 21
 XTRACE=$(set +o | grep xtrace)
22 22
 set +o xtrace
23 23
 
24
+RPC_MESSAGING_PROTOCOL=${RPC_MESSAGING_PROTOCOL:-0.9}
25
+
26
+# TODO(sdague): RPC backend selection is super wonky because we treat
27
+# messaging server as a service, which it really isn't for multi host
28
+QPID_HOST=${QPID_HOST:-}
24 29
 
25 30
 # Functions
26 31
 # ---------
... ...
@@ -68,9 +73,6 @@ function check_rpc_backend {
68 68
 function cleanup_rpc_backend {
69 69
     if is_service_enabled rabbit; then
70 70
         # Obliterate rabbitmq-server
71
-        if [ -n "$RABBIT_USERID" ]; then
72
-            sudo rabbitmqctl delete_user "$RABBIT_USERID"
73
-        fi
74 71
         uninstall_package rabbitmq-server
75 72
         sudo killall epmd || sudo killall -9 epmd
76 73
         if is_ubuntu; then
... ...
@@ -82,7 +82,7 @@ SWIFT_EXTRAS_MIDDLEWARE=${SWIFT_EXTRAS_MIDDLEWARE:-formpost staticweb}
82 82
 
83 83
 # Set ``SWIFT_EXTRAS_MIDDLEWARE_LAST`` to extras middlewares that need to be at
84 84
 # the end of the pipeline.
85
-SWIFT_EXTRAS_MIDDLEWARE_LAST=${SWIFT_EXTRAS_MIDDLEWARE_LAST}
85
+SWIFT_EXTRAS_MIDDLEWARE_LAST=${SWIFT_EXTRAS_MIDDLEWARE_LAST:-}
86 86
 
87 87
 # Set ``SWIFT_EXTRAS_MIDDLEWARE_NO_AUTH`` to extras middlewares that need to be at
88 88
 # the beginning of the pipeline, before authentication middlewares.
... ...
@@ -127,7 +127,7 @@ ACCOUNT_PORT_BASE=${ACCOUNT_PORT_BASE:-6012}
127 127
 
128 128
 # Enable tempurl feature
129 129
 SWIFT_ENABLE_TEMPURLS=${SWIFT_ENABLE_TEMPURLS:-False}
130
-SWIFT_TEMPURL_KEY=${SWIFT_TEMPURL_KEY}
130
+SWIFT_TEMPURL_KEY=${SWIFT_TEMPURL_KEY:-}
131 131
 
132 132
 # Tell Tempest this project is present
133 133
 TEMPEST_SERVICES+=,swift
... ...
@@ -75,8 +75,8 @@ TEMPEST_DEFAULT_STORAGE_PROTOCOL="iSCSI"
75 75
 TEMPEST_STORAGE_PROTOCOL=${TEMPEST_STORAGE_PROTOCOL:-$TEMPEST_DEFAULT_STORAGE_PROTOCOL}
76 76
 
77 77
 # Neutron/Network variables
78
-IPV6_ENABLED=$(trueorfalse True $IPV6_ENABLED)
79
-IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True $IPV6_SUBNET_ATTRIBUTES_ENABLED)
78
+IPV6_ENABLED=$(trueorfalse True IPV6_ENABLED)
79
+IPV6_SUBNET_ATTRIBUTES_ENABLED=$(trueorfalse True IPV6_SUBNET_ATTRIBUTES_ENABLED)
80 80
 
81 81
 # Functions
82 82
 # ---------
... ...
@@ -40,6 +40,12 @@ PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
40 40
 # Keep track of the devstack directory
41 41
 TOP_DIR=$(cd $(dirname "$0") && pwd)
42 42
 
43
+# Check for uninitialized variables, a big cause of bugs
44
+NOUNSET=${NOUNSET:-}
45
+if [[ -n "$NOUNSET" ]]; then
46
+    set -o nounset
47
+fi
48
+
43 49
 # Sanity Checks
44 50
 # -------------
45 51
 
... ...
@@ -79,6 +85,9 @@ fi
79 79
 # Prepare the environment
80 80
 # -----------------------
81 81
 
82
+# Initialize variables:
83
+LAST_SPINNER_PID=""
84
+
82 85
 # Import common functions
83 86
 source $TOP_DIR/functions
84 87
 
... ...
@@ -172,12 +181,12 @@ export_proxy_variables
172 172
 disable_negated_services
173 173
 
174 174
 # Look for obsolete stuff
175
-if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then
176
-    echo "FATAL: 'swift' is not supported as a service name"
177
-    echo "FATAL: Use the actual swift service names to enable them as required:"
178
-    echo "FATAL: s-proxy s-object s-container s-account"
179
-    exit 1
180
-fi
175
+# if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then
176
+#     echo "FATAL: 'swift' is not supported as a service name"
177
+#     echo "FATAL: Use the actual swift service names to enable them as required:"
178
+#     echo "FATAL: s-proxy s-object s-container s-account"
179
+#     exit 1
180
+# fi
181 181
 
182 182
 # Configure sudo
183 183
 # --------------
... ...
@@ -311,7 +320,7 @@ fi
311 311
 # -----------------
312 312
 
313 313
 # Set up logging level
314
-VERBOSE=$(trueorfalse True $VERBOSE)
314
+VERBOSE=$(trueorfalse True VERBOSE)
315 315
 
316 316
 # Draw a spinner so the user knows something is happening
317 317
 function spinner {
... ...
@@ -482,47 +491,6 @@ set -o errexit
482 482
 # an error.  It is also useful for following along as the install occurs.
483 483
 set -o xtrace
484 484
 
485
-
486
-# Common Configuration
487
-# --------------------
488
-
489
-# Set ``OFFLINE`` to ``True`` to configure ``stack.sh`` to run cleanly without
490
-# Internet access. ``stack.sh`` must have been previously run with Internet
491
-# access to install prerequisites and fetch repositories.
492
-OFFLINE=`trueorfalse False $OFFLINE`
493
-
494
-# Set ``ERROR_ON_CLONE`` to ``True`` to configure ``stack.sh`` to exit if
495
-# the destination git repository does not exist during the ``git_clone``
496
-# operation.
497
-ERROR_ON_CLONE=`trueorfalse False $ERROR_ON_CLONE`
498
-
499
-# Whether to enable the debug log level in OpenStack services
500
-ENABLE_DEBUG_LOG_LEVEL=`trueorfalse True $ENABLE_DEBUG_LOG_LEVEL`
501
-
502
-# Set fixed and floating range here so we can make sure not to use addresses
503
-# from either range when attempting to guess the IP to use for the host.
504
-# Note that setting FIXED_RANGE may be necessary when running DevStack
505
-# in an OpenStack cloud that uses either of these address ranges internally.
506
-FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
507
-FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
508
-FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
509
-
510
-HOST_IP=$(get_default_host_ip $FIXED_RANGE $FLOATING_RANGE "$HOST_IP_IFACE" "$HOST_IP")
511
-if [ "$HOST_IP" == "" ]; then
512
-    die $LINENO "Could not determine host ip address.  See local.conf for suggestions on setting HOST_IP."
513
-fi
514
-
515
-# Allow the use of an alternate hostname (such as localhost/127.0.0.1) for service endpoints.
516
-SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
517
-
518
-# Configure services to use syslog instead of writing to individual log files
519
-SYSLOG=`trueorfalse False $SYSLOG`
520
-SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
521
-SYSLOG_PORT=${SYSLOG_PORT:-516}
522
-
523
-# Use color for logging output (only available if syslog is not used)
524
-LOG_COLOR=`trueorfalse True $LOG_COLOR`
525
-
526 485
 # Reset the bundle of CA certificates
527 486
 SSL_BUNDLE_FILE="$DATA_DIR/ca-bundle.pem"
528 487
 rm -f $SSL_BUNDLE_FILE
... ...
@@ -535,9 +503,6 @@ source $TOP_DIR/lib/rpc_backend
535 535
 # and the specified rpc backend is available on your platform.
536 536
 check_rpc_backend
537 537
 
538
-# Use native SSL for servers in SSL_ENABLED_SERVICES
539
-USE_SSL=$(trueorfalse False $USE_SSL)
540
-
541 538
 # Service to enable with SSL if USE_SSL is True
542 539
 SSL_ENABLED_SERVICES="key,nova,cinder,glance,s-proxy,neutron"
543 540
 
... ...
@@ -708,7 +673,7 @@ source $TOP_DIR/tools/install_prereqs.sh
708 708
 
709 709
 # Configure an appropriate python environment
710 710
 if [[ "$OFFLINE" != "True" ]]; then
711
-    PYPI_ALTERNATIVE_URL=$PYPI_ALTERNATIVE_URL $TOP_DIR/tools/install_pip.sh
711
+    PYPI_ALTERNATIVE_URL=${PYPI_ALTERNATIVE_URL:-""} $TOP_DIR/tools/install_pip.sh
712 712
 fi
713 713
 
714 714
 TRACK_DEPENDS=${TRACK_DEPENDS:-False}
... ...
@@ -944,13 +909,14 @@ fi
944 944
 # Configure screen
945 945
 # ----------------
946 946
 
947
-USE_SCREEN=$(trueorfalse True $USE_SCREEN)
947
+USE_SCREEN=$(trueorfalse True USE_SCREEN)
948 948
 if [[ "$USE_SCREEN" == "True" ]]; then
949 949
     # Create a new named screen to run processes in
950 950
     screen -d -m -S $SCREEN_NAME -t shell -s /bin/bash
951 951
     sleep 1
952 952
 
953 953
     # Set a reasonable status bar
954
+    SCREEN_HARDSTATUS=${SCREEN_HARDSTATUS-:}
954 955
     if [ -z "$SCREEN_HARDSTATUS" ]; then
955 956
         SCREEN_HARDSTATUS='%{= .} %-Lw%{= .}%> %n%f %t*%{= .}%+Lw%< %-=%{g}(%{d}%H/%l%{g})'
956 957
     fi
... ...
@@ -43,9 +43,17 @@ REGION_NAME=${REGION_NAME:-RegionOne}
43 43
 #  enable_service q-meta
44 44
 #  # Optional, to enable tempest configuration as part of devstack
45 45
 #  enable_service tempest
46
+function isset {
47
+    local nounset=$(set +o | grep nounset)
48
+    set +o nounset
49
+    [[ -n "${!1+x}" ]]
50
+    result=$?
51
+    $nounset
52
+    return $result
53
+}
46 54
 
47 55
 # this allows us to pass ENABLED_SERVICES
48
-if [[ -z "$ENABLED_SERVICES" ]]; then
56
+if ! isset ENABLED_SERVICES ; then
49 57
     # core compute (glance / keystone / nova (+ nova-network))
50 58
     ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,n-sch,n-xvnc,n-cauth
51 59
     # cinder
... ...
@@ -106,7 +114,7 @@ fi
106 106
 
107 107
 # This can be used to turn database query logging on and off
108 108
 # (currently only implemented for MySQL backend)
109
-DATABASE_QUERY_LOGGING=$(trueorfalse True $DATABASE_QUERY_LOGGING)
109
+DATABASE_QUERY_LOGGING=$(trueorfalse True DATABASE_QUERY_LOGGING)
110 110
 
111 111
 # Set a timeout for git operations.  If git is still running when the
112 112
 # timeout expires, the command will be retried up to 3 times.  This is
... ...
@@ -593,7 +601,7 @@ fi
593 593
 
594 594
 # Staging Area for New Images, have them here for at least 24hrs for nodepool
595 595
 # to cache them otherwise the failure rates in the gate are too high
596
-PRECACHE_IMAGES=$(trueorfalse False $PRECACHE_IMAGES)
596
+PRECACHE_IMAGES=$(trueorfalse False PRECACHE_IMAGES)
597 597
 if [[ "$PRECACHE_IMAGES" == "True" ]]; then
598 598
     # staging in update for nodepool
599 599
     IMAGE_URL="https://download.fedoraproject.org/pub/alt/openstack/20/x86_64/Fedora-x86_64-20-20140618-sda.qcow2"
... ...
@@ -646,6 +654,54 @@ SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
646 646
 # till we get to the point we need to handle this automatically
647 647
 YUM=${YUM:-yum}
648 648
 
649
+# Common Configuration
650
+# --------------------
651
+
652
+# Set ``OFFLINE`` to ``True`` to configure ``stack.sh`` to run cleanly without
653
+# Internet access. ``stack.sh`` must have been previously run with Internet
654
+# access to install prerequisites and fetch repositories.
655
+OFFLINE=$(trueorfalse False OFFLINE)
656
+
657
+# Set ``ERROR_ON_CLONE`` to ``True`` to configure ``stack.sh`` to exit if
658
+# the destination git repository does not exist during the ``git_clone``
659
+# operation.
660
+ERROR_ON_CLONE=$(trueorfalse False ERROR_ON_CLONE)
661
+
662
+# Whether to enable the debug log level in OpenStack services
663
+ENABLE_DEBUG_LOG_LEVEL=$(trueorfalse True ENABLE_DEBUG_LOG_LEVEL)
664
+
665
+# Set fixed and floating range here so we can make sure not to use addresses
666
+# from either range when attempting to guess the IP to use for the host.
667
+# Note that setting FIXED_RANGE may be necessary when running DevStack
668
+# in an OpenStack cloud that uses either of these address ranges internally.
669
+FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
670
+FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
671
+FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
672
+HOST_IP_IFACE=${HOST_IP_IFACE:-}
673
+HOST_IP=${HOST_IP:-}
674
+
675
+HOST_IP=$(get_default_host_ip $FIXED_RANGE $FLOATING_RANGE "$HOST_IP_IFACE" "$HOST_IP")
676
+if [ "$HOST_IP" == "" ]; then
677
+    die $LINENO "Could not determine host ip address.  See local.conf for suggestions on setting HOST_IP."
678
+fi
679
+
680
+# Allow the use of an alternate hostname (such as localhost/127.0.0.1) for service endpoints.
681
+SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
682
+
683
+# Configure services to use syslog instead of writing to individual log files
684
+SYSLOG=$(trueorfalse False SYSLOG)
685
+SYSLOG_HOST=${SYSLOG_HOST:-$HOST_IP}
686
+SYSLOG_PORT=${SYSLOG_PORT:-516}
687
+
688
+# Use color for logging output (only available if syslog is not used)
689
+LOG_COLOR=$(trueorfalse True LOG_COLOR)
690
+
691
+# Set global ``GIT_DEPTH=<number>`` to limit the history depth of the git clone
692
+GIT_DEPTH=${GIT_DEPTH:-1}
693
+
694
+# Use native SSL for servers in SSL_ENABLED_SERVICES
695
+USE_SSL=$(trueorfalse False USE_SSL)
696
+
649 697
 # Following entries need to be last items in file
650 698
 
651 699
 # Local variables:
652 700
new file mode 100755
... ...
@@ -0,0 +1,34 @@
0
+#!/usr/bin/env bash
1
+
2
+# Tests for DevStack meta-config functions
3
+
4
+TOP=$(cd $(dirname "$0")/.. && pwd)
5
+
6
+# Import common functions
7
+source $TOP/functions
8
+source $TOP/tests/unittest.sh
9
+
10
+function test_truefalse {
11
+    local one=1
12
+    local captrue=True
13
+    local lowtrue=true
14
+    local abrevtrue=t
15
+    local zero=0
16
+    local capfalse=False
17
+    local lowfalse=false
18
+    local abrevfalse=f
19
+    for against in True False; do
20
+        for name in one captrue lowtrue abrevtrue; do
21
+            assert_equal "True" $(trueorfalse $against $name) "\$(trueorfalse $against $name)"
22
+        done
23
+    done
24
+    for against in True False; do
25
+        for name in zero capfalse lowfalse abrevfalse; do
26
+            assert_equal "False" $(trueorfalse $against $name) "\$(trueorfalse $against $name)"
27
+        done
28
+    done
29
+}
30
+
31
+test_truefalse
32
+
33
+report_results
0 34
new file mode 100644
... ...
@@ -0,0 +1,39 @@
0
+#!/usr/bin/env bash
1
+
2
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
3
+# not use this file except in compliance with the License. You may obtain
4
+# a copy of the License at
5
+#
6
+#      http://www.apache.org/licenses/LICENSE-2.0
7
+#
8
+# Unless required by applicable law or agreed to in writing, software
9
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11
+# License for the specific language governing permissions and limitations
12
+# under the License.
13
+
14
+# we always start with no errors
15
+ERROR=0
16
+FAILED_FUNCS=""
17
+
18
+function assert_equal {
19
+    local lineno=`caller 0 | awk '{print $1}'`
20
+    local function=`caller 0 | awk '{print $2}'`
21
+    local msg=$3
22
+    if [[ "$1" != "$2" ]]; then
23
+        FAILED_FUNCS+="$function:L$lineno\n"
24
+        echo "ERROR: $1 != $2 in $function:L$lineno!"
25
+        echo "  $msg"
26
+        ERROR=1
27
+    else
28
+        echo "$function:L$lineno - ok"
29
+    fi
30
+}
31
+
32
+function report_results {
33
+    if [[ $ERROR -eq 1 ]]; then
34
+        echo "Tests FAILED"
35
+        echo $FAILED_FUNCS
36
+        exit 1
37
+    fi
38
+}
... ...
@@ -8,9 +8,15 @@
8 8
 #
9 9
 # -f        Force an install run now
10 10
 
11
-if [[ -n "$1" &&  "$1" = "-f" ]]; then
12
-    FORCE_PREREQ=1
13
-fi
11
+FORCE_PREREQ=0
12
+
13
+while getopts ":f" opt; do
14
+    case $opt in
15
+        f)
16
+            FORCE_PREREQ=1
17
+            ;;
18
+    esac
19
+done
14 20
 
15 21
 # If TOP_DIR is set we're being sourced rather than running stand-alone
16 22
 # or in a sub-shell
... ...
@@ -6,11 +6,22 @@
6 6
 # mysql and rabbit are left running as OpenStack code refreshes
7 7
 # do not require them to be restarted.
8 8
 #
9
-# Stop all processes by setting ``UNSTACK_ALL`` or specifying ``--all``
9
+# Stop all processes by setting ``UNSTACK_ALL`` or specifying ``-a``
10 10
 # on the command line
11 11
 
12
+UNSTACK_ALL=""
13
+
14
+while getopts ":a" opt; do
15
+    case $opt in
16
+        a)
17
+            UNSTACK_ALL=""
18
+            ;;
19
+    esac
20
+done
21
+
12 22
 # Keep track of the current devstack directory.
13 23
 TOP_DIR=$(cd $(dirname "$0") && pwd)
24
+FILES=$TOP_DIR/files
14 25
 
15 26
 # Import common functions
16 27
 source $TOP_DIR/functions
... ...
@@ -19,7 +30,7 @@ source $TOP_DIR/functions
19 19
 source $TOP_DIR/lib/database
20 20
 
21 21
 # Load local configuration
22
-source $TOP_DIR/stackrc
22
+source $TOP_DIR/openrc
23 23
 
24 24
 # Destination path for service data
25 25
 DATA_DIR=${DATA_DIR:-${DEST}/data}
... ...
@@ -72,10 +83,6 @@ load_plugin_settings
72 72
 # ``os_RELEASE``, ``os_UPDATE``, ``os_PACKAGE``, ``os_CODENAME``
73 73
 GetOSVersion
74 74
 
75
-if [[ "$1" == "--all" ]]; then
76
-    UNSTACK_ALL=${UNSTACK_ALL:-1}
77
-fi
78
-
79 75
 # Run extras
80 76
 # ==========
81 77