Add is_fedora and exit_distro_not_supported functions
Between is_fedora, is_ubuntu and is_suse, we can make the code a bit
simpler to read. We also use exit_distro_not_supported to identify
places where we need implementation details for new distros.
As "/sbin/service --skip-redirect" is Fedora-specific, guard this with a
is_fedora test too.
Change-Id: Ic77c0697ed9be0dbb5df8e73da93463e76025f0c
diff --git a/lib/cinder b/lib/cinder
index 9b9d50d..a43f0a1 100644
--- a/lib/cinder
+++ b/lib/cinder
@@ -195,8 +195,8 @@
mkdir -p $CINDER_STATE_PATH/volumes
if sudo vgs $VOLUME_GROUP; then
- if [[ "$os_PACKAGE" = "rpm" ]]; then
- # RPM doesn't start the service
+ if is_fedora || is_suse; then
+ # service is not started by default
start_service tgtd
fi
@@ -245,9 +245,15 @@
# do it in two steps
sudo stop tgt || true
sudo start tgt
- else
+ elif is_fedora; then
# bypass redirection to systemctl during restart
sudo /sbin/service --skip-redirect tgtd restart
+ elif is_suse; then
+ restart_service tgtd
+ else
+ # note for other distros: unstack.sh also uses the tgt/tgtd service
+ # name, and would need to be adjusted too
+ exit_distro_not_supported "restarting tgt"
fi
fi