Periodic formatting cleanup
This is the semi-irregular comment and docs cleanup.
No functional changes should be here although some code is moved in a
small attempt to sort functions and get things where they need to be.
Change-Id: Ib4a3e2590c6fbd016c391acc7aef6421e91c0dca
diff --git a/functions b/functions
index dfde7dc..1257024 100644
--- a/functions
+++ b/functions
@@ -200,6 +200,7 @@
echo "$pkg_dir"
}
+
# get_packages() collects a list of package names of any type from the
# prerequisite files in ``files/{apts|rpms}``. The list is intended
# to be passed to a package installer such as apt or yum.
@@ -390,42 +391,6 @@
export os_VENDOR os_RELEASE os_UPDATE os_PACKAGE os_CODENAME
}
-# git update using reference as a branch.
-# git_update_branch ref
-function git_update_branch() {
-
- GIT_BRANCH=$1
-
- git checkout -f origin/$GIT_BRANCH
- # a local branch might not exist
- git branch -D $GIT_BRANCH || true
- git checkout -b $GIT_BRANCH
-}
-
-
-# git update using reference as a tag. Be careful editing source at that repo
-# as working copy will be in a detached mode
-# git_update_tag ref
-function git_update_tag() {
-
- GIT_TAG=$1
-
- git tag -d $GIT_TAG
- # fetching given tag only
- git fetch origin tag $GIT_TAG
- git checkout -f $GIT_TAG
-}
-
-
-# git update using reference as a branch.
-# git_update_remote_branch ref
-function git_update_remote_branch() {
-
- GIT_BRANCH=$1
-
- git checkout -b $GIT_BRANCH -t origin/$GIT_BRANCH
-}
-
# Translate the OS version values into common nomenclature
# Sets ``DISTRO`` from the ``os_*`` values
@@ -457,19 +422,8 @@
}
-# Determine if current distribution is an Ubuntu-based distribution.
-# It will also detect non-Ubuntu but Debian-based distros; this is not an issue
-# since Debian and Ubuntu should be compatible.
-# is_ubuntu
-function is_ubuntu {
- if [[ -z "$os_PACKAGE" ]]; then
- GetOSVersion
- fi
- [ "$os_PACKAGE" = "deb" ]
-}
-
# Determine if current distribution is a Fedora-based distribution
-# (Fedora, RHEL, CentOS).
+# (Fedora, RHEL, CentOS, etc).
# is_fedora
function is_fedora {
if [[ -z "$os_VENDOR" ]]; then
@@ -479,6 +433,7 @@
[ "$os_VENDOR" = "Fedora" ] || [ "$os_VENDOR" = "Red Hat" ] || [ "$os_VENDOR" = "CentOS" ]
}
+
# Determine if current distribution is a SUSE-based distribution
# (openSUSE, SLE).
# is_suse
@@ -491,6 +446,17 @@
}
+# Determine if current distribution is an Ubuntu-based distribution
+# It will also detect non-Ubuntu but Debian-based distros
+# is_ubuntu
+function is_ubuntu {
+ if [[ -z "$os_PACKAGE" ]]; then
+ GetOSVersion
+ fi
+ [ "$os_PACKAGE" = "deb" ]
+}
+
+
# Exit after outputting a message about the distribution not being supported.
# exit_distro_not_supported [optional-string-telling-what-is-missing]
function exit_distro_not_supported {
@@ -565,6 +531,43 @@
}
+# git update using reference as a branch.
+# git_update_branch ref
+function git_update_branch() {
+
+ GIT_BRANCH=$1
+
+ git checkout -f origin/$GIT_BRANCH
+ # a local branch might not exist
+ git branch -D $GIT_BRANCH || true
+ git checkout -b $GIT_BRANCH
+}
+
+
+# git update using reference as a branch.
+# git_update_remote_branch ref
+function git_update_remote_branch() {
+
+ GIT_BRANCH=$1
+
+ git checkout -b $GIT_BRANCH -t origin/$GIT_BRANCH
+}
+
+
+# git update using reference as a tag. Be careful editing source at that repo
+# as working copy will be in a detached mode
+# git_update_tag ref
+function git_update_tag() {
+
+ GIT_TAG=$1
+
+ git tag -d $GIT_TAG
+ # fetching given tag only
+ git fetch origin tag $GIT_TAG
+ git checkout -f $GIT_TAG
+}
+
+
# Comment an option in an INI file
# inicomment config-file section option
function inicomment() {
@@ -1020,6 +1023,7 @@
fi
}
+
# Helper to remove the *.failure files under $SERVICE_DIR/$SCREEN_NAME
# This is used for service_check when all the screen_it are called finished
# init_service_check
@@ -1034,6 +1038,7 @@
rm -f "$SERVICE_DIR/$SCREEN_NAME"/*.failure
}
+
# Helper to get the status of each running service
# service_check
function service_check() {
@@ -1062,6 +1067,7 @@
fi
}
+
# ``pip install`` the dependencies of the package before ``setup.py develop``
# so pip and not distutils processes the dependency chain
# Uses globals ``TRACK_DEPENDES``, ``*_proxy`
@@ -1242,6 +1248,7 @@
fi
}
+
# Set the database backend to use
# When called from stackrc/localrc DATABASE_BACKENDS has not been
# initialized yet, just save the configuration selection and call back later
@@ -1259,6 +1266,7 @@
fi
}
+
# Toggle enable/disable_service for services that must run exclusive of each other
# $1 The name of a variable containing a space-separated list of services
# $2 The name of a variable in which to store the enabled service's name
@@ -1275,6 +1283,7 @@
return 0
}
+
# Wait for an HTTP server to start answering requests
# wait_for_service timeout url
function wait_for_service() {
@@ -1283,6 +1292,7 @@
timeout $timeout sh -c "while ! http_proxy= https_proxy= curl -s $url >/dev/null; do sleep 1; done"
}
+
# Wrapper for ``yum`` to set proxy environment variables
# Uses globals ``OFFLINE``, ``*_proxy`
# yum_install package [package ...]
@@ -1295,8 +1305,21 @@
yum install -y "$@"
}
+
+# zypper wrapper to set arguments correctly
+# zypper_install package [package ...]
+function zypper_install() {
+ [[ "$OFFLINE" = "True" ]] && return
+ local sudo="sudo"
+ [[ "$(id -u)" = "0" ]] && sudo="env"
+ $sudo http_proxy=$http_proxy https_proxy=$https_proxy \
+ zypper --non-interactive install --auto-agree-with-licenses "$@"
+}
+
+
# ping check
# Uses globals ``ENABLED_SERVICES``
+# ping_check from-net ip boot-timeout expected
function ping_check() {
if is_service_enabled quantum; then
_ping_check_quantum "$1" $2 $3 $4
@@ -1333,8 +1356,10 @@
fi
}
+
# ssh check
+# ssh_check net-name key-file floating-ip default-user active-timeout
function ssh_check() {
if is_service_enabled quantum; then
_ssh_check_quantum "$1" $2 $3 $4 $5
@@ -1356,17 +1381,6 @@
}
-# zypper wrapper to set arguments correctly
-# zypper_install package [package ...]
-function zypper_install() {
- [[ "$OFFLINE" = "True" ]] && return
- local sudo="sudo"
- [[ "$(id -u)" = "0" ]] && sudo="env"
- $sudo http_proxy=$http_proxy https_proxy=$https_proxy \
- zypper --non-interactive install --auto-agree-with-licenses "$@"
-}
-
-
# Add a user to a group.
# add_user_to_group user group
function add_user_to_group() {
@@ -1396,6 +1410,7 @@
fi
}
+
# Get the location of the $module-rootwrap executables, where module is cinder
# or nova.
# get_rootwrap_location module
@@ -1405,6 +1420,7 @@
echo "$(get_python_exec_prefix)/$module-rootwrap"
}
+
# Get the path to the pip command.
# get_pip_command
function get_pip_command() {
@@ -1419,6 +1435,7 @@
fi
}
+
# Path permissions sanity check
# check_path_perm_sanity path
function check_path_perm_sanity() {
@@ -1448,6 +1465,7 @@
done
}
+
# Restore xtrace
$XTRACE