Add partial openSUSE/SLE support
Note that this is the first part of the support. A second part involves
dealing with the package names.
Among the changes:
- add several functions to determine some distro-specific behavior (how
to call usermod, if some features are available on the distro, etc.)
- correctly detect openSUSE and SLE in GetOSVersion, and set DISTRO
accordingly
- new is_suse() function to check if running on a SUSE-based distro
- use zypper to install packages
- adapt apache virtual host configuration for openSUSE
- some simple fixes (path to pip, mysql service name)
Change-Id: Id2f7c9e18a1c4a7b7cea262ea7959d183e4b0cf0
diff --git a/functions b/functions
index 8ab3eef..16664d6 100644
--- a/functions
+++ b/functions
@@ -223,6 +223,12 @@
os_UPDATE=""
if [[ "Debian,Ubuntu" =~ $os_VENDOR ]]; then
os_PACKAGE="deb"
+ elif [[ "SUSE LINUX" =~ $os_VENDOR ]]; then
+ lsb_release -d -s | grep -q openSUSE
+ if [[ $? -eq 0 ]]; then
+ os_VENDOR="openSUSE"
+ fi
+ os_PACKAGE="rpm"
else
os_PACKAGE="rpm"
fi
@@ -246,6 +252,23 @@
os_VENDOR=""
done
os_PACKAGE="rpm"
+ elif [[ -r /etc/SuSE-release ]]; then
+ for r in openSUSE "SUSE Linux"; do
+ if [[ "$r" = "SUSE Linux" ]]; then
+ os_VENDOR="SUSE LINUX"
+ else
+ os_VENDOR=$r
+ fi
+
+ if [[ -n "`grep \"$r\" /etc/SuSE-release`" ]]; then
+ os_CODENAME=`grep "CODENAME = " /etc/SuSE-release | sed 's:.* = ::g'`
+ os_RELEASE=`grep "VERSION = " /etc/SuSE-release | sed 's:.* = ::g'`
+ os_UPDATE=`grep "PATCHLEVEL = " /etc/SuSE-release | sed 's:.* = ::g'`
+ break
+ fi
+ os_VENDOR=""
+ done
+ os_PACKAGE="rpm"
fi
export os_VENDOR os_RELEASE os_UPDATE os_PACKAGE os_CODENAME
}
@@ -297,6 +320,15 @@
elif [[ "$os_VENDOR" =~ (Fedora) ]]; then
# For Fedora, just use 'f' and the release
DISTRO="f$os_RELEASE"
+ elif [[ "$os_VENDOR" =~ (openSUSE) ]]; then
+ DISTRO="opensuse-$os_RELEASE"
+ elif [[ "$os_VENDOR" =~ (SUSE LINUX) ]]; then
+ # For SLE, also use the service pack
+ if [[ -z "$os_UPDATE" ]]; then
+ DISTRO="sle${os_RELEASE}"
+ else
+ DISTRO="sle${os_RELEASE}sp${os_UPDATE}"
+ fi
else
# Catch-all for now is Vendor + Release + Update
DISTRO="$os_VENDOR-$os_RELEASE.$os_UPDATE"
@@ -305,6 +337,19 @@
}
+# Determine if current distribution is a SUSE-based distribution
+# (openSUSE, SLE).
+# is_suse
+function is_suse {
+ if [[ -z "$os_VENDOR" ]]; then
+ GetOSVersion
+ fi
+
+ [[ "$os_VENDOR" = "openSUSE" || "$os_VENDOR" = "SUSE LINUX" ]]
+ return $?
+}
+
+
# git clone only if directory doesn't exist already. Since ``DEST`` might not
# be owned by the installation user, we create the directory and change the
# ownership to the proper user.
@@ -542,7 +587,11 @@
apt_get install "$@"
else
- yum_install "$@"
+ if is_suse; then
+ zypper_install "$@"
+ else
+ yum_install "$@"
+ fi
fi
}
@@ -593,7 +642,7 @@
SUDO_PIP="env"
else
SUDO_PIP="sudo"
- if [[ "$os_PACKAGE" = "deb" ]]; then
+ if [[ "$os_PACKAGE" = "deb" || is_suse ]]; then
CMD_PIP=/usr/bin/pip
else
CMD_PIP=/usr/bin/pip-python
@@ -946,6 +995,68 @@
fi
}
+
+# 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() {
+ local user=$1
+ local group=$2
+
+ if [[ -z "$os_VENDOR" ]]; then
+ GetOSVersion
+ fi
+
+ # SLE11 and openSUSE 12.2 don't have the usual usermod
+ if ! is_suse || [[ "$os_VENDOR" = "openSUSE" && "$os_RELEASE" != "12.2" ]]; then
+ sudo usermod -a -G "$group" "$user"
+ else
+ sudo usermod -A "$group" "$user"
+ fi
+}
+
+
+# Get the location of the $module-rootwrap executables, where module is cinder
+# or nova.
+# get_rootwrap_location module
+function get_rootwrap_location() {
+ local module=$1
+
+ if [[ -z "$os_PACKAGE" ]]; then
+ GetOSVersion
+ fi
+
+ if [[ "$os_PACKAGE" = "deb" || is_suse ]]; then
+ echo "/usr/local/bin/$module-rootwrap"
+ else
+ echo "/usr/bin/$module-rootwrap"
+ fi
+}
+
+
+# Check if qpid can be used on the current distro.
+# qpid_is_supported
+function qpid_is_supported() {
+ if [[ -z "$DISTRO" ]]; then
+ GetDistro
+ fi
+
+ # Qpid was introduced to Ubuntu in precise, disallow it on oneiric; it is
+ # not in openSUSE either right now.
+ [[ "$DISTRO" = "oneiric" || is_suse ]]
+ return $?
+}
+
# Restore xtrace
$XTRACE
diff --git a/lib/cinder b/lib/cinder
index c2cf15b..058fcc2 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -63,11 +63,7 @@
cp -p $CINDER_DIR/etc/cinder/policy.json $CINDER_CONF_DIR
# Set the paths of certain binaries
- if [[ "$os_PACKAGE" = "deb" ]]; then
- CINDER_ROOTWRAP=/usr/local/bin/cinder-rootwrap
- else
- CINDER_ROOTWRAP=/usr/bin/cinder-rootwrap
- fi
+ CINDER_ROOTWRAP=$(get_rootwrap_location cinder)
# If Cinder ships the new rootwrap filters files, deploy them
# (owned by root) and add a parameter to $CINDER_ROOTWRAP
diff --git a/lib/databases/mysql b/lib/databases/mysql
index ed59290..fc6a3b7 100644
--- a/lib/databases/mysql
+++ b/lib/databases/mysql
@@ -25,7 +25,11 @@
MYSQL=mysql
else
MY_CONF=/etc/my.cnf
- MYSQL=mysqld
+ if is_suse; then
+ MYSQL=mysql
+ else
+ MYSQL=mysqld
+ fi
fi
# Start mysql-server
diff --git a/lib/horizon b/lib/horizon
index c6c96da..af09f77 100644
--- a/lib/horizon
+++ b/lib/horizon
@@ -81,9 +81,17 @@
sudo a2ensite horizon
else
# Install httpd, which is NOPRIME'd
- APACHE_NAME=httpd
- APACHE_CONF=conf.d/horizon.conf
- sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
+ if is_suse; then
+ APACHE_NAME=apache2
+ APACHE_CONF=vhosts.d/horizon.conf
+ # Append wsgi to the list of modules to load
+ grep -q "^APACHE_MODULES=.*wsgi" /etc/sysconfig/apache2 ||
+ sudo sed '/^APACHE_MODULES=/s/^\(.*\)"$/\1 wsgi"/' -i /etc/sysconfig/apache2
+ else
+ APACHE_NAME=httpd
+ APACHE_CONF=conf.d/horizon.conf
+ sudo sed '/^Listen/s/^.*$/Listen 0.0.0.0:80/' -i /etc/httpd/conf/httpd.conf
+ fi
fi
# Configure apache to run horizon
diff --git a/lib/nova b/lib/nova
index 3ea2f2a..d15d9e3 100644
--- a/lib/nova
+++ b/lib/nova
@@ -47,11 +47,7 @@
fi
# Set the paths of certain binaries
-if [[ "$os_PACKAGE" = "deb" ]]; then
- NOVA_ROOTWRAP=/usr/local/bin/nova-rootwrap
-else
- NOVA_ROOTWRAP=/usr/bin/nova-rootwrap
-fi
+NOVA_ROOTWRAP=$(get_rootwrap_location nova)
# Allow rate limiting to be turned off for testing, like for Tempest
# NOTE: Set API_RATE_LIMIT="False" to turn OFF rate limiting
@@ -252,7 +248,7 @@
# The user that nova runs as needs to be member of **libvirtd** group otherwise
# nova-compute will be unable to use libvirt.
- sudo usermod -a -G libvirtd `whoami`
+ add_user_to_group `whoami` libvirtd
# libvirt detects various settings on startup, as we potentially changed
# the system configuration (modules, filesystems), we need to restart
diff --git a/stack.sh b/stack.sh
index 570fc68..70f4610 100755
--- a/stack.sh
+++ b/stack.sh
@@ -113,9 +113,8 @@
fi
fi
-# Qpid was introduced to Ubuntu in precise, disallow it on oneiric
-if [ "${DISTRO}" = "oneiric" ] && is_service_enabled qpid ; then
- echo "You must use Ubuntu Precise or newer for Qpid support."
+if is_service_enabled qpid && ! qpid_is_supported; then
+ echo "Qpid support is not available for this version of your distribution."
exit 1
fi