[NEW PATCH] Path and user substitutions using autoconf (via gerrit-bot)

Federico Simoncelli fsimonce at redhat.com
Wed Aug 3 12:27:57 UTC 2011


New patch submitted by Federico Simoncelli (fsimonce at redhat.com)

You can review this change at: http://gerrit.usersys.redhat.com/714

commit c251b1f8c47e2bc08f02ba2e8809564780961455
Author: Federico Simoncelli <fsimonce at redhat.com>
Date:   Fri Jul 15 12:50:46 2011 +0000

    Path and user substitutions using autoconf
    
    Change-Id: I5c24d9418a592d0e582ddf41315012d2db69a76a

diff --git a/configure.ac b/configure.ac
index 132fa8b..ea1cfaa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,12 @@
 AC_INIT([vdsm], [4.9], [vdsm-devel at lists.fedorahosted.org])
 AC_SUBST([PACKAGE_RELEASE], m4_esyscmd([./build-aux/release.sh]))
 
+# Users and groups
+AC_SUBST([VDSMUSER], [vdsm])
+AC_SUBST([VDSMGROUP], [qemu])
+AC_SUBST([METADATAGROUP], [kvm])
+AC_SUBST([QEMUUSER], [qemu])
+
 # External programs (sorted, please keep in order)
 AC_PATH_PROG([BLOCKDEV_PATH], [blockdev], [/sbin/blockdev])
 AC_PATH_PROG([BRCTL_PATH], [brctl], [/usr/sbin/brctl])
@@ -58,6 +64,9 @@ AC_PATH_PROG([YUM_PATH], [yum], [/usr/bin/yum])
 AC_OUTPUT([
 	vdsm.spec
 	Makefile
-	vdsm/constants.py
+	vdsm/Makefile
+	vdsm/constants.py.in
+	vdsm/sudoers.vdsm.in
+	vdsm/mk_sysprep_floppy
 	vdsm_reg/deployUtil.py
 ])
diff --git a/vdsm/Makefile b/vdsm/Makefile
deleted file mode 100644
index 5786751..0000000
--- a/vdsm/Makefile
+++ /dev/null
@@ -1,116 +0,0 @@
-# Copyright 2008 Red Hat, Inc. and/or its affiliates.
-#
-# Licensed to you under the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.  See the files README and
-# LICENSE_GPL_v2 which accompany this distribution.
-#
-
-INSTALL=install
-
-FILES=define.py utils.py constants.py \
-      vm.py libvirtvm.py libvirtev.py \
-      caps.py clientIF.py hooks.py hooking.py \
-      guestIF.py dsaversion.py \
-      configNetwork.py SecureXMLRPCServer.py ksm.py \
-      netinfo.py neterrors.py \
-      kaxmlrpclib.py config.py logUtils.py \
-      supervdsm.py supervdsmServer.py \
-      libvirtconnection.py vdsmDebugPlugin.py \
-      pthread.py betterThreading.py \
-
-SCRIPTFILES=vdsm logCollector.sh \
-            addNetwork delNetwork \
-            get-conf-item set-conf-item \
-            mk_sysprep_floppy \
-            write-net-config vdsm-restore-net-config \
-            vdsm-store-net-config \
-            get-vm-pid respawn \
-            prepare-vmchannel
-
-STORAGEFILES=storageConstants.py dispatcher.py storage_exception.py \
-             __init__.py \
-             sd.py sp.py blockSD.py fileSD.py hsm.py safelease.py spm.py \
-             image.py volume.py blockVolume.py fileVolume.py taskManager.py\
-             resourceManager.py storage_connection.py fileUtils.py misc.py hba.py \
-             lvm.py iscsi.py multipath.py threadPool.py task.py \
-             storage_mailbox.py sdc.py sdf.py persistentDict.py \
-             threadLocal.py nfsSD.py localFsSD.py resourceFactories.py \
-	     outOfProcess.py processPool.py devicemapper.py
-
-PROTECTFILES=spmprotect.sh spmstop.sh safelease
-
-VDSMDIR=/usr/share/vdsm
-VDSMLOGDIR=/var/log/vdsm
-VDSMRUNDIR=/var/run/vdsm
-VDSMLIBDIR=/var/lib/vdsm
-LOGROTATEDIR=/etc/logrotate.d
-SOSPLUGINDIR=/usr/lib/python/site-packages/sos/plugins
-POOLSDATADIR=$(VDSMRUNDIR)/pools
-BACKUPDIR=$(VDSMLOGDIR)/backup
-BINDIR=$(VDSMDIR)
-LIBEXECDIR=/usr/libexec/vdsm
-HOOKSDIR=$(LIBEXECDIR)/hooks
-CONFDIR=$(VDSMDIR)
-TRUSTSTORE=$(VDSMRUNDIR)/ts
-MANDIR=/usr/share/man
-UDEVDIR=/etc/udev/rules.d
-
-CFLAGS=-Wall -O
-
-all: storage/protect/safelease
-
-# TODO fix this nonsense with autoconf
-.PHONY: fixpaths
-sudoers.vdsm: fixpaths sudoers.vdsm.in
-	python substitute_constants.py - < sudoers.vdsm.in > $@
-
-vdsm.conf.sample: fixpaths config.py
-	python mk_vdsm.conf.sample.py > vdsm.conf.sample
-
-fixpaths:
-	sed -i "s:@CONFDIR@:$(CONFDIR):; \
-	        s:@VDSMLOGDIR@:$(VDSMLOGDIR):; \
-	        s:@VDSMDIR@:$(VDSMDIR):; \
-	        s:@HOOKSDIR@:$(HOOKSDIR):; \
-	        s:@VDSMRUNDIR@:$(VDSMRUNDIR):; \
-	        s:@VDSMLIBDIR@:$(VDSMLIBDIR):; \
-	        s:@POOLSDIR@:$(POOLSDATADIR):; \
-	        s:@BACKUPDIR@:$(BACKUPDIR):; \
-	        s:@LIBEXECDIR@:$(LIBEXECDIR):; \
-	        s:@TRUSTSTORE@:$(TRUSTSTORE):" constants.py vdsm-sosplugin.py
-	python substitute_constants.py mk_sysprep_floppy logger.conf vdsmd \
-			    vdsm-store-net-config vdsm-restore-net-config
-
-install: all sudoers.vdsm vdsm.conf.sample
-	$(INSTALL) -Dd $(DESTDIR)$(VDSMDIR)/storage/protect
-	$(INSTALL) -Dd $(DESTDIR)$(TRUSTSTORE)/{certs,keys}
-	$(INSTALL) -Dd $(DESTDIR)$(VDSMLOGDIR)
-	$(INSTALL) -Dd $(DESTDIR)$(VDSMRUNDIR)
-	$(INSTALL) -Dd $(DESTDIR)$(VDSMLIBDIR)/netconfback
-	$(INSTALL) -Dd $(DESTDIR)$(POOLSDATADIR)
-	$(INSTALL) -Dd $(DESTDIR)$(BACKUPDIR)
-	$(INSTALL) -Dd $(DESTDIR)$(POOLDATADIR)
-	$(INSTALL) -Dd $(DESTDIR)$(LIBEXECDIR)
-	$(INSTALL) -Dd $(DESTDIR)/etc/init.d
-	$(INSTALL) -Dd $(DESTDIR)/etc/udev/rules.d
-	$(INSTALL) -Dd -m 775 $(DESTDIR)/var/lib/libvirt/qemu/channels
-	$(INSTALL) -Dm 644 $(FILES) $(DESTDIR)$(VDSMDIR)
-	$(INSTALL) -Dm 755 $(SCRIPTFILES) $(DESTDIR)$(VDSMDIR)
-	(cd storage; \
-	    $(INSTALL) -Dm 644 $(STORAGEFILES) $(DESTDIR)$(VDSMDIR)/storage)
-	(cd storage/protect; \
-	    $(INSTALL) -Dm 755 $(PROTECTFILES) $(DESTDIR)$(LIBEXECDIR))
-	$(INSTALL) -Dm 644 storage/12-vdsm-lvm.rules $(DESTDIR)$(UDEVDIR)
-	$(INSTALL) -Dm 644 logger.conf $(DESTDIR)$(CONFDIR)/logger.conf
-	$(INSTALL) -Dm 755 vdsmd $(DESTDIR)/etc/init.d/vdsmd
-	$(INSTALL) -Dm 440 sudoers.vdsm $(DESTDIR)/etc/sudoers.d/50_vdsm
-	$(INSTALL) -Dm 644 vdsm-logrotate.conf $(DESTDIR)/etc/logrotate.d/vdsm
-	$(INSTALL) -Dm 755 vdsm-logrotate $(DESTDIR)/etc/cron.hourly/vdsm-logrotate
-	$(INSTALL) -Dm 755 vdsm-libvirt-logrotate $(DESTDIR)/etc/cron.d/vdsm-libvirt-logrotate
-	$(INSTALL) -Dm 644 vdsm-sosplugin.py $(DESTDIR)$(SOSPLUGINDIR)/vdsm.py
-	$(INSTALL) -Dm 644 vdsmd.8 $(DESTDIR)$(MANDIR)/man8/vdsmd.8
-	$(INSTALL) -Dm 644 vdsm.rwtab $(DESTDIR)/etc/rwtab.d/vdsm
-
-clean:
-	$(RM) *~ *.pyc storage/protect/safelease vdsm.conf.sample
diff --git a/vdsm/Makefile.in b/vdsm/Makefile.in
new file mode 100644
index 0000000..a188f27
--- /dev/null
+++ b/vdsm/Makefile.in
@@ -0,0 +1,123 @@
+# Copyright 2008 Red Hat, Inc. and/or its affiliates.
+#
+# Licensed to you under the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.  See the files README and
+# LICENSE_GPL_v2 which accompany this distribution.
+#
+
+INSTALL=install
+
+FILES=define.py utils.py constants.py \
+      vm.py libvirtvm.py libvirtev.py \
+      caps.py clientIF.py hooks.py hooking.py \
+      guestIF.py dsaversion.py \
+      configNetwork.py SecureXMLRPCServer.py ksm.py \
+      netinfo.py neterrors.py \
+      kaxmlrpclib.py config.py logUtils.py \
+      supervdsm.py supervdsmServer.py \
+      libvirtconnection.py vdsmDebugPlugin.py \
+      pthread.py betterThreading.py \
+
+SCRIPTFILES=vdsm logCollector.sh \
+            addNetwork delNetwork \
+            get-conf-item set-conf-item \
+            mk_sysprep_floppy \
+            write-net-config vdsm-restore-net-config \
+            vdsm-store-net-config \
+            get-vm-pid respawn \
+            prepare-vmchannel
+
+STORAGEFILES=storageConstants.py dispatcher.py storage_exception.py \
+             __init__.py \
+             sd.py sp.py blockSD.py fileSD.py hsm.py safelease.py spm.py \
+             image.py volume.py blockVolume.py fileVolume.py taskManager.py\
+             resourceManager.py storage_connection.py fileUtils.py misc.py hba.py \
+             lvm.py iscsi.py multipath.py threadPool.py task.py \
+             storage_mailbox.py sdc.py sdf.py persistentDict.py \
+             threadLocal.py nfsSD.py localFsSD.py resourceFactories.py \
+	     outOfProcess.py processPool.py devicemapper.py
+
+FILES_SUBSTITUTIONS = \
+	constants.py \
+	vdsm-sosplugin.py \
+	sudoers.vdsm \
+	logger.conf \
+	vdsmd \
+	vdsm-store-net-config \
+	vdsm-restore-net-config
+
+PROTECTFILES=spmprotect.sh spmstop.sh safelease
+
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+VDSMDIR = @datarootdir@/vdsm
+VDSMLOGDIR = @localstatedir@/log/vdsm
+VDSMRUNDIR = @localstatedir@/run/vdsm
+VDSMLIBDIR = @localstatedir@/lib/vdsm
+LOGROTATEDIR = @sysconfdir@/logrotate.d
+SOSPLUGINDIR = @libdir@/python/site-packages/sos/plugins
+POOLSDATADIR = $(VDSMRUNDIR)/pools
+BACKUPDIR = $(VDSMLOGDIR)/backup
+LIBEXECDIR = @libexecdir@/vdsm
+HOOKSDIR = $(LIBEXECDIR)/hooks
+CONFDIR = $(VDSMDIR)
+TRUSTSTORE = $(VDSMRUNDIR)/ts
+MANDIR = @mandir@
+UDEVDIR = @sysconfdir@/udev/rules.d
+
+CFLAGS=-Wall -O
+
+all: storage/protect/safelease
+
+vdsm.conf.sample: config.py
+	python mk_vdsm.conf.sample.py > vdsm.conf.sample
+
+# Reference:
+# http://www.gnu.org/software/automake/manual/html_node/Scripts.html#Scripts
+do_subst = sed -e "s,[@]CONFDIR[@],$(CONFDIR),g" \
+	    -e "s,[@]VDSMLOGDIR[@],$(VDSMLOGDIR),g" \
+	    -e "s,[@]VDSMDIR[@],$(VDSMDIR),g" \
+	    -e "s,[@]HOOKSDIR[@],$(HOOKSDIR),g" \
+	    -e "s,[@]VDSMRUNDIR[@],$(VDSMRUNDIR),g" \
+	    -e "s,[@]VDSMLIBDIR[@],$(VDSMLIBDIR),g" \
+	    -e "s,[@]POOLSDIR[@],$(POOLSDATADIR),g" \
+	    -e "s,[@]BACKUPDIR[@],$(BACKUPDIR),g" \
+	    -e "s,[@]LIBEXECDIR[@],$(LIBEXECDIR),g" \
+	    -e "s,[@]TRUSTSTORE[@],$(TRUSTSTORE),g"
+
+$(FILES_SUBSTITUTIONS):
+	$(do_subst) < $@.in > $@
+
+install: $(FILES_SUBSTITUTIONS) vdsm.conf.sample
+	$(INSTALL) -Dd $(DESTDIR)$(VDSMDIR)/storage/protect
+	$(INSTALL) -Dd $(DESTDIR)$(TRUSTSTORE)/{certs,keys}
+	$(INSTALL) -Dd $(DESTDIR)$(VDSMLOGDIR)
+	$(INSTALL) -Dd $(DESTDIR)$(VDSMRUNDIR)
+	$(INSTALL) -Dd $(DESTDIR)$(VDSMLIBDIR)/netconfback
+	$(INSTALL) -Dd $(DESTDIR)$(POOLSDATADIR)
+	$(INSTALL) -Dd $(DESTDIR)$(BACKUPDIR)
+	$(INSTALL) -Dd $(DESTDIR)$(POOLDATADIR)
+	$(INSTALL) -Dd $(DESTDIR)$(LIBEXECDIR)
+	$(INSTALL) -Dd $(DESTDIR)/etc/init.d
+	$(INSTALL) -Dd $(DESTDIR)/etc/udev/rules.d
+	$(INSTALL) -Dd -m 775 $(DESTDIR)/var/lib/libvirt/qemu/channels
+	$(INSTALL) -Dm 644 $(FILES) $(DESTDIR)$(VDSMDIR)
+	$(INSTALL) -Dm 755 $(SCRIPTFILES) $(DESTDIR)$(VDSMDIR)
+	(cd storage; \
+	    $(INSTALL) -Dm 644 $(STORAGEFILES) $(DESTDIR)$(VDSMDIR)/storage)
+	(cd storage/protect; \
+	    $(INSTALL) -Dm 755 $(PROTECTFILES) $(DESTDIR)$(LIBEXECDIR))
+	$(INSTALL) -Dm 644 storage/12-vdsm-lvm.rules $(DESTDIR)$(UDEVDIR)
+	$(INSTALL) -Dm 644 logger.conf $(DESTDIR)$(CONFDIR)/logger.conf
+	$(INSTALL) -Dm 755 vdsmd $(DESTDIR)/etc/init.d/vdsmd
+	$(INSTALL) -Dm 440 sudoers.vdsm $(DESTDIR)/etc/sudoers.d/50_vdsm
+	$(INSTALL) -Dm 644 vdsm-logrotate.conf $(DESTDIR)/etc/logrotate.d/vdsm
+	$(INSTALL) -Dm 755 vdsm-logrotate $(DESTDIR)/etc/cron.hourly/vdsm-logrotate
+	$(INSTALL) -Dm 755 vdsm-libvirt-logrotate $(DESTDIR)/etc/cron.d/vdsm-libvirt-logrotate
+	$(INSTALL) -Dm 644 vdsm-sosplugin.py $(DESTDIR)$(SOSPLUGINDIR)/vdsm.py
+	$(INSTALL) -Dm 644 vdsmd.8 $(DESTDIR)$(MANDIR)/man8/vdsmd.8
+	$(INSTALL) -Dm 644 vdsm.rwtab $(DESTDIR)/etc/rwtab.d/vdsm
+
+clean:
+	$(RM) *~ *.pyc storage/protect/safelease vdsm.conf.sample
diff --git a/vdsm/constants.py.in b/vdsm/constants.py.in
deleted file mode 100644
index 60e131a..0000000
--- a/vdsm/constants.py.in
+++ /dev/null
@@ -1,148 +0,0 @@
-# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Description:    Constants definitions for vdsm and utilities.
-
-#
-# file ownership definitions
-#
-DISKIMAGE_USER = 'vdsm'
-DISKIMAGE_GROUP = 'qemu'
-METADATA_USER = 'vdsm'
-METADATA_GROUP = 'kvm'
-QEMU_PROCESS_USER = 'qemu'
-
-# This is the domain version translation list
-# DO NOT CHANGE OLD VALUES ONLY APPEND
-DOMAIN_VERSIONS = (0, 2)
-
-# This contains the domains versions that this VDSM
-# accepts currently its all of the version but in the
-# future we might slice it (eg. tuple(DOMAIN_VERSION[1:]))
-SUPPORTED_DOMAIN_VERSIONS = DOMAIN_VERSIONS
-
-UUID_GLOB_PATTERN = '*-*-*-*-*'
-
-MEGAB = 2 ** 20 # = 1024 ** 2 = 1 MiB
-
-#
-# Path definitions
-#
-P_BIN = '/bin/'
-P_SBIN = '/sbin/'
-P_LIBVIRT_VMCHANNELS = '/var/lib/libvirt/qemu/channels/'
-P_STORAGEPOOLS = '@POOLSDIR@'
-P_TRUSTSTORE = '@TRUSTSTORE@'
-P_USR_BIN = '/usr/bin/'
-P_USR_SBIN = '/usr/sbin/'
-P_VDSM = '@VDSMDIR@/'
-P_VDSM_BACKUP = '@BACKUPDIR@'
-P_VDSM_HOOKS = '@HOOKSDIR@/'
-P_VDSM_LIB = '@VDSMLIBDIR@/'
-P_VDSM_LIBEXEC = '@LIBEXECDIR@/'
-P_VDSM_RUN = '@VDSMRUNDIR@/'
-P_VDSM_CONF = '@CONFDIR@/'
-P_VDSM_KEYS = '/etc/pki/vdsm/keys/'
-
-P_VDSM_CLIENT_LOG = '@VDSMRUNDIR@/client.log'
-P_VDSM_LOG = '@VDSMLOGDIR@'
-
-#
-# External programs (sorted, please keep in order).
-#
-EXT_ADDNETWORK = P_VDSM + 'addNetwork'
-
-EXT_BLOCKDEV = '@BLOCKDEV_PATH@'
-EXT_BRCTL = '@BRCTL_PATH@'
-
-EXT_CAT = '@CAT_PATH@'
-EXT_CHOWN = '@CHOWN_PATH@'
-EXT_CP = '@CP_PATH@'
-
-EXT_DD = '@DD_PATH@'
-EXT_DELNETWORK = P_VDSM + 'delNetwork'
-EXT_DMIDECODE = '@DMIDECODE_PATH@'
-EXT_DMSETUP = '@DMSETUP_PATH@'
-
-EXT_EDITNETWORK = P_VDSM + 'editNetwork'
-
-EXT_FENCE_PREFIX = P_USR_SBIN + 'fence_'
-EXT_FSCK = '@FSCK_PATH@'
-EXT_FUSER = '@FUSER_PATH@'
-
-EXT_GET_VM_PID = P_VDSM + 'get-vm-pid'
-
-EXT_IFCONFIG = '@IFCONFIG_PATH@'
-EXT_IFDOWN = '@IFDOWN_PATH@'
-EXT_IFUP = '@IFUP_PATH@'
-EXT_IONICE = '@IONICE_PATH@'
-EXT_IPCALC = '@IPCALC_PATH@'
-EXT_ISCSIADM = '@ISCSIADM_PATH@'
-
-EXT_KILLALL = '@KILLALL_PATH@'
-EXT_KILL = '@KILL_PATH@'
-
-EXT_LVM = '@LVM_PATH@'
-
-EXT_MKFS = '@MKFS_PATH@'
-EXT_MK_SYSPREP_FLOPPY = P_VDSM + 'mk_sysprep_floppy'
-EXT_MOUNT = '@MOUNT_PATH@'
-EXT_MULTIPATH = '@MULTIPATH_PATH@'
-EXT_MV = '@MV_PATH@'
-
-EXT_NICE = '@NICE_PATH@'
-
-EXT_PERSIST = '@PERSIST_PATH@'
-EXT_PGREP = '@PGREP_PATH@'
-EXT_PREPARE_VMCHANNEL = P_VDSM + 'prepare-vmchannel'
-EXT_PYTHON = '@PYTHON_PATH@'
-
-EXT_QEMUIMG = '@QEMUIMG_PATH@'
-
-EXT_REBOOT = '@REBOOT_PATH@'
-EXT_RPM = '@RPM_PATH@'
-EXT_RSYNC = '@RSYNC_PATH@'
-
-EXT_SCSI_ID = '@SCSI_ID_PATH@' #TBD !
-EXT_SERVICE = '@SERVICE_PATH@'
-EXT_SETSID = '@SETSID_PATH@'
-EXT_SH = '/bin/sh' # The shell path is invariable
-EXT_SHOWMOUNT = '@SHOWMOUNT_PATH@'
-EXT_SU = '@SU_PATH@'
-EXT_SUDO = '@SUDO_PATH@'
-
-EXT_TAR = '@TAR_PATH@'
-EXT_TUNE2FS = '@TUNE2FS_PATH@'
-
-EXT_UMOUNT = '@UMOUNT_PATH@'
-EXT_UNPERSIST = '@UNPERSIST_PATH@'
-
-EXT_VCONFIG = '@VCONFIG_PATH@'
-EXT_VDSM_STORE_NET_CONFIG = P_VDSM + 'vdsm-store-net-config'
-
-EXT_WGET = '@WGET_PATH@'
-EXT_WRITE_NET_CONFIG = P_VDSM + 'write-net-config'
-
-CMD_LOWPRIO = [EXT_NICE, '-n', '19', EXT_IONICE, '-c', '2', '-n', '7']
-
-#
-# Storage constants
-#
-STRG_ISCSI_HOST = "iscsi_host/"
-STRG_SCSI_HOST = "scsi_host/"
-STRG_ISCSI_SESSION = "iscsi_session/"
-STRG_ISCSI_CONNECION = "iscsi_connection/"
-STRG_MPATH_CONF = """
-
-defaults {
-    polling_interval        5
-    getuid_callout          "/sbin/scsi_id -g -u -d /dev/%n"
-    no_path_retry           fail
-    user_friendly_names     no
-    flush_on_last_del       yes
-    fast_io_fail_tmo        5
-    dev_loss_tmo            30
-    max_fds                 4096
-}
-"""
-
diff --git a/vdsm/constants.py.in.in b/vdsm/constants.py.in.in
new file mode 100644
index 0000000..aad6b52
--- /dev/null
+++ b/vdsm/constants.py.in.in
@@ -0,0 +1,144 @@
+# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# Description:    Constants definitions for vdsm and utilities.
+
+#
+# file ownership definitions
+#
+DISKIMAGE_USER = '@VDSMUSER@'
+DISKIMAGE_GROUP = '@VDSMGROUP@'
+METADATA_USER = '@VDSMUSER@'
+METADATA_GROUP = '@METADATAGROUP@'
+QEMU_PROCESS_USER = '@QEMUUSER@'
+
+# This is the domain version translation list
+# DO NOT CHANGE OLD VALUES ONLY APPEND
+DOMAIN_VERSIONS = (0, 2)
+
+# This contains the domains versions that this VDSM
+# accepts currently its all of the version but in the
+# future we might slice it (eg. tuple(DOMAIN_VERSION[1:]))
+SUPPORTED_DOMAIN_VERSIONS = DOMAIN_VERSIONS
+
+UUID_GLOB_PATTERN = '*-*-*-*-*'
+
+MEGAB = 2 ** 20 # = 1024 ** 2 = 1 MiB
+
+#
+# Path definitions
+#
+P_LIBVIRT_VMCHANNELS = '/var/lib/libvirt/qemu/channels/'
+P_STORAGEPOOLS = '@POOLSDIR@'
+P_TRUSTSTORE = '@TRUSTSTORE@'
+P_VDSM = '@VDSMDIR@/'
+P_VDSM_BACKUP = '@BACKUPDIR@'
+P_VDSM_HOOKS = '@HOOKSDIR@/'
+P_VDSM_LIB = '@VDSMLIBDIR@/'
+P_VDSM_LIBEXEC = '@LIBEXECDIR@/'
+P_VDSM_RUN = '@VDSMRUNDIR@/'
+P_VDSM_CONF = '@CONFDIR@/'
+P_VDSM_KEYS = '/etc/pki/vdsm/keys/'
+
+P_VDSM_CLIENT_LOG = '@VDSMRUNDIR@/client.log'
+P_VDSM_LOG = '@VDSMLOGDIR@'
+
+#
+# External programs (sorted, please keep in order).
+#
+EXT_ADDNETWORK = '@VDSMDIR@/addNetwork'
+
+EXT_BLOCKDEV = '@BLOCKDEV_PATH@'
+EXT_BRCTL = '@BRCTL_PATH@'
+
+EXT_CAT = '@CAT_PATH@'
+EXT_CHOWN = '@CHOWN_PATH@'
+EXT_CP = '@CP_PATH@'
+
+EXT_DD = '@DD_PATH@'
+EXT_DELNETWORK = '@VDSMDIR@/delNetwork'
+EXT_DMIDECODE = '@DMIDECODE_PATH@'
+EXT_DMSETUP = '@DMSETUP_PATH@'
+
+EXT_EDITNETWORK = '@VDSMDIR@/editNetwork'
+
+EXT_FENCE_PREFIX = '/usr/bin/fence_'
+EXT_FSCK = '@FSCK_PATH@'
+EXT_FUSER = '@FUSER_PATH@'
+
+EXT_GET_VM_PID = '@VDSMDIR@/get-vm-pid'
+
+EXT_IFCONFIG = '@IFCONFIG_PATH@'
+EXT_IFDOWN = '@IFDOWN_PATH@'
+EXT_IFUP = '@IFUP_PATH@'
+EXT_IONICE = '@IONICE_PATH@'
+EXT_IPCALC = '@IPCALC_PATH@'
+EXT_ISCSIADM = '@ISCSIADM_PATH@'
+
+EXT_KILLALL = '@KILLALL_PATH@'
+EXT_KILL = '@KILL_PATH@'
+
+EXT_LVM = '@LVM_PATH@'
+
+EXT_MKFS = '@MKFS_PATH@'
+EXT_MK_SYSPREP_FLOPPY = '@VDSMDIR@/mk_sysprep_floppy'
+EXT_MOUNT = '@MOUNT_PATH@'
+EXT_MULTIPATH = '@MULTIPATH_PATH@'
+EXT_MV = '@MV_PATH@'
+
+EXT_NICE = '@NICE_PATH@'
+
+EXT_PERSIST = '@PERSIST_PATH@'
+EXT_PGREP = '@PGREP_PATH@'
+EXT_PREPARE_VMCHANNEL = '@VDSMDIR@/prepare-vmchannel'
+EXT_PYTHON = '@PYTHON_PATH@'
+
+EXT_QEMUIMG = '@QEMUIMG_PATH@'
+
+EXT_REBOOT = '@REBOOT_PATH@'
+EXT_RPM = '@RPM_PATH@'
+EXT_RSYNC = '@RSYNC_PATH@'
+
+EXT_SCSI_ID = '@SCSI_ID_PATH@' #TBD !
+EXT_SERVICE = '@SERVICE_PATH@'
+EXT_SETSID = '@SETSID_PATH@'
+EXT_SH = '/bin/sh' # The shell path is invariable
+EXT_SHOWMOUNT = '@SHOWMOUNT_PATH@'
+EXT_SU = '@SU_PATH@'
+EXT_SUDO = '@SUDO_PATH@'
+
+EXT_TAR = '@TAR_PATH@'
+EXT_TUNE2FS = '@TUNE2FS_PATH@'
+
+EXT_UMOUNT = '@UMOUNT_PATH@'
+EXT_UNPERSIST = '@UNPERSIST_PATH@'
+
+EXT_VCONFIG = '@VCONFIG_PATH@'
+EXT_VDSM_STORE_NET_CONFIG = '@VDSMDIR@/vdsm-store-net-config'
+
+EXT_WGET = '@WGET_PATH@'
+EXT_WRITE_NET_CONFIG = '@VDSMDIR@/write-net-config'
+
+CMD_LOWPRIO = [EXT_NICE, '-n', '19', EXT_IONICE, '-c', '2', '-n', '7']
+
+#
+# Storage constants
+#
+STRG_ISCSI_HOST = "iscsi_host/"
+STRG_SCSI_HOST = "scsi_host/"
+STRG_ISCSI_SESSION = "iscsi_session/"
+STRG_ISCSI_CONNECION = "iscsi_connection/"
+STRG_MPATH_CONF = """
+
+defaults {
+    polling_interval        5
+    getuid_callout          "/sbin/scsi_id -g -u -d /dev/%n"
+    no_path_retry           fail
+    user_friendly_names     no
+    flush_on_last_del       yes
+    fast_io_fail_tmo        5
+    dev_loss_tmo            30
+    max_fds                 4096
+}
+"""
+
diff --git a/vdsm/logger.conf b/vdsm/logger.conf
deleted file mode 100644
index cef1918..0000000
--- a/vdsm/logger.conf
+++ /dev/null
@@ -1,78 +0,0 @@
-[loggers]
-keys=root,vds,Storage,metadata,SuperVdsm
-
-[handlers]
-keys=console,syslog,logfile,metadata
-
-[formatters]
-keys=long,simple,none,sysform
-
-[logger_root]
-level=DEBUG
-handlers=syslog,logfile
-propagate=0
-
-[logger_vds]
-level=DEBUG
-handlers=syslog,logfile
-qualname=vds
-propagate=0
-
-[logger_Storage]
-level=DEBUG
-handlers=syslog,logfile
-qualname=Storage
-propagate=0
-
-[logger_SuperVdsm]
-level=DEBUG
-handlers=syslog,logfile
-qualname=SuperVdsm
-propagate=0
-
-[logger_metadata]
-level=WARNING
-handlers=metadata
-qualname=irs.metadata
-propagate=0
-
-[handler_syslog]
-class=handlers.SysLogHandler
-formatter=sysform
-args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
-
-[handler_logfile]
-class=FileHandler
-args=('@P_VDSM_LOG@/vdsm.log',)
-filters=storage.misc.TracebackRepeatFilter
-level=DEBUG
-formatter=long
-
-[handler_metadata]
-class=FileHandler
-args=('@P_VDSM_LOG@/metadata.log',)
-level=WARNING
-formatter=long
-
-[handler_console]
-class: StreamHandler
-args: []
-formatter: none
-
-[formatter_simple]
-format: %(name)s:%(levelname)s:  %(message)s
-
-[formatter_none]
-format: %(message)s
-
-[formatter_long]
-format: %(threadName)s::%(levelname)s::%(asctime)s::%(module)s::%(lineno)d::%(name)s::(%(funcName)s) %(message)s
-
-[formatter_sysform]
-format= %(asctime)s %(levelname)s %(message)s
-datefmt=
-
-
-
-
-
diff --git a/vdsm/logger.conf.in b/vdsm/logger.conf.in
new file mode 100644
index 0000000..f012683
--- /dev/null
+++ b/vdsm/logger.conf.in
@@ -0,0 +1,78 @@
+[loggers]
+keys=root,vds,Storage,metadata,SuperVdsm
+
+[handlers]
+keys=console,syslog,logfile,metadata
+
+[formatters]
+keys=long,simple,none,sysform
+
+[logger_root]
+level=DEBUG
+handlers=syslog,logfile
+propagate=0
+
+[logger_vds]
+level=DEBUG
+handlers=syslog,logfile
+qualname=vds
+propagate=0
+
+[logger_Storage]
+level=DEBUG
+handlers=syslog,logfile
+qualname=Storage
+propagate=0
+
+[logger_SuperVdsm]
+level=DEBUG
+handlers=syslog,logfile
+qualname=SuperVdsm
+propagate=0
+
+[logger_metadata]
+level=WARNING
+handlers=metadata
+qualname=irs.metadata
+propagate=0
+
+[handler_syslog]
+class=handlers.SysLogHandler
+formatter=sysform
+args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)
+
+[handler_logfile]
+class=FileHandler
+args=('@VDSMLOGDIR@/vdsm.log',)
+filters=storage.misc.TracebackRepeatFilter
+level=DEBUG
+formatter=long
+
+[handler_metadata]
+class=FileHandler
+args=('@VDSMLOGDIR@/metadata.log',)
+level=WARNING
+formatter=long
+
+[handler_console]
+class: StreamHandler
+args: []
+formatter: none
+
+[formatter_simple]
+format: %(name)s:%(levelname)s:  %(message)s
+
+[formatter_none]
+format: %(message)s
+
+[formatter_long]
+format: %(threadName)s::%(levelname)s::%(asctime)s::%(module)s::%(lineno)d::%(name)s::(%(funcName)s) %(message)s
+
+[formatter_sysform]
+format= %(asctime)s %(levelname)s %(message)s
+datefmt=
+
+
+
+
+
diff --git a/vdsm/mk_sysprep_floppy b/vdsm/mk_sysprep_floppy
deleted file mode 100644
index 1278811..0000000
--- a/vdsm/mk_sysprep_floppy
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh -e
-#
-# make a virtual floppy disk with sysprep.inf at its root.
-#
-
-if [ $# -ne 1 ]; then
-   echo usage: $0 /path/to.vfd
-   echo
-   echo create a floppy image and copy stdin into sysprep.inf.
-   exit 1
-fi
-
-FLOPPY_NAME="$1"
-/sbin/mkfs.msdos -C "$FLOPPY_NAME" 1440
-/bin/chown @DISKIMAGE_USER@:@DISKIMAGE_GROUP@ "$FLOPPY_NAME"
-/bin/chmod 0440 "$FLOPPY_NAME"
-mntpoint=`mktemp -d`
-mount -o loop,uid=`id -u`,gid=`id -g` "$FLOPPY_DIR/$FLOPPY_NAME" $mntpoint
-
-/bin/cat > $mntpoint/sysprep.inf
-
-umount $mntpoint
-rmdir $mntpoint
-
diff --git a/vdsm/mk_sysprep_floppy.in b/vdsm/mk_sysprep_floppy.in
new file mode 100644
index 0000000..d354474
--- /dev/null
+++ b/vdsm/mk_sysprep_floppy.in
@@ -0,0 +1,24 @@
+#!/bin/sh -e
+#
+# make a virtual floppy disk with sysprep.inf at its root.
+#
+
+if [ $# -ne 1 ]; then
+   echo usage: $0 /path/to.vfd
+   echo
+   echo create a floppy image and copy stdin into sysprep.inf.
+   exit 1
+fi
+
+FLOPPY_NAME="$1"
+/sbin/mkfs.msdos -C "$FLOPPY_NAME" 1440
+/bin/chown @VDSMUSER@:@VDSMGROUP@ "$FLOPPY_NAME"
+/bin/chmod 0440 "$FLOPPY_NAME"
+mntpoint=`mktemp -d`
+mount -o loop,uid=`id -u`,gid=`id -g` "$FLOPPY_DIR/$FLOPPY_NAME" $mntpoint
+
+/bin/cat > $mntpoint/sysprep.inf
+
+umount $mntpoint
+rmdir $mntpoint
+
diff --git a/vdsm/sudoers.vdsm.in b/vdsm/sudoers.vdsm.in
deleted file mode 100644
index 168f14e..0000000
--- a/vdsm/sudoers.vdsm.in
+++ /dev/null
@@ -1,45 +0,0 @@
-Cmnd_Alias VDSM_LIFECYCLE = @ADDNETWORK@, @DELNETWORK@, @EDITNETWORK@, @VDSM_STORE_NET_CONFIG@, @DMIDECODE@, @MK_SYSPREP_FLOPPY@, \
-    @SERVICE@ ksmtuned *, \
-    @SERVICE@ ksm *, \
-    @PREPARE_VMCHANNEL@, \
-    @GET_VM_PID@
-Cmnd_Alias VDSM_STORAGE = @MOUNT@, @UMOUNT@, \
-    @FSCK@ -p *, \
-    @TUNE2FS@ -j *, \
-    @MKFS@ -q -j *, \
-    @FUSER@ -m *, \
-    @KILL@, \
-    @CHOWN@ @DISKIMAGE_USER@\:@DISKIMAGE_GROUP@ *, \
-    @CHOWN@ @METADATA_USER@\:@METADATA_GROUP@ *, \
-    @MV@ /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.*, \
-    @MV@ /etc/multipath.conf *, \
-    @CP@ * /etc/iscsi/iscsid.conf, \
-    @CP@ * /etc/multipath.conf, \
-    @SERVICE@ iscsid *, \
-    @SERVICE@ multipathd restart, \
-    @SERVICE@ multipathd reload, \
-    @SCSI_ID@, \
-    @ISCSIADM@ *, \
-    @LVM@, \
-    @CAT@ /sys/block/*/device/../../*, \
-    @CAT@ /sys/devices/platform/host*, \
-    @CAT@ /etc/iscsi/iscsid.conf, \
-    @CAT@ /etc/multipath.conf, \
-    @DD@ of=/sys/class/scsi_host/host*/scan, \
-    @DD@, \
-    @PERSIST@ multipath.conf, \
-    @PERSIST@ /var/log/vdsm/backup/*, \
-    @UNPERSIST@ multipath.conf, \
-    @UNPERSIST@ /var/log/vdsm/backup/*, \
-    @CP@ * multipath.conf *, \
-    @CP@ * /var/log/vdsm/backup/* *, \
-    @MULTIPATH@, \
-    @BLOCKDEV@ --getsize64 *, \
-    @SETSID@ @IONICE@ -c? -n? @SU@ vdsm -s /bin/sh -c /usr/libexec/vdsm/spmprotect.sh*, \
-    @SERVICE@ vdsmd *, \
-    @REBOOT@ -f, \
-    @PYTHON@ @P_VDSM at supervdsmServer.pyc [a-z0-9\\-]* [0-9]*
-
-vdsm  ALL=(ALL) NOPASSWD: VDSM_LIFECYCLE, VDSM_STORAGE
-Defaults:vdsm !requiretty
-Defaults:vdsm !syslog
diff --git a/vdsm/sudoers.vdsm.in.in b/vdsm/sudoers.vdsm.in.in
new file mode 100644
index 0000000..106c498
--- /dev/null
+++ b/vdsm/sudoers.vdsm.in.in
@@ -0,0 +1,51 @@
+Cmnd_Alias VDSM_LIFECYCLE = \
+    @VDSMDIR@/addNetwork, \
+    @VDSMDIR@/delNetwork, \
+    @VDSMDIR@/editNetwork, \
+    @VDSMDIR@/vdsm-store-net-config, \
+    @DMIDECODE_PATH@, \
+    @VDSMDIR@/mk_sysprep_floppy, \
+    @SERVICE_PATH@ ksmtuned *, \
+    @SERVICE_PATH@ ksm *, \
+    @VDSMDIR@/prepare-vmchannel, \
+    @VDSMDIR@/get-vm-pid
+Cmnd_Alias VDSM_STORAGE = @MOUNT_PATH@, @UMOUNT_PATH@, \
+    @FSCK_PATH@ -p *, \
+    @TUNE2FS_PATH@ -j *, \
+    @MKFS_PATH@ -q -j *, \
+    @FUSER_PATH@ -m *, \
+    @KILL_PATH@, \
+    @CHOWN_PATH@ @VDSMUSER@\:@VDSMGROUP@ *, \
+    @CHOWN_PATH@ @VDSMUSER@\:@METADATAGROUP@ *, \
+    @MV_PATH@ /etc/iscsi/iscsid.conf /etc/iscsi/iscsid.conf.*, \
+    @MV_PATH@ /etc/multipath.conf *, \
+    @CP_PATH@ * /etc/iscsi/iscsid.conf, \
+    @CP_PATH@ * /etc/multipath.conf, \
+    @SERVICE_PATH@ iscsid *, \
+    @SERVICE_PATH@ multipathd restart, \
+    @SERVICE_PATH@ multipathd reload, \
+    @SCSI_ID_PATH@, \
+    @ISCSIADM_PATH@ *, \
+    @LVM_PATH@, \
+    @CAT_PATH@ /sys/block/*/device/../../*, \
+    @CAT_PATH@ /sys/devices/platform/host*, \
+    @CAT_PATH@ /etc/iscsi/iscsid.conf, \
+    @CAT_PATH@ /etc/multipath.conf, \
+    @DD_PATH@ of=/sys/class/scsi_host/host*/scan, \
+    @DD_PATH@, \
+    @PERSIST_PATH@ multipath.conf, \
+    @PERSIST_PATH@ /var/log/vdsm/backup/*, \
+    @UNPERSIST_PATH@ multipath.conf, \
+    @UNPERSIST_PATH@ /var/log/vdsm/backup/*, \
+    @CP_PATH@ * multipath.conf *, \
+    @CP_PATH@ * /var/log/vdsm/backup/* *, \
+    @MULTIPATH_PATH@, \
+    @BLOCKDEV_PATH@ --getsize64 *, \
+    @SETSID_PATH@ @IONICE_PATH@ -c? -n? @SU_PATH@ vdsm -s /bin/sh -c /usr/libexec/vdsm/spmprotect.sh*, \
+    @SERVICE_PATH@ vdsmd *, \
+    @REBOOT_PATH@ -f, \
+    @PYTHON_PATH@ @VDSMDIR@/supervdsmServer.pyc [a-z0-9\\-]* [0-9]*
+
+vdsm  ALL=(ALL) NOPASSWD: VDSM_LIFECYCLE, VDSM_STORAGE
+Defaults:vdsm !requiretty
+Defaults:vdsm !syslog
diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config
deleted file mode 100755
index 7b7562c..0000000
--- a/vdsm/vdsm-restore-net-config
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-#
-# vdsm-restore-net-config: restore network configuration files to their
-# declared-safe state.
-#
-# this should NOT be used in ovirt, where configuration persistence is handled
-# otherwise.
-
-[ -f /etc/rhev-hypervisor-release ] && exit 0
-
-NET_CONF_DIR='/etc/sysconfig/network-scripts/'
-NET_CONF_BACK_DIR=@P_VDSM_LIB@/netconfback
-DELETE_HEADER='# original file did not exist'
-
-for f in "$NET_CONF_BACK_DIR"/*;
-do
-    [ ! -f "$f" ] && continue
-    f=`basename "$f"`
-    declare -a todel tomove
-    if grep -q "$DELETE_HEADER" "$NET_CONF_BACK_DIR/$f"
-    then
-        todel[${#todel[@]}]="$f"
-    else
-        tomove[${#tomove[@]}]="$f"
-    fi
-    should_restart=yes
-done
-
-if [ "$should_restart" == yes ];
-then
-    service network stop
-    # ifdown'ed bridge are not deleteted
-    for f in "${todel[@]}";
-    do
-        grep -q '^TYPE=Bridge' "$NET_CONF_DIR/$f" && brctl delbr "${f/ifcfg-/}"
-    done
-fi
-
-for f in "${todel[@]}";
-do
-    rm -f "$NET_CONF_DIR/$f"
-    rm "$NET_CONF_BACK_DIR/$f"
-done
-for f in "${tomove[@]}";
-do
-    mv "$NET_CONF_BACK_DIR/$f" "$NET_CONF_DIR"
-done
-[ -d "$NET_CONF_BACK_DIR" ] && rmdir "$NET_CONF_BACK_DIR"
-[ "$should_restart" == yes ] && service network start
diff --git a/vdsm/vdsm-restore-net-config.in b/vdsm/vdsm-restore-net-config.in
new file mode 100755
index 0000000..7992319
--- /dev/null
+++ b/vdsm/vdsm-restore-net-config.in
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# vdsm-restore-net-config: restore network configuration files to their
+# declared-safe state.
+#
+# this should NOT be used in ovirt, where configuration persistence is handled
+# otherwise.
+
+[ -f /etc/rhev-hypervisor-release ] && exit 0
+
+NET_CONF_DIR='/etc/sysconfig/network-scripts/'
+NET_CONF_BACK_DIR=@VDSMLIBDIR@/netconfback
+DELETE_HEADER='# original file did not exist'
+
+for f in "$NET_CONF_BACK_DIR"/*;
+do
+    [ ! -f "$f" ] && continue
+    f=`basename "$f"`
+    declare -a todel tomove
+    if grep -q "$DELETE_HEADER" "$NET_CONF_BACK_DIR/$f"
+    then
+        todel[${#todel[@]}]="$f"
+    else
+        tomove[${#tomove[@]}]="$f"
+    fi
+    should_restart=yes
+done
+
+if [ "$should_restart" == yes ];
+then
+    service network stop
+    # ifdown'ed bridge are not deleteted
+    for f in "${todel[@]}";
+    do
+        grep -q '^TYPE=Bridge' "$NET_CONF_DIR/$f" && brctl delbr "${f/ifcfg-/}"
+    done
+fi
+
+for f in "${todel[@]}";
+do
+    rm -f "$NET_CONF_DIR/$f"
+    rm "$NET_CONF_BACK_DIR/$f"
+done
+for f in "${tomove[@]}";
+do
+    mv "$NET_CONF_BACK_DIR/$f" "$NET_CONF_DIR"
+done
+[ -d "$NET_CONF_BACK_DIR" ] && rmdir "$NET_CONF_BACK_DIR"
+[ "$should_restart" == yes ] && service network start
diff --git a/vdsm/vdsm-sosplugin.py b/vdsm/vdsm-sosplugin.py
deleted file mode 100644
index bc61007..0000000
--- a/vdsm/vdsm-sosplugin.py
+++ /dev/null
@@ -1,100 +0,0 @@
-### This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-import sos.plugintools
-import subprocess
-import ConfigParser
-import os
-
-class vdsm(sos.plugintools.PluginBase):
-    """VDSM server related information
-    """
-
-    optionList = [("logsize",  'max size (MiB) to collect per log file', '', False)]
-
-    def __addCopySpecLogLimit(self,path, logsize=None):
-        """
-        Glob the files in path and ensure that the sorted cumulative
-        list of globbed files isn't larger than logsize in MiB if
-        logsize is supplied.  Otherwise grab all files in path
-        irrespective of their size.
-        """
-        if logsize is not None:
-            self.addCopySpecLimit(path, logsize)
-        else:
-            self.addCopySpec(path)
-
-
-    def setup(self):
-        os.environ["LVM_SYSTEM_DIR"] = "@VDSMRUNDIR@/lvm"
-        self.collectExtOutput("/etc/init.d/vdsmd status")
-        self.addCopySpec("/tmp/vds_installer*")
-        self.addCopySpec("/tmp/vds_bootstrap*")
-        self.addCopySpec("/etc/vdsm/*")
-        logsize = self.getOption('logsize')
-        self.__addCopySpecLogLimit("/var/log/vdsm/*", logsize)
-        self.__addCopySpecLogLimit("/var/log/vdsm-reg/*", logsize)
-        self._addVdsmRunDir()
-        self.addCopySpec("@TRUSTSTORE@")
-        self.addCopySpec("@HOOKSDIR@")
-        self.addCopySpec("/var/log/ovirt.log")
-        p = subprocess.Popen(['/usr/bin/pgrep', 'qemu-kvm'],
-                             stdout=subprocess.PIPE)
-        out, err = p.communicate()
-        for line in out.splitlines():
-            pid = line.strip()
-            self.addCopySpec("/proc/%s/cmdline" % pid)
-            self.addCopySpec("/proc/%s/status" % pid)
-            self.addCopySpec("/proc/%s/mountstats" % pid)
-        self.collectExtOutput("/bin/ls -l /var/log/core")
-        self.collectExtOutput("/bin/su vdsm -s /bin/sh -c '/usr/bin/tree /rhev/data-center/'")
-        self.collectExtOutput("/bin/su vdsm -s /bin/sh -c '/bin/ls -lR /rhev/'")
-        self.collectExtOutput("/sbin/lvm vgs -v -o +tags")
-        self.collectExtOutput("/sbin/lvm lvs -v -o +tags")
-        self.collectExtOutput("/sbin/lvm pvs -v -o +all")
-        self.collectExtOutput("/sbin/fdisk -l")
-        self.collectExtOutput("/usr/bin/iostat")
-        self.collectExtOutput("/sbin/iscsiadm -m node")
-        self.collectExtOutput("/sbin/iscsiadm -m session")
-        config = ConfigParser.ConfigParser()
-        config.read('/etc/vdsm/vdsm.conf')
-        sslopt = ['', '-s '][config.getboolean('vars', 'ssl')]
-        vdsclient = "/usr/bin/vdsClient " + sslopt + "0 "
-        self.collectExtOutput(vdsclient + "getVdsCapabilities")
-        self.collectExtOutput(vdsclient + "getVdsStats")
-        self.collectExtOutput(vdsclient + "getAllVmStats")
-        self.collectExtOutput(vdsclient + "list")
-        self.collectExtOutput(vdsclient + "getVGList")
-        self.collectExtOutput(vdsclient + "getDeviceList")
-        self.collectExtOutput(vdsclient + "getSessionList")
-        self.collectExtOutput(vdsclient + "getAllTasksInfo")
-        self.collectExtOutput(vdsclient + "getAllTasksStatuses")
-        p = subprocess.Popen(vdsclient + "getConnectedStoragePoolsList",
-                             shell=True, stdout=subprocess.PIPE,
-                             stderr=subprocess.PIPE)
-        out, err = p.communicate()
-        for line in out.splitlines()[1:-1]:
-            pool = line.strip()
-            self.collectExtOutput(vdsclient + "getSpmStatus " + pool)
-        self.collectExtOutput('/bin/su vdsm -s /usr/bin/python @VDSMDIR@/dumpStorageTable.pyc')
-
-    def _addVdsmRunDir(self):
-        """Add everything under /var/run/vdsm except possibly confidential
-        sysprep vfds """
-
-        import glob
-
-        for f in glob.glob("@VDSMRUNDIR@/*"):
-            if not f.endswith('.vfd') and not f.endswith('/isoUploader'):
-                self.addCopySpec(f)
diff --git a/vdsm/vdsm-sosplugin.py.in b/vdsm/vdsm-sosplugin.py.in
new file mode 100644
index 0000000..bc61007
--- /dev/null
+++ b/vdsm/vdsm-sosplugin.py.in
@@ -0,0 +1,100 @@
+### This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import sos.plugintools
+import subprocess
+import ConfigParser
+import os
+
+class vdsm(sos.plugintools.PluginBase):
+    """VDSM server related information
+    """
+
+    optionList = [("logsize",  'max size (MiB) to collect per log file', '', False)]
+
+    def __addCopySpecLogLimit(self,path, logsize=None):
+        """
+        Glob the files in path and ensure that the sorted cumulative
+        list of globbed files isn't larger than logsize in MiB if
+        logsize is supplied.  Otherwise grab all files in path
+        irrespective of their size.
+        """
+        if logsize is not None:
+            self.addCopySpecLimit(path, logsize)
+        else:
+            self.addCopySpec(path)
+
+
+    def setup(self):
+        os.environ["LVM_SYSTEM_DIR"] = "@VDSMRUNDIR@/lvm"
+        self.collectExtOutput("/etc/init.d/vdsmd status")
+        self.addCopySpec("/tmp/vds_installer*")
+        self.addCopySpec("/tmp/vds_bootstrap*")
+        self.addCopySpec("/etc/vdsm/*")
+        logsize = self.getOption('logsize')
+        self.__addCopySpecLogLimit("/var/log/vdsm/*", logsize)
+        self.__addCopySpecLogLimit("/var/log/vdsm-reg/*", logsize)
+        self._addVdsmRunDir()
+        self.addCopySpec("@TRUSTSTORE@")
+        self.addCopySpec("@HOOKSDIR@")
+        self.addCopySpec("/var/log/ovirt.log")
+        p = subprocess.Popen(['/usr/bin/pgrep', 'qemu-kvm'],
+                             stdout=subprocess.PIPE)
+        out, err = p.communicate()
+        for line in out.splitlines():
+            pid = line.strip()
+            self.addCopySpec("/proc/%s/cmdline" % pid)
+            self.addCopySpec("/proc/%s/status" % pid)
+            self.addCopySpec("/proc/%s/mountstats" % pid)
+        self.collectExtOutput("/bin/ls -l /var/log/core")
+        self.collectExtOutput("/bin/su vdsm -s /bin/sh -c '/usr/bin/tree /rhev/data-center/'")
+        self.collectExtOutput("/bin/su vdsm -s /bin/sh -c '/bin/ls -lR /rhev/'")
+        self.collectExtOutput("/sbin/lvm vgs -v -o +tags")
+        self.collectExtOutput("/sbin/lvm lvs -v -o +tags")
+        self.collectExtOutput("/sbin/lvm pvs -v -o +all")
+        self.collectExtOutput("/sbin/fdisk -l")
+        self.collectExtOutput("/usr/bin/iostat")
+        self.collectExtOutput("/sbin/iscsiadm -m node")
+        self.collectExtOutput("/sbin/iscsiadm -m session")
+        config = ConfigParser.ConfigParser()
+        config.read('/etc/vdsm/vdsm.conf')
+        sslopt = ['', '-s '][config.getboolean('vars', 'ssl')]
+        vdsclient = "/usr/bin/vdsClient " + sslopt + "0 "
+        self.collectExtOutput(vdsclient + "getVdsCapabilities")
+        self.collectExtOutput(vdsclient + "getVdsStats")
+        self.collectExtOutput(vdsclient + "getAllVmStats")
+        self.collectExtOutput(vdsclient + "list")
+        self.collectExtOutput(vdsclient + "getVGList")
+        self.collectExtOutput(vdsclient + "getDeviceList")
+        self.collectExtOutput(vdsclient + "getSessionList")
+        self.collectExtOutput(vdsclient + "getAllTasksInfo")
+        self.collectExtOutput(vdsclient + "getAllTasksStatuses")
+        p = subprocess.Popen(vdsclient + "getConnectedStoragePoolsList",
+                             shell=True, stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+        out, err = p.communicate()
+        for line in out.splitlines()[1:-1]:
+            pool = line.strip()
+            self.collectExtOutput(vdsclient + "getSpmStatus " + pool)
+        self.collectExtOutput('/bin/su vdsm -s /usr/bin/python @VDSMDIR@/dumpStorageTable.pyc')
+
+    def _addVdsmRunDir(self):
+        """Add everything under /var/run/vdsm except possibly confidential
+        sysprep vfds """
+
+        import glob
+
+        for f in glob.glob("@VDSMRUNDIR@/*"):
+            if not f.endswith('.vfd') and not f.endswith('/isoUploader'):
+                self.addCopySpec(f)
diff --git a/vdsm/vdsm-store-net-config b/vdsm/vdsm-store-net-config
deleted file mode 100755
index 2aad93e..0000000
--- a/vdsm/vdsm-store-net-config
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-#
-# vdsm-store-net-config: store network configuration files persistently
-#
-
-NET_CONF_DIR='/etc/sysconfig/network-scripts/'
-NET_CONF_BACK_DIR=@P_VDSM_LIB@/netconfback
-DELETE_HEADER='# original file did not exist'
-
-if [ -f /etc/rhev-hypervisor-release ];
-then
-    # for ovirt, persist the changed configuration files
-
-    . /usr/libexec/ovirt-functions
-
-    for f in "$NET_CONF_BACK_DIR"/*;
-    do
-        [ ! -f "$f" ] && continue
-        bf=`basename "$f"`
-        if [ -f "$NET_CONF_DIR/$bf" ];
-        then
-            ovirt_store_config "$NET_CONF_DIR/$bf"
-        else
-            ovirt_safe_delete_config "$NET_CONF_DIR/$bf"
-        fi
-        rm "$NET_CONF_BACK_DIR/$bf"
-    done
-else
-    # for rhel, remove the backed up configuration files, and thus mark the
-    # ones under /etc/sysconfig as "safe".
-
-    rm -rf "$NET_CONF_BACK_DIR"/*
-fi
diff --git a/vdsm/vdsm-store-net-config.in b/vdsm/vdsm-store-net-config.in
new file mode 100755
index 0000000..a4f274c
--- /dev/null
+++ b/vdsm/vdsm-store-net-config.in
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# vdsm-store-net-config: store network configuration files persistently
+#
+
+NET_CONF_DIR='/etc/sysconfig/network-scripts/'
+NET_CONF_BACK_DIR=@VDSMLIBDIR@/netconfback
+DELETE_HEADER='# original file did not exist'
+
+if [ -f /etc/rhev-hypervisor-release ];
+then
+    # for ovirt, persist the changed configuration files
+
+    . /usr/libexec/ovirt-functions
+
+    for f in "$NET_CONF_BACK_DIR"/*;
+    do
+        [ ! -f "$f" ] && continue
+        bf=`basename "$f"`
+        if [ -f "$NET_CONF_DIR/$bf" ];
+        then
+            ovirt_store_config "$NET_CONF_DIR/$bf"
+        else
+            ovirt_safe_delete_config "$NET_CONF_DIR/$bf"
+        fi
+        rm "$NET_CONF_BACK_DIR/$bf"
+    done
+else
+    # for rhel, remove the backed up configuration files, and thus mark the
+    # ones under /etc/sysconfig as "safe".
+
+    rm -rf "$NET_CONF_BACK_DIR"/*
+fi
diff --git a/vdsm/vdsmd b/vdsm/vdsmd
deleted file mode 100755
index f5ecc53..0000000
--- a/vdsm/vdsmd
+++ /dev/null
@@ -1,519 +0,0 @@
-#! /bin/sh
-#
-# Copyright 2006-2010 Red Hat, Inc. and/or its affiliates.
-#
-# Licensed to you under the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.  See the files README and
-# LICENSE_GPL_v2 which accompany this distribution.
-#
-
-# chkconfig: 2345 99 00
-#
-### BEGIN INIT INFO
-# Provides: vdsmd
-# Required-Start: $syslog $network
-# Should-Start: $time
-# Required-Stop: $syslog
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Description: init script for the VDS management server
-# Short-Description: init script for the VDS management server
-### END INIT INFO
-
-VDSM_BIN=@P_VDSM@/vdsm
-CONF_FILE=@P_VDSM_CONF at vdsm.conf
-GETCONFITEM=@P_VDSM@/get-conf-item
-prog=vdsm
-PIDFILE=@P_VDSM_RUN@/vdsmd.pid
-RESPAWNPIDFILE=@P_VDSM_RUN@/respawn.pid
-CORE_DUMP_PATH=/var/log/core/core.%p.%t.dump
-DOM_METADATA_BACKUP_DIR=/var/log/vdsm/backup
-CORE_PATTERN=/proc/sys/kernel/core_pattern
-NEEDED_SERVICES="iscsid multipathd"
-CONFLICTING_SERVICES="libvirt-guests libvirtd"
-# TODO: Remove cpu cgroup disabling when BZ#623712 is resolved (kernel on
-# massively multicore platforms failing to scale with cgroups turned on)
-CONFLICTING_SERVICES="cgconfig $CONFLICTING_SERVICES"
-
-LCONF=/etc/libvirt/libvirtd.conf
-QCONF=/etc/libvirt/qemu.conf
-LDCONF=/etc/sysconfig/libvirtd
-
-is_coredump=`$GETCONFITEM $CONF_FILE vars core_dump_enable false | tr A-Z a-z`
-[ $is_coredump != true ] && is_coredump=false
-
-. /etc/init.d/functions
-
-log_failure_msg() { echo -n "$@"; failure "$@"; echo; }
-log_success_msg() { echo -n "$@"; success "$@"; echo; }
-
-check_port_taken() {
-    local MANAGEMENT_PORT MANAGEMENT_IP
-    MANAGEMENT_PORT=`$GETCONFITEM $CONF_FILE addresses management_port ""`
-    if [ -z "$MANAGEMENT_PORT" ]; then
-        log_failure_msg "$prog: management_port not found in $CONF_FILE"
-        return 1
-    fi
-    MANAGEMENT_IP=`$GETCONFITEM $CONF_FILE addresses management_ip 0.0.0.0`
-    netstat -ntl | grep -q "$MANAGEMENT_IP:$MANAGEMENT_PORT"
-    RETVAL=$?
-    if [ "$RETVAL" -eq 0 ]; then
-        log_failure_msg "$prog: port $MANAGEMENT_PORT already bound"
-        return 1
-    fi
-    return 0
-}
-
-mk_data_center() {
-    local dc
-    dc=`$GETCONFITEM $CONF_FILE irs repository /rhev/`
-    /bin/mkdir -p "$dc"
-    /bin/chown vdsm.kvm "$dc"
-}
-
-mk_dom_backup() {
-    /bin/mkdir -p ${DOM_METADATA_BACKUP_DIR} > /dev/null 2>&1
-    /bin/chown vdsm.kvm ${DOM_METADATA_BACKUP_DIR} > /dev/null 2>&1
-}
-
-mk_upgrade_path() {
-    if ! [ -d "/data/updates" ]; then
-        /bin/mkdir -p /data/updates > /dev/null 2>&1
-        /bin/chmod 755 /data/updates > /dev/null 2>&1
-    fi
-}
-
-mk_core_path() {
-    core_path=/var/log/core
-    if ! [ -d $core_path ]; then
-        /bin/mkdir -p $core_path > /dev/null 2>&1
-    fi
-    /bin/chmod a+tw $core_path > /dev/null 2>&1
-}
-
-get_libvirt_conf_item() {
-    local cfile key
-
-    cfile=$1
-    key=$2
-    /bin/grep "^\s*$key\s*=" "$cfile" | \
-            /usr/bin/tail -1 | /bin/sed "s/\s*$key\s*=\s*//;s/\s*\(#.*\)\?$//"
-}
-
-test_conflicting_conf() {
-    local listen_tcp auth_tcp ssl
-
-    ssl=`$GETCONFITEM $CONF_FILE vars ssl true | tr A-Z a-z`
-    [ "$ssl" == true ] && return 0
-
-    listen_tcp="`get_libvirt_conf_item $LCONF listen_tcp`"
-    auth_tcp="`get_libvirt_conf_item $LCONF auth_tcp`"
-    spice_tls="`get_libvirt_conf_item $QCONF spice_tls`"
-
-    if [ "$listen_tcp" == 1 -a "$auth_tcp" == '"none"' -a "$spice_tls" == 0 ];
-    then
-        return 0
-    else
-        echo "conflicting vdsm and libvirt tls configuration."
-        echo "vdsm.conf with ssl=False requires libvirt with:"
-        echo "listen_tcp=1, auth_tcp=\"none\" and spice_tls=0."
-        return 1
-    fi
-}
-
-shutdown_conflicting_srv() {
-    local srv
-
-    for srv in $CONFLICTING_SERVICES
-    do
-        /sbin/chkconfig $srv off
-        if /sbin/service $srv status > /dev/null 2>&1;
-        then
-            if [ "$srv" == "libvirt-guests" ]; then
-                /bin/rm -f /var/lock/subsys/libvirt-guests
-            else
-                /sbin/service $srv stop
-            fi
-        fi
-    done
-    return 0
-}
-
-start_needed_srv() {
-    local srv
-    local ret_val
-
-    for srv in $NEEDED_SERVICES
-    do
-        if ! /sbin/service $srv status > /dev/null 2>&1;
-        then
-            echo "Starting $srv..."
-            /sbin/service $srv start
-            ret_val=$?
-            if [ $ret_val -ne 0 ]
-            then
-                log_failure_msg "$prog: Dependent $srv failed to start"
-                return $ret_val
-            fi
-        fi
-    done
-
-    /sbin/service iscsid force-start
-}
-
-test_lo() {
-    if ! LC_ALL=C /sbin/ifconfig lo | /bin/grep -q UP;
-    then
-        log_failure_msg "VDSMD: lo interface is down, can't run !"
-        echo "VDSMD: lo interface is down, can't run !" > /dev/kmsg
-        return 1
-    fi
-    return 0
-}
-
-free_space() {
-    local path=$1
-    df -P "$path" | awk '{print $4}'| tail -1
-}
-
-test_space() {
-    local MIN_SPACE_KB=10000
-
-    if [ "`free_space /var/log/vdsm`" -lt "$MIN_SPACE_KB" ]; then
-        log_failure_msg "$prog: low log space"
-        return 1
-    fi
-    return 0
-}
-
-bond_dev_available() {
-    local BOND_DEVS=$(/bin/cat /sys/class/net/bonding_masters)
-    local x
-
-    [[ -z "$BOND_DEVS" ]] && return 1
-
-    for x in $BOND_DEVS; do
-        [[ "$x" == "$1" ]] && return 0
-    done
-
-    return 1
-}
-
-load_needed_modules() {
-    local b
-
-    /sbin/modprobe tun
-    /sbin/modprobe bonding
-    # RHEV-M currently assumes that all bonding devices pre-exist
-    for b in bond{0,1,2,3,4}; do
-        if ! bond_dev_available $b; then
-            echo +$b > /sys/class/net/bonding_masters 2>/dev/null
-        fi
-    done
-    /sbin/modprobe 8021q
-}
-
-test_already_running()
-{
-    if pidofproc -p $RESPAWNPIDFILE >/dev/null || \
-       pidofproc -p $PIDFILE $VDSM_BIN >/dev/null; then
-        log_success_msg "$prog: already running"
-        return 0
-    fi
-    return 1
-}
-
-# configure libvirt to vdsm's needs
-configure_libvirt()
-{
-    local force_reconfigure="$1"
-    local BY_VDSM="# by vdsm"
-    local ts=/etc/pki/vdsm
-
-    remove_vdsm_conf() {
-        sed -i --copy "/$BY_VDSM/d" "$1"
-    }
-
-    set_if_default() {
-        local cfile key val
-        cfile="$1"
-        key="$2"
-        val="$3"
-
-        /bin/grep -q "^\s*$key\s*=" "$cfile" || \
-          echo "$key=$val $BY_VDSM" >> "$cfile"
-    }
-
-    if [ -f /etc/rhev-hypervisor-release ];
-    then
-        . /usr/libexec/ovirt-functions
-    else
-        ovirt_store_config() { :; }
-    fi
-
-    local lconf qconf ldconf
-    local ssl=`$GETCONFITEM $CONF_FILE vars ssl true | tr A-Z a-z`
-
-    lconf="$2"
-    qconf="$3"
-    ldconf="$4"
-
-    if [ "$force_reconfigure" == force ];then
-        remove_vdsm_conf $lconf
-        remove_vdsm_conf $qconf
-        remove_vdsm_conf $ldconf
-    fi
-
-    # do not configure ovirt nodes before registration
-    if [ -f /etc/rhev-hypervisor-release -a \
-      ! -f $ts/certs/vdsmcert.pem ]
-    then
-        log_failure_msg "$prog: Missing certificates, $prog not registered "
-        return 6
-    fi
-
-    # do not reconfigure, return 0, so that vdsm start can continue.
-    if grep -q "$BY_VDSM" $lconf && grep -q "$BY_VDSM" $qconf
-    then
-        log_success_msg $"$prog: libvirt already configured for vdsm "
-        return 0
-    fi
-
-    echo $"Configuring libvirt for vdsm..."
-
-    # Set the default values for libvirt and qemu
-    set_if_default $lconf listen_addr \"0\"
-    set_if_default $lconf unix_sock_group \"kvm\"
-    set_if_default $lconf unix_sock_rw_perms \"0770\"
-    set_if_default $lconf auth_unix_rw \"sasl\"
-    set_if_default $qconf dynamic_ownership 0
-    if [[ "$ssl" == true ]]; then
-        set_if_default $qconf spice_tls 1
-    else
-        set_if_default $qconf spice_tls 0
-    fi
-    set_if_default $ldconf LIBVIRTD_ARGS --listen
-    set_if_default $ldconf DAEMON_COREFILE_LIMIT unlimited
-    set_if_default $lconf save_image_format \"lzop\"
-    # FIXME until we are confident with libvirt integration, let us have a verbose log
-    set_if_default $lconf log_outputs \"1:file:/var/log/libvirtd.log\"
-    set_if_default $lconf log_filters "\"1:libvirt 3:event 3:json 1:util 1:qemu\""
-
-    # If the ssl flag is set, update the libvirt and qemu configuration files
-    # with the location for certificates and permissions.
-    if [ -f $ts/certs/cacert.pem -a \
-         -f $ts/certs/vdsmcert.pem -a \
-         -f $ts/keys/vdsmkey.pem -a \
-         "$ssl" == true ];
-    then
-        set_if_default $lconf ca_file \"$ts/certs/cacert.pem\"
-        set_if_default $lconf cert_file \"$ts/certs/vdsmcert.pem\"
-        set_if_default $lconf key_file \"$ts/keys/vdsmkey.pem\"
-        set_if_default $qconf spice_tls_x509_cert_dir \"$ts/libvirt-spice\"
-    else
-        set_if_default $lconf auth_tcp \"none\"
-        set_if_default $lconf listen_tcp 1
-        set_if_default $lconf listen_tls 0
-    fi
-
-    local lnetwork=/etc/libvirt/qemu/networks/autostart/default.xml
-    rm -f $lnetwork
-
-    local llogr=/etc/logrotate.d/libvirtd
-    local stanza=`mktemp`
-    /bin/cat > "$stanza" <<EOF
-# vdsm
-/var/log/libvirtd.log {
-    rotate 100
-    missingok
-    copytruncate
-    size 15M
-    compress
-    compresscmd /usr/bin/xz
-    uncompresscmd /usr/bin/unxz
-    compressext .xz
-}
-# end vdsm
-EOF
-    /bin/cat "$llogr" >> "$stanza"
-    local oldmod=`/usr/bin/stat --format=%a "$llogr"`
-    /bin/mv "$stanza" "$llogr"
-    /bin/chmod "$oldmod" "$llogr"
-
-    ovirt_store_config "$lconf" "$qconf" "$ldconf" "$llogr"
-
-    # vdsm makes extensive use of nfs-exported images
-    /usr/sbin/semanage  boolean -m -S targeted -F /dev/stdin  << _EOF
-virt_use_nfs=1
-_EOF
-    /usr/sbin/setsebool virt_use_nfs on
-
-    /sbin/initctl restart libvirtd 2>/dev/null || :
-}
-
-RETVAL=0
-
-reconfigure() {
-    local args="$@"
-    case $# in
-        0)
-            args="force $LCONF $QCONF $LDCONF"
-            ;;
-        1)
-            # Use default paths
-            args="$args $LCONF $QCONF $LDCONF"
-            ;;
-    esac
-    configure_libvirt $args
-}
-
-start_libvirtd() {
-    local packaged installed target
-    local startout
-
-    packaged=`/bin/rpm -ql libvirt | /bin/grep libvirtd.upstart | \
-                 /usr/bin/tail -1`
-    target=/etc/init/libvirtd.conf
-    installed=`/bin/readlink -f "$target"`
-
-    if [[ "$packaged" != "$installed" ]];
-    then
-        /bin/ln -sf "$packaged" "$target" || return 1
-        /sbin/initctl reload-configuration
-    fi
-
-    startout=`/sbin/initctl start libvirtd 2>&1`
-    if [[ "$?" -eq 0 || "$startout" =~ .*already\ running.* ]];
-    then
-        return 0
-    else
-        echo "$startout" >&2
-        return 1
-    fi
-}
-
-start() {
-    local ret_val
-    python @P_VDSM@/hooks.pyc before_vdsm_start
-
-    shutdown_conflicting_srv
-
-    reconfigure noforce
-    ret_val=$?
-    if [ $ret_val -ne 0 ]
-    then
-        log_failure_msg "$prog: failed to reconfigure libvirt"
-        return $ret_val
-    fi
-
-    start_needed_srv && start_libvirtd
-    ret_val=$?
-    if [ $ret_val -ne 0 ]
-    then
-       log_failure_msg "$prog: one of the dependent services did not start, error code $ret_val"
-       return $ret_val
-    fi
-
-    @P_VDSM@/vdsm-restore-net-config
-    load_needed_modules
-    mk_data_center
-    mk_upgrade_path
-    mk_core_path
-    mk_dom_backup
-    /bin/chmod 1777 /dev/shm
-    if [ $is_coredump == true ]; then
-        export DAEMON_COREFILE_LIMIT=unlimited
-        echo $CORE_DUMP_PATH > $CORE_PATTERN
-    fi
-    [ `ulimit -n` -lt 4096 ] && ulimit -n 4096
-
-    test_already_running && return 0
-
-    if ! (test_space && test_lo && \
-          check_port_taken && \
-          test_conflicting_conf); then
-        return 1
-    fi
-
-    echo $"Starting up vdsm daemon: "
-    local vdsm_nice=`$GETCONFITEM $CONF_FILE vars vdsm_nice -5`
-
-    LIBVIRT_LOG_FILTERS=`$GETCONFITEM $CONF_FILE vars libvirt_log_filters "1:libvirt 1:remote"` \
-    LIBVIRT_LOG_OUTPUTS=`$GETCONFITEM $CONF_FILE vars libvirt_log_outputs "1:file:/var/log/vdsm/libvirt.log"` \
-    LC_ALL=C NICELEVEL=$vdsm_nice daemon --user=vdsm @P_VDSM@/respawn --minlifetime 10 --daemon --masterpid $RESPAWNPIDFILE $VDSM_BIN
-    RETVAL=$?
-    [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog start" || log_failure_msg $"$prog start"
-    [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vdsmd
-}
-
-stop() {
-    echo $"Shutting down vdsm daemon: "
-    if killproc -p $RESPAWNPIDFILE; then
-        log_success_msg $"$prog watchdog stop"
-    fi
-    if ! pidofproc -p $PIDFILE >/dev/null; then
-        log_failure_msg "$prog: not running"
-        RETVAL=0
-    else
-        killproc -p $PIDFILE -d 2
-        RETVAL=$?
-        [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog stop" || log_failure_msg $"$prog stop"
-        [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vdsmd
-    fi
-    python @P_VDSM@/hooks.pyc after_vdsm_stop
-    return $RETVAL
-}
-
-case "$1" in
-     start)
-        start
-	RETVAL=$?
-	;;
-     stop)
-        stop
-	RETVAL=$?
-	;;
-     status)
-	pidofproc -p $PIDFILE $VDSM_BIN >/dev/null
-	RETVAL=$?
-	if [ "$RETVAL" -eq 0 ]; then
-	    echo "VDS daemon server is running"
-	else
-	    echo -n "VDS daemon is not running"
-            if pidofproc -p $RESPAWNPIDFILE >/dev/null; then
-                echo ", but its watchdog is"
-            else
-                echo
-            fi
-	fi
-	;;
-     condrestart)
-	pidofproc -p $PIDFILE $VDSM_BIN >/dev/null
-	RETVAL=$?
-	if [ "$RETVAL" -eq 0 ]; then
-	    $0 stop && $0 start;
-	    RETVAL=$?;
-	fi;
-        ;;
-     try-restart)
-	$0 stop && $0 start
-	RETVAL=$?
-	;;
-     restart|force-reload)
-	$0 stop
-	$0 start
-	RETVAL=$?
-	;;
-    reconfigure)
-        # Jump over 'reconfigure'
-        shift 1
-        reconfigure "$@"
-	RETVAL=$?
-    ;;
-     *)
-	echo "Usage: $0 {start|stop|status|restart|force-reload|try-restart}"
-	RETVAL=2
-esac
-
-exit $RETVAL
diff --git a/vdsm/vdsmd.in b/vdsm/vdsmd.in
new file mode 100755
index 0000000..60a5afd
--- /dev/null
+++ b/vdsm/vdsmd.in
@@ -0,0 +1,519 @@
+#! /bin/sh
+#
+# Copyright 2006-2010 Red Hat, Inc. and/or its affiliates.
+#
+# Licensed to you under the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.  See the files README and
+# LICENSE_GPL_v2 which accompany this distribution.
+#
+
+# chkconfig: 2345 99 00
+#
+### BEGIN INIT INFO
+# Provides: vdsmd
+# Required-Start: $syslog $network
+# Should-Start: $time
+# Required-Stop: $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Description: init script for the VDS management server
+# Short-Description: init script for the VDS management server
+### END INIT INFO
+
+VDSM_BIN=@VDSMDIR@/vdsm
+CONF_FILE=@CONFDIR@/vdsm.conf
+GETCONFITEM=@VDSMDIR@/get-conf-item
+prog=vdsm
+PIDFILE=@VDSMRUNDIR@/vdsmd.pid
+RESPAWNPIDFILE=@VDSMRUNDIR@/respawn.pid
+CORE_DUMP_PATH=/var/log/core/core.%p.%t.dump
+DOM_METADATA_BACKUP_DIR=/var/log/vdsm/backup
+CORE_PATTERN=/proc/sys/kernel/core_pattern
+NEEDED_SERVICES="iscsid multipathd"
+CONFLICTING_SERVICES="libvirt-guests libvirtd"
+# TODO: Remove cpu cgroup disabling when BZ#623712 is resolved (kernel on
+# massively multicore platforms failing to scale with cgroups turned on)
+CONFLICTING_SERVICES="cgconfig $CONFLICTING_SERVICES"
+
+LCONF=/etc/libvirt/libvirtd.conf
+QCONF=/etc/libvirt/qemu.conf
+LDCONF=/etc/sysconfig/libvirtd
+
+is_coredump=`$GETCONFITEM $CONF_FILE vars core_dump_enable false | tr A-Z a-z`
+[ $is_coredump != true ] && is_coredump=false
+
+. /etc/init.d/functions
+
+log_failure_msg() { echo -n "$@"; failure "$@"; echo; }
+log_success_msg() { echo -n "$@"; success "$@"; echo; }
+
+check_port_taken() {
+    local MANAGEMENT_PORT MANAGEMENT_IP
+    MANAGEMENT_PORT=`$GETCONFITEM $CONF_FILE addresses management_port ""`
+    if [ -z "$MANAGEMENT_PORT" ]; then
+        log_failure_msg "$prog: management_port not found in $CONF_FILE"
+        return 1
+    fi
+    MANAGEMENT_IP=`$GETCONFITEM $CONF_FILE addresses management_ip 0.0.0.0`
+    netstat -ntl | grep -q "$MANAGEMENT_IP:$MANAGEMENT_PORT"
+    RETVAL=$?
+    if [ "$RETVAL" -eq 0 ]; then
+        log_failure_msg "$prog: port $MANAGEMENT_PORT already bound"
+        return 1
+    fi
+    return 0
+}
+
+mk_data_center() {
+    local dc
+    dc=`$GETCONFITEM $CONF_FILE irs repository /rhev/`
+    /bin/mkdir -p "$dc"
+    /bin/chown vdsm.kvm "$dc"
+}
+
+mk_dom_backup() {
+    /bin/mkdir -p ${DOM_METADATA_BACKUP_DIR} > /dev/null 2>&1
+    /bin/chown vdsm.kvm ${DOM_METADATA_BACKUP_DIR} > /dev/null 2>&1
+}
+
+mk_upgrade_path() {
+    if ! [ -d "/data/updates" ]; then
+        /bin/mkdir -p /data/updates > /dev/null 2>&1
+        /bin/chmod 755 /data/updates > /dev/null 2>&1
+    fi
+}
+
+mk_core_path() {
+    core_path=/var/log/core
+    if ! [ -d $core_path ]; then
+        /bin/mkdir -p $core_path > /dev/null 2>&1
+    fi
+    /bin/chmod a+tw $core_path > /dev/null 2>&1
+}
+
+get_libvirt_conf_item() {
+    local cfile key
+
+    cfile=$1
+    key=$2
+    /bin/grep "^\s*$key\s*=" "$cfile" | \
+            /usr/bin/tail -1 | /bin/sed "s/\s*$key\s*=\s*//;s/\s*\(#.*\)\?$//"
+}
+
+test_conflicting_conf() {
+    local listen_tcp auth_tcp ssl
+
+    ssl=`$GETCONFITEM $CONF_FILE vars ssl true | tr A-Z a-z`
+    [ "$ssl" == true ] && return 0
+
+    listen_tcp="`get_libvirt_conf_item $LCONF listen_tcp`"
+    auth_tcp="`get_libvirt_conf_item $LCONF auth_tcp`"
+    spice_tls="`get_libvirt_conf_item $QCONF spice_tls`"
+
+    if [ "$listen_tcp" == 1 -a "$auth_tcp" == '"none"' -a "$spice_tls" == 0 ];
+    then
+        return 0
+    else
+        echo "conflicting vdsm and libvirt tls configuration."
+        echo "vdsm.conf with ssl=False requires libvirt with:"
+        echo "listen_tcp=1, auth_tcp=\"none\" and spice_tls=0."
+        return 1
+    fi
+}
+
+shutdown_conflicting_srv() {
+    local srv
+
+    for srv in $CONFLICTING_SERVICES
+    do
+        /sbin/chkconfig $srv off
+        if /sbin/service $srv status > /dev/null 2>&1;
+        then
+            if [ "$srv" == "libvirt-guests" ]; then
+                /bin/rm -f /var/lock/subsys/libvirt-guests
+            else
+                /sbin/service $srv stop
+            fi
+        fi
+    done
+    return 0
+}
+
+start_needed_srv() {
+    local srv
+    local ret_val
+
+    for srv in $NEEDED_SERVICES
+    do
+        if ! /sbin/service $srv status > /dev/null 2>&1;
+        then
+            echo "Starting $srv..."
+            /sbin/service $srv start
+            ret_val=$?
+            if [ $ret_val -ne 0 ]
+            then
+                log_failure_msg "$prog: Dependent $srv failed to start"
+                return $ret_val
+            fi
+        fi
+    done
+
+    /sbin/service iscsid force-start
+}
+
+test_lo() {
+    if ! LC_ALL=C /sbin/ifconfig lo | /bin/grep -q UP;
+    then
+        log_failure_msg "VDSMD: lo interface is down, can't run !"
+        echo "VDSMD: lo interface is down, can't run !" > /dev/kmsg
+        return 1
+    fi
+    return 0
+}
+
+free_space() {
+    local path=$1
+    df -P "$path" | awk '{print $4}'| tail -1
+}
+
+test_space() {
+    local MIN_SPACE_KB=10000
+
+    if [ "`free_space /var/log/vdsm`" -lt "$MIN_SPACE_KB" ]; then
+        log_failure_msg "$prog: low log space"
+        return 1
+    fi
+    return 0
+}
+
+bond_dev_available() {
+    local BOND_DEVS=$(/bin/cat /sys/class/net/bonding_masters)
+    local x
+
+    [[ -z "$BOND_DEVS" ]] && return 1
+
+    for x in $BOND_DEVS; do
+        [[ "$x" == "$1" ]] && return 0
+    done
+
+    return 1
+}
+
+load_needed_modules() {
+    local b
+
+    /sbin/modprobe tun
+    /sbin/modprobe bonding
+    # RHEV-M currently assumes that all bonding devices pre-exist
+    for b in bond{0,1,2,3,4}; do
+        if ! bond_dev_available $b; then
+            echo +$b > /sys/class/net/bonding_masters 2>/dev/null
+        fi
+    done
+    /sbin/modprobe 8021q
+}
+
+test_already_running()
+{
+    if pidofproc -p $RESPAWNPIDFILE >/dev/null || \
+       pidofproc -p $PIDFILE $VDSM_BIN >/dev/null; then
+        log_success_msg "$prog: already running"
+        return 0
+    fi
+    return 1
+}
+
+# configure libvirt to vdsm's needs
+configure_libvirt()
+{
+    local force_reconfigure="$1"
+    local BY_VDSM="# by vdsm"
+    local ts=/etc/pki/vdsm
+
+    remove_vdsm_conf() {
+        sed -i --copy "/$BY_VDSM/d" "$1"
+    }
+
+    set_if_default() {
+        local cfile key val
+        cfile="$1"
+        key="$2"
+        val="$3"
+
+        /bin/grep -q "^\s*$key\s*=" "$cfile" || \
+          echo "$key=$val $BY_VDSM" >> "$cfile"
+    }
+
+    if [ -f /etc/rhev-hypervisor-release ];
+    then
+        . /usr/libexec/ovirt-functions
+    else
+        ovirt_store_config() { :; }
+    fi
+
+    local lconf qconf ldconf
+    local ssl=`$GETCONFITEM $CONF_FILE vars ssl true | tr A-Z a-z`
+
+    lconf="$2"
+    qconf="$3"
+    ldconf="$4"
+
+    if [ "$force_reconfigure" == force ];then
+        remove_vdsm_conf $lconf
+        remove_vdsm_conf $qconf
+        remove_vdsm_conf $ldconf
+    fi
+
+    # do not configure ovirt nodes before registration
+    if [ -f /etc/rhev-hypervisor-release -a \
+      ! -f $ts/certs/vdsmcert.pem ]
+    then
+        log_failure_msg "$prog: Missing certificates, $prog not registered "
+        return 6
+    fi
+
+    # do not reconfigure, return 0, so that vdsm start can continue.
+    if grep -q "$BY_VDSM" $lconf && grep -q "$BY_VDSM" $qconf
+    then
+        log_success_msg $"$prog: libvirt already configured for vdsm "
+        return 0
+    fi
+
+    echo $"Configuring libvirt for vdsm..."
+
+    # Set the default values for libvirt and qemu
+    set_if_default $lconf listen_addr \"0\"
+    set_if_default $lconf unix_sock_group \"kvm\"
+    set_if_default $lconf unix_sock_rw_perms \"0770\"
+    set_if_default $lconf auth_unix_rw \"sasl\"
+    set_if_default $qconf dynamic_ownership 0
+    if [[ "$ssl" == true ]]; then
+        set_if_default $qconf spice_tls 1
+    else
+        set_if_default $qconf spice_tls 0
+    fi
+    set_if_default $ldconf LIBVIRTD_ARGS --listen
+    set_if_default $ldconf DAEMON_COREFILE_LIMIT unlimited
+    set_if_default $lconf save_image_format \"lzop\"
+    # FIXME until we are confident with libvirt integration, let us have a verbose log
+    set_if_default $lconf log_outputs \"1:file:/var/log/libvirtd.log\"
+    set_if_default $lconf log_filters "\"1:libvirt 3:event 3:json 1:util 1:qemu\""
+
+    # If the ssl flag is set, update the libvirt and qemu configuration files
+    # with the location for certificates and permissions.
+    if [ -f $ts/certs/cacert.pem -a \
+         -f $ts/certs/vdsmcert.pem -a \
+         -f $ts/keys/vdsmkey.pem -a \
+         "$ssl" == true ];
+    then
+        set_if_default $lconf ca_file \"$ts/certs/cacert.pem\"
+        set_if_default $lconf cert_file \"$ts/certs/vdsmcert.pem\"
+        set_if_default $lconf key_file \"$ts/keys/vdsmkey.pem\"
+        set_if_default $qconf spice_tls_x509_cert_dir \"$ts/libvirt-spice\"
+    else
+        set_if_default $lconf auth_tcp \"none\"
+        set_if_default $lconf listen_tcp 1
+        set_if_default $lconf listen_tls 0
+    fi
+
+    local lnetwork=/etc/libvirt/qemu/networks/autostart/default.xml
+    rm -f $lnetwork
+
+    local llogr=/etc/logrotate.d/libvirtd
+    local stanza=`mktemp`
+    /bin/cat > "$stanza" <<EOF
+# vdsm
+/var/log/libvirtd.log {
+    rotate 100
+    missingok
+    copytruncate
+    size 15M
+    compress
+    compresscmd /usr/bin/xz
+    uncompresscmd /usr/bin/unxz
+    compressext .xz
+}
+# end vdsm
+EOF
+    /bin/cat "$llogr" >> "$stanza"
+    local oldmod=`/usr/bin/stat --format=%a "$llogr"`
+    /bin/mv "$stanza" "$llogr"
+    /bin/chmod "$oldmod" "$llogr"
+
+    ovirt_store_config "$lconf" "$qconf" "$ldconf" "$llogr"
+
+    # vdsm makes extensive use of nfs-exported images
+    /usr/sbin/semanage  boolean -m -S targeted -F /dev/stdin  << _EOF
+virt_use_nfs=1
+_EOF
+    /usr/sbin/setsebool virt_use_nfs on
+
+    /sbin/initctl restart libvirtd 2>/dev/null || :
+}
+
+RETVAL=0
+
+reconfigure() {
+    local args="$@"
+    case $# in
+        0)
+            args="force $LCONF $QCONF $LDCONF"
+            ;;
+        1)
+            # Use default paths
+            args="$args $LCONF $QCONF $LDCONF"
+            ;;
+    esac
+    configure_libvirt $args
+}
+
+start_libvirtd() {
+    local packaged installed target
+    local startout
+
+    packaged=`/bin/rpm -ql libvirt | /bin/grep libvirtd.upstart | \
+                 /usr/bin/tail -1`
+    target=/etc/init/libvirtd.conf
+    installed=`/bin/readlink -f "$target"`
+
+    if [[ "$packaged" != "$installed" ]];
+    then
+        /bin/ln -sf "$packaged" "$target" || return 1
+        /sbin/initctl reload-configuration
+    fi
+
+    startout=`/sbin/initctl start libvirtd 2>&1`
+    if [[ "$?" -eq 0 || "$startout" =~ .*already\ running.* ]];
+    then
+        return 0
+    else
+        echo "$startout" >&2
+        return 1
+    fi
+}
+
+start() {
+    local ret_val
+    python @VDSMDIR@/hooks.pyc before_vdsm_start
+
+    shutdown_conflicting_srv
+
+    reconfigure noforce
+    ret_val=$?
+    if [ $ret_val -ne 0 ]
+    then
+        log_failure_msg "$prog: failed to reconfigure libvirt"
+        return $ret_val
+    fi
+
+    start_needed_srv && start_libvirtd
+    ret_val=$?
+    if [ $ret_val -ne 0 ]
+    then
+       log_failure_msg "$prog: one of the dependent services did not start, error code $ret_val"
+       return $ret_val
+    fi
+
+    @VDSMDIR@/vdsm-restore-net-config
+    load_needed_modules
+    mk_data_center
+    mk_upgrade_path
+    mk_core_path
+    mk_dom_backup
+    /bin/chmod 1777 /dev/shm
+    if [ $is_coredump == true ]; then
+        export DAEMON_COREFILE_LIMIT=unlimited
+        echo $CORE_DUMP_PATH > $CORE_PATTERN
+    fi
+    [ `ulimit -n` -lt 4096 ] && ulimit -n 4096
+
+    test_already_running && return 0
+
+    if ! (test_space && test_lo && \
+          check_port_taken && \
+          test_conflicting_conf); then
+        return 1
+    fi
+
+    echo $"Starting up vdsm daemon: "
+    local vdsm_nice=`$GETCONFITEM $CONF_FILE vars vdsm_nice -5`
+
+    LIBVIRT_LOG_FILTERS=`$GETCONFITEM $CONF_FILE vars libvirt_log_filters "1:libvirt 1:remote"` \
+    LIBVIRT_LOG_OUTPUTS=`$GETCONFITEM $CONF_FILE vars libvirt_log_outputs "1:file:/var/log/vdsm/libvirt.log"` \
+    LC_ALL=C NICELEVEL=$vdsm_nice daemon --user=vdsm @VDSMDIR@/respawn --minlifetime 10 --daemon --masterpid $RESPAWNPIDFILE $VDSM_BIN
+    RETVAL=$?
+    [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog start" || log_failure_msg $"$prog start"
+    [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vdsmd
+}
+
+stop() {
+    echo $"Shutting down vdsm daemon: "
+    if killproc -p $RESPAWNPIDFILE; then
+        log_success_msg $"$prog watchdog stop"
+    fi
+    if ! pidofproc -p $PIDFILE >/dev/null; then
+        log_failure_msg "$prog: not running"
+        RETVAL=0
+    else
+        killproc -p $PIDFILE -d 2
+        RETVAL=$?
+        [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog stop" || log_failure_msg $"$prog stop"
+        [ "$RETVAL" -eq 0 ] && rm -f /var/lock/subsys/vdsmd
+    fi
+    python @VDSMDIR@/hooks.pyc after_vdsm_stop
+    return $RETVAL
+}
+
+case "$1" in
+     start)
+        start
+	RETVAL=$?
+	;;
+     stop)
+        stop
+	RETVAL=$?
+	;;
+     status)
+	pidofproc -p $PIDFILE $VDSM_BIN >/dev/null
+	RETVAL=$?
+	if [ "$RETVAL" -eq 0 ]; then
+	    echo "VDS daemon server is running"
+	else
+	    echo -n "VDS daemon is not running"
+            if pidofproc -p $RESPAWNPIDFILE >/dev/null; then
+                echo ", but its watchdog is"
+            else
+                echo
+            fi
+	fi
+	;;
+     condrestart)
+	pidofproc -p $PIDFILE $VDSM_BIN >/dev/null
+	RETVAL=$?
+	if [ "$RETVAL" -eq 0 ]; then
+	    $0 stop && $0 start;
+	    RETVAL=$?;
+	fi;
+        ;;
+     try-restart)
+	$0 stop && $0 start
+	RETVAL=$?
+	;;
+     restart|force-reload)
+	$0 stop
+	$0 start
+	RETVAL=$?
+	;;
+    reconfigure)
+        # Jump over 'reconfigure'
+        shift 1
+        reconfigure "$@"
+	RETVAL=$?
+    ;;
+     *)
+	echo "Usage: $0 {start|stop|status|restart|force-reload|try-restart}"
+	RETVAL=2
+esac
+
+exit $RETVAL




More information about the vdsm-patches mailing list