[NEW PATCH] BZ#716919 - Update guest cpu running state after underlying VM is continued (via gerrit-bot)
by Yotam Oron
New patch submitted by Yotam Oron (yoron(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/695
commit 7fb94d36d2808a1468e4fe802987cab4f7d63f55
Author: Yotam Oron <yoron(a)redhat.com>
Date: Tue Jul 12 15:52:23 2011 +0300
BZ#716919 - Update guest cpu running state after underlying VM is continued
[WIP] The guest CPU state should be updated after the underlying machine is
resumed, so that the right value is read from libvirt.
Change-Id: Ie3bb3bd2ec985b42bdaea19ce334f53234df4f11
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 40567a5..fd0daa5 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -881,7 +881,6 @@ class LibvirtVm(vm.Vm):
self.guestAgent = guestIF.GuestAgent(self._guestSocektFile, self.log,
connect=utils.tobool(self.conf.get('vmchannel', 'true')))
- self._guestCpuRunning = self._dom.info()[0] == libvirt.VIR_DOMAIN_RUNNING
if self.lastStatus not in ('Migration Destination',
'Restoring state'):
self._initTimePauseCode = self._readPauseCode(0)
@@ -1010,6 +1009,7 @@ class LibvirtVm(vm.Vm):
def _underlyingCont(self):
hooks.before_vm_cont(self._dom.XMLDesc(0), self.conf)
self._dom.resume()
+ self._guestCpuRunning = self._dom.info()[0] == libvirt.VIR_DOMAIN_RUNNING
def _underlyingPause(self):
hooks.before_vm_pause(self._dom.XMLDesc(0), self.conf)
12 years, 8 months
[NEW PATCH] BZ#704131 - Mutiple set rw on block. (via gerrit-bot)
by ewarszaw@redhat.com
New patch submitted by Eduardo Warszawski (ewarszaw(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/763
commit 4f012ffb140fdd42b14d232bb50ce681e552bb9f
Author: Eduardo Warszawski <ewarszaw(a)redhat.com>
Date: Wed Jul 27 16:54:18 2011 +0300
BZ#704131 - Mutiple set rw on block.
Change-Id: Ie98bda6d327f0a7c2f29636830e4f9cfde27c29e
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 55e790e..049f373 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -1149,19 +1149,21 @@ def listPVNames(vgName):
return [pv.name for pv in pvs if pv.vg_name == vgName]
-def setrwLV(vg, lv, rw=True):
+def setrwLV(vgName, lvNames, rw=True):
permission = {False:'r', True:'rw'}[rw]
try:
- _changelv(vg, lv, "--permission", permission)
+ _changelv(vgName, lvNames, "--permission", permission)
except se.StorageException:
- l = getLV(vg, lv)
- if l.writeable == rw:
+ reloaded = _lvminfo._reloadlvs(vgName).values()
+ failed = []
+ for lv in reloaded:
+ if lv.writeable != rw:
+ failed.append(lv.name)
# Ignore the error since lv is now rw, hoping that the error was
# because lv was already rw, see BZ#654691. We may hide here another
# lvchange error.
- return
-
- raise se.CannotSetRWLogicalVolume(vg, lv, permission)
+ if failed:
+ raise se.CannotSetRWLogicalVolume(vgName, " ".join(failed), permission)
def lvsByTag(vg, tag):
12 years, 8 months
[NEW PATCH] Introduce new version system for VDSM (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/752
commit 4c851e5831a9473e01ef4207b5ed96faaa10de8e
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Wed Jul 20 09:46:27 2011 +0000
Introduce new version system for VDSM
Change-Id: I9b9efb781a59bc1179bdb1b10b9ec17b7d08fbc1
diff --git a/build-aux/release.sh b/build-aux/release.sh
index 40d76bc..aeecf28 100755
--- a/build-aux/release.sh
+++ b/build-aux/release.sh
@@ -1,4 +1,16 @@
#!/bin/sh
-GIT_RELEASE=`git describe | awk -F- '{print $3 "." $5}' | tr -d '\n'`
-GIT_BRANCH=`git branch | awk '/^*/{print $2}' | sed 's/[^a-zA-Z0-9_.]//g'`
-echo -n $GIT_RELEASE.$GIT_BRANCH
+# tags and output releases:
+# - v4.9.0 => 0 (upstream clean)
+# - v4.9.0-1 => 1 (downstream clean)
+# - v4.9.0-2-g34e62f => 0.2.g34e62f (upstream dirty)
+# - v4.9.0-1-2-g34e62f => 1.2.g34e62f (downstream dirty)
+AWK_RELEASE='
+ BEGIN { FS="-"; OFS="." }
+ /^v[0-9]/ {
+ if (NF == 1) print 0
+ else if (NF == 2) print $2
+ else if (NF == 3) print 0, $2, $3
+ else if (NF == 4) print $2, $3, $4
+ }'
+git describe \
+ | awk "$AWK_RELEASE" | tr -cd '[:alnum:].'
diff --git a/build-aux/version.sh b/build-aux/version.sh
new file mode 100755
index 0000000..1c9d3fb
--- /dev/null
+++ b/build-aux/version.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# tags and output versions:
+# - v4.9.0 => 4.9.0 (upstream clean)
+# - v4.9.0-1 => 4.9.0 (downstream clean)
+# - v4.9.0-2-g34e62f => 4.9.0 (upstream dirty)
+# - v4.9.0-1-2-g34e62f => 4.9.0 (downstream dirty)
+AWK_VERSION='
+ BEGIN { FS="-" }
+ /^v[0-9]/ {
+ sub(/^v/,"") ; print $1
+ }'
+git describe \
+ | awk "$AWK_VERSION" | tr -cd '[0-9].'
diff --git a/configure.ac b/configure.ac
index 0533cd0..8bcedc1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,8 +1,13 @@
# Autoconf initialization
-AC_INIT([vdsm], [4.9], [vdsm-devel(a)lists.fedorahosted.org])
-AC_SUBST([PACKAGE_RELEASE], m4_esyscmd([./build-aux/release.sh]))
+AC_INIT([vdsm],
+ [m4_esyscmd([build-aux/version.sh])],
+ [vdsm-devel(a)lists.fedorahosted.org])
AC_CONFIG_AUX_DIR([build-aux])
+# Package release
+AC_SUBST([PACKAGE_RELEASE],
+ [m4_esyscmd([build-aux/release.sh])])
+
# Automake initialization
AM_INIT_AUTOMAKE([-Wno-portability])
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 29d511e..691f6a5 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1,7 +1,6 @@
%define vdsm_reg vdsm-reg
%define vdsm_name vdsm
%define vdsm_bootstrap vdsm-bootstrap
-%define vdsm_release @PACKAGE_RELEASE@
%include %{_rpmconfigdir}/macros.python
Summary: Virtual Desktop Server Manager
@@ -11,7 +10,7 @@ Source: %{vdsm_name}-%{version}.tar.gz
# tarball built from internal git repo with
# make tarball rpmversion=<version> rpmrelease=<release>
Version: @PACKAGE_VERSION@
-Release: %{vdsm_release}%{?dist}
+Release: @PACKAGE_RELEASE@%{?dist}
License: GPLv2+
Group: Applications/System
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
12 years, 8 months
[NEW PATCH] [WIP] Use automake to build and install vdsm (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/726
commit db4c78906c7cd56ceb688a31d2025a447c79269b
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Mon Jul 18 16:06:49 2011 +0000
[WIP] Use automake to build and install vdsm
Change-Id: I91fae2ca646f8f1db8c12708dee1ddd1ae96b38f
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..6964d0e
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,37 @@
+# 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.
+#
+
+SUBDIRS = vdsm vdsm_cli vds_bootstrap vdsm_reg vdsm_hooks
+EXTRA_DIST = vdsm.spec
+
+rpmversion = @PACKAGE_VERSION@
+rpmrelease = @PACKAGE_RELEASE@
+RPMTOP = $(PWD)/rpmtop
+
+TESTS = pyflakes
+
+test: pyflakes exceptions
+ echo $(rpmrelease) $(rpmversion)
+
+.PHONY: pyflakes exceptions
+exceptions:
+ python vdsm/storage/storage_exception.py | grep Collision && exit 1 || true
+
+pyflakes:
+ @git ls-files '*.py' | xargs pyflakes \
+ || (echo "Pyflakes errors or pyflakes not found"; exit 1)
+
+.PHONY: srpm rpm
+srpm: dist
+ mkdir -p $(RPMTOP)/{RPMS,SRPMS,SOURCES,BUILD}
+ rpmbuild -ts \
+ --define="_topdir $(RPMTOP)" \
+ --define="_sourcedir $(PWD)" $(DIST_ARCHIVES)
+
+rpm: dist
+ rpmbuild --define="_topdir $(RPMTOP)" -ta $(DIST_ARCHIVES)
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index ac0b198..0000000
--- a/Makefile.in
+++ /dev/null
@@ -1,54 +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.
-#
-SUBDIRS=vdsm_cli re vds_bootstrap vdsm vdsm_reg vdsm_hooks
-DOCS=COPYING README
-
-all: rpm
-
-rpmversion=@PACKAGE_VERSION@
-rpmrelease=@PACKAGE_RELEASE@
-RPMTOP=$(PWD)/rpmtop
-SPEC=vdsm.spec
-
-TARBALL=vdsm-$(rpmversion)-$(rpmrelease).tar.gz
-SRPM=$(RPMTOP)/SRPMS/vdsm-$(rpmversion)-$(rpmrelease).src.rpm
-
-TESTS=pyflakes
-
-test: pyflakes exceptions
- echo $(rpmrelease) $(rpmversion)
-
-exceptions:
- python vdsm/storage/storage_exception.py | grep Collision && exit 1 || true
-
-pyflakes:
- @git ls-files '*.py' | xargs pyflakes \
- || (echo "Pyflakes errors or pyflakes not found"; exit 1)
-
-install:
- for subdir in $(SUBDIRS); do make -C $$subdir $@; done
-
-.PHONY: tarball
-tarball: $(TARBALL)
-$(TARBALL): Makefile $(SUBDIRS) $(DOCS) $(TESTS)
- tar zcf $(TARBALL) `git ls-files | grep -v /ut/` vdsm.spec configure
-
-.PHONY: srpm rpm
-srpm: $(SRPM)
-$(SRPM): $(TARBALL) vdsm.spec.in
- mkdir -p $(RPMTOP)/{RPMS,SRPMS,SOURCES,BUILD}
- rpmbuild -ts \
- --define="_topdir $(RPMTOP)" \
- --define="_sourcedir $(PWD)" $(TARBALL)
-
-rpm: $(SRPM)
- rpmbuild --define="_topdir $(RPMTOP)" -ta $(TARBALL)
-
-clean:
- $(RM) *~ *.pyc vdsm*.tar.gz $(SPEC)
- $(RM) -r rpmtop
diff --git a/configure.ac b/configure.ac
index 3629d4a..5e7a31b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,12 +1,38 @@
+# Autoconf initialization
AC_INIT([vdsm], [4.9], [vdsm-devel(a)lists.fedorahosted.org])
AC_SUBST([PACKAGE_RELEASE], m4_esyscmd([./build-aux/release.sh]))
+# Automake initialization
+AM_INIT_AUTOMAKE([-Wno-portability])
+
+# Checking for build tools
+AC_PROG_CC
+AC_PROG_LN_S
+AM_PATH_PYTHON([2.6])
+
# Users and groups
AC_SUBST([VDSMUSER], [vdsm])
AC_SUBST([VDSMGROUP], [qemu])
AC_SUBST([METADATAGROUP], [kvm])
AC_SUBST([QEMUUSER], [qemu])
+# VDSM default paths
+AC_SUBST([vdsmdir], ['${datarootdir}/vdsm'])
+AC_SUBST([vdsmconfdir], ['${sysconfdir}/vdsm'])
+AC_SUBST([vdsmlogdir], ['${localstatedir}/log/vdsm'])
+AC_SUBST([vdsmrundir], ['${localstatedir}/run/vdsm'])
+AC_SUBST([vdsmlibdir], ['${localstatedir}/lib/vdsm'])
+AC_SUBST([vdsmpoolsdir], ['${vdsmrundir}/pools'])
+AC_SUBST([vdsmbackupdir], ['${vdsmlogdir}/backup'])
+AC_SUBST([vdsmexecdir], ['${libexecdir}/vdsm'])
+AC_SUBST([vdsmhooksdir], ['${vdsmexecdir}/hooks'])
+AC_SUBST([vdsmtsdir], ['${sysconfdir}/pki/vdsm'])
+
+# VDSM registration default paths
+AC_SUBST([vdsmregdir], ['${datarootdir}/vdsm-reg'])
+AC_SUBST([vdsmregconfdir], ['${sysconfdir}/vdsm-reg'])
+AC_SUBST([vdsmreglogdir], ['${localstatedir}/log/vdsm-reg'])
+
# External programs (sorted, please keep in order)
AC_PATH_PROG([BLOCKDEV_PATH], [blockdev], [/sbin/blockdev])
AC_PATH_PROG([BRCTL_PATH], [brctl], [/usr/sbin/brctl])
@@ -63,9 +89,17 @@ AC_PATH_PROG([WGET_PATH], [wget], [/usr/bin/wget])
AC_PATH_PROG([YUM_PATH], [yum], [/usr/bin/yum])
AC_OUTPUT([
- vdsm.spec
Makefile
+ vds_bootstrap/Makefile
+ vdsm_cli/Makefile
+ vdsm_hooks/faqemu/Makefile
+ vdsm_hooks/Makefile
+ vdsm_hooks/vhostmd/Makefile
vdsm/Makefile
+ vdsm_reg/Makefile
+ vdsm/storage/Makefile
+ vdsm/storage/protect/Makefile
+ vdsm.spec
vdsm/constants.py.in
vdsm/sudoers.vdsm.in
vdsm/mk_sysprep_floppy
diff --git a/vds_bootstrap/Makefile b/vds_bootstrap/Makefile
deleted file mode 100644
index 2c023ae..0000000
--- a/vds_bootstrap/Makefile
+++ /dev/null
@@ -1,25 +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
-VDSMBOOTDIR = /usr/share/vdsm-bootstrap
-PYSRCS = vds_bootstrap.py vds_bootstrap_complete.py
-
-all: $(PYSRCS)
-
-install:
- $(INSTALL) -Dd 755 $(DESTDIR)$(VDSMBOOTDIR)
- $(INSTALL) -Dm 755 $(PYSRCS) $(DESTDIR)$(VDSMBOOTDIR)
- $(INSTALL) -Dm 644 deployUtil.py $(DESTDIR)$(VDSMBOOTDIR)
-
-clean:
- $(RM) *.pyc *.pyo *~
-
-pyflakes:
- find . -name "*.py" | xargs pyflakes
-
diff --git a/vds_bootstrap/Makefile.am b/vds_bootstrap/Makefile.am
new file mode 100644
index 0000000..8199cbf
--- /dev/null
+++ b/vds_bootstrap/Makefile.am
@@ -0,0 +1,14 @@
+# 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.
+#
+
+vdsmbootstrapdir = $(datarootdir)/vdsm-bootstrap
+
+dist_vdsmbootstrap_DATA = \
+ deployUtil.py \
+ vds_bootstrap_complete.py \
+ vds_bootstrap.py
diff --git a/vdsm.spec.in b/vdsm.spec.in
index adf7232..51a5367 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -6,7 +6,7 @@
Summary: Virtual Desktop Server Manager
Name: vdsm
-Source: %{vdsm_name}-%{version}-%{vdsm_release}.tar.gz
+Source: %{vdsm_name}-%{version}.tar.gz
# Url: no upstream project exists
# tarball built from internal git repo with
# make tarball rpmversion=<version> rpmrelease=<release>
@@ -43,32 +43,15 @@ storage, memory and networks as well as virtual machine creation, other host
administration tasks, statistics gathering, and log collection.
%prep
-%setup -c -q
+%setup -q
%build
%configure
-make -C vdsm CFLAGS="$RPM_OPT_FLAGS"
-baserelease=`echo "%{release}" | sed 's/\([0-9]\+\(\.[0-9]\+\)\?\).*/\1/'`
-sed -i 's/^software_version =.*/software_version = "%{version}"/;s/software_revision =.*/software_revision = "'"$baserelease"'"/' re/dsaversion.py
-
+make
%install
-rm -rf "%{buildroot}"
-mkdir -p "%{buildroot}"
-make DESTDIR="%{buildroot}" \
- ETC=%{_sysconfdir} \
- VDSMDIR=%{_datadir}/%{vdsm_name} \
- VDSMLOGDIR=%{_localstatedir}/log/%{vdsm_name} \
- TRUSTSTORE=%{_sysconfdir}/pki/%{vdsm_name} \
- BINDIR=%{_bindir} \
- LIBEXECDIR=%{_libexecdir}/%{vdsm_name} \
- CONFDIR=%{_sysconfdir}/%{vdsm_name} \
- REGCONFDIR=%{_sysconfdir}/%{vdsm_name}-reg \
- VDSMRUNDIR=%{_localstatedir}/run/%{vdsm_name} \
- VDSMLIBDIR=%{_localstatedir}/lib/%{vdsm_name} \
- SOSPLUGINDIR=%{py_sitedir}/sos/plugins \
- OVIRT_CONFIG_SETUP=%{py_sitedir}/ovirt_config_setup \
- install
+rm -rf %{buildroot}
+make DESTDIR=%{buildroot} install
# this is not commonplace, but we want /var/log/core to be a world-writable
# dropbox for core dumps.
@@ -219,6 +202,7 @@ machines without running real guests.
%files
%defattr(-,root,root,-)
+%doc vdsm/vdsm.conf.sample
%dir %{_libexecdir}/%{vdsm_name}
%dir %{_datadir}/%{vdsm_name}
%dir %{_datadir}/%{vdsm_name}/storage
@@ -242,7 +226,6 @@ machines without running real guests.
%{_datadir}/%{vdsm_name}/mk_sysprep_floppy
%{_datadir}/%{vdsm_name}/get-vm-pid
%{_datadir}/%{vdsm_name}/prepare-vmchannel
-%doc vdsm/vdsm.conf.sample
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/logger.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/vdsm
%config(noreplace) %{_sysconfdir}/rwtab.d/vdsm
diff --git a/vdsm/Makefile.am b/vdsm/Makefile.am
new file mode 100644
index 0000000..4a86b40
--- /dev/null
+++ b/vdsm/Makefile.am
@@ -0,0 +1,143 @@
+# 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.
+#
+
+SUBDIRS = storage
+
+dist_vdsm_DATA = \
+ betterThreading.py \
+ caps.py \
+ clientIF.py \
+ configNetwork.py \
+ config.py \
+ constants.py \
+ define.py \
+ dsaversion.py \
+ guestIF.py \
+ hooking.py \
+ hooks.py \
+ kaxmlrpclib.py \
+ ksm.py \
+ libvirtconnection.py \
+ libvirtev.py \
+ libvirtvm.py \
+ logUtils.py \
+ neterrors.py \
+ netinfo.py \
+ pthread.py \
+ SecureXMLRPCServer.py \
+ supervdsm.py \
+ supervdsmServer.py \
+ utils.py \
+ vdsmDebugPlugin.py \
+ vm.py
+
+dist_vdsm_SCRIPTS = \
+ addNetwork \
+ delNetwork \
+ get-conf-item \
+ get-vm-pid \
+ logCollector.sh \
+ mk_sysprep_floppy \
+ prepare-vmchannel \
+ respawn \
+ set-conf-item \
+ vdsm \
+ vdsm-restore-net-config \
+ vdsm-store-net-config \
+ write-net-config
+
+dist_man8_MANS = vdsmd.8
+
+noinst_DATA = \
+ logger.conf \
+ sudoers.vdsm \
+ vdsm.conf.sample \
+ vdsmd \
+ vdsm-sosplugin.py
+
+vdsm_SUBST = \
+ $(noinst_DATA) \
+ constants.py \
+ vdsm-restore-net-config \
+ vdsm-store-net-config
+
+CLEANFILES = $(vdsm_SUBST)
+
+EXTRA_DIST = \
+ constants.py.in \
+ logger.conf.in \
+ mk_vdsm.conf.sample.py \
+ sudoers.vdsm.in \
+ vdsmd.in \
+ vdsm-logrotate \
+ vdsm-logrotate.conf \
+ vdsm-restore-net-config.in \
+ vdsm.rwtab \
+ vdsm-sosplugin.py.in \
+ vdsm-store-net-config.in
+
+# Reference:
+# http://www.gnu.org/software/automake/manual/html_node/Scripts.html
+do_subst = sed -e "s,[@]CONFDIR[@],$(vdsmconfdir),g" \
+ -e "s,[@]VDSMLOGDIR[@],$(vdsmlogdir),g" \
+ -e "s,[@]VDSMDIR[@],$(vdsmdir),g" \
+ -e "s,[@]HOOKSDIR[@],$(vdsmhooksdir),g" \
+ -e "s,[@]VDSMRUNDIR[@],$(vdsmrundir),g" \
+ -e "s,[@]VDSMLIBDIR[@],$(vdsmlibdir),g" \
+ -e "s,[@]POOLSDIR[@],$(vdsmpoolsdir),g" \
+ -e "s,[@]BACKUPDIR[@],$(vdsmbackupdir),g" \
+ -e "s,[@]LIBEXECDIR[@],$(vdsmexecdir),g" \
+ -e "s,[@]TRUSTSTORE[@],$(vdsmtsdir),g"
+
+$(vdsm_SUBST): Makefile
+ $(do_subst) < $@.in > $@
+
+vdsm.conf.sample: config.py
+ python mk_vdsm.conf.sample.py > vdsm.conf.sample
+
+install-data-local: install-data-init install-data-logger \
+ install-data-rwtab install-data-logrotate \
+ install-data-sudoers install-data-sosplugin
+ mkdir -p $(DESTDIR)$(vdsmtsdir)/keys
+ mkdir -p $(DESTDIR)$(vdsmtsdir)/certs
+ mkdir -p $(DESTDIR)$(vdsmlogdir)
+ mkdir -p $(DESTDIR)$(vdsmrundir)
+ mkdir -p $(DESTDIR)$(vdsmlibdir)/netconfback
+ mkdir -p $(DESTDIR)$(vdsmpoolsdir)
+ mkdir -p $(DESTDIR)$(vdsmbackupdir)
+ mkdir -p $(DESTDIR)$(localstatedir)/lib/libvirt/qemu/channels
+
+install-data-init: $(vdsm_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/init.d
+ $(INSTALL_SCRIPT) vdsmd $(DESTDIR)$(sysconfdir)/init.d/vdsmd
+
+install-data-logger: $(vdsm_SUBST)
+ mkdir -p $(DESTDIR)$(vdsmconfdir)
+ $(INSTALL_DATA) logger.conf $(DESTDIR)$(vdsmconfdir)/logger.conf
+
+install-data-rwtab: $(vdsm_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/rwtab.d
+ $(INSTALL_DATA) vdsm.rwtab $(DESTDIR)$(sysconfdir)/rwtab.d/vdsm
+
+install-data-logrotate: $(vdsm_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d
+ mkdir -p $(DESTDIR)$(sysconfdir)/cron.hourly
+ $(INSTALL_DATA) vdsm-logrotate.conf \
+ $(DESTDIR)$(sysconfdir)/logrotate.d/vdsm
+ $(INSTALL_SCRIPT) vdsm-logrotate \
+ $(DESTDIR)$(sysconfdir)/cron.hourly/vdsm-logrotate
+
+install-data-sudoers: $(vdsm_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/sudoers.d
+ $(INSTALL_DATA) sudoers.vdsm \
+ $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm
+
+install-data-sosplugin: $(vdsm_SUBST)
+ mkdir -p $(DESTDIR)$(pythondir)/sos/plugins
+ $(INSTALL_DATA) vdsm-sosplugin.py \
+ $(DESTDIR)$(pythondir)/sos/plugins/vdsm.py
diff --git a/vdsm/Makefile.in b/vdsm/Makefile.in
deleted file mode 100644
index 7845b06..0000000
--- a/vdsm/Makefile.in
+++ /dev/null
@@ -1,122 +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
-
-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(a)/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(a)/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 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/storage/Makefile.am b/vdsm/storage/Makefile.am
new file mode 100644
index 0000000..64135cc
--- /dev/null
+++ b/vdsm/storage/Makefile.am
@@ -0,0 +1,57 @@
+# 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.
+#
+
+SUBDIRS = protect
+
+vdsmstoragedir = $(vdsmdir)/storage
+
+dist_vdsmstorage_DATA = \
+ blockSD.py \
+ blockVolume.py \
+ devicemapper.py \
+ dispatcher.py \
+ fileSD.py \
+ fileUtils.py \
+ fileVolume.py \
+ hba.py \
+ hsm.py \
+ image.py \
+ __init__.py \
+ iscsi.py \
+ localFsSD.py \
+ lvm.py \
+ misc.py \
+ multipath.py \
+ nfsSD.py \
+ outOfProcess.py \
+ persistentDict.py \
+ processPool.py \
+ resourceFactories.py \
+ resourceManager.py \
+ safelease.py \
+ sdc.py \
+ sdf.py \
+ sd.py \
+ spm.py \
+ sp.py \
+ storage_connection.py \
+ storageConstants.py \
+ storage_exception.py \
+ storage_mailbox.py \
+ taskManager.py \
+ task.py \
+ threadLocal.py \
+ threadPool.py \
+ volume.py
+
+EXTRA_DIST = 12-vdsm-lvm.rules
+
+install-data-local:
+ mkdir -p $(DESTDIR)$(sysconfdir)/udev/rules.d
+ $(INSTALL_DATA) 12-vdsm-lvm.rules \
+ $(DESTDIR)$(sysconfdir)/udev/rules.d/12-vdsm-lvm.rules
diff --git a/vdsm/storage/protect/Makefile.am b/vdsm/storage/protect/Makefile.am
new file mode 100644
index 0000000..feb40a9
--- /dev/null
+++ b/vdsm/storage/protect/Makefile.am
@@ -0,0 +1,16 @@
+# 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.
+#
+
+vdsmexec_PROGRAMS = safelease
+
+dist_vdsmexec_SCRIPTS = \
+ spmprotect.sh \
+ spmstop.sh
+
+safelease_SOURCES = \
+ safelease.c
diff --git a/vdsm_cli/Makefile b/vdsm_cli/Makefile
deleted file mode 100644
index 287284b..0000000
--- a/vdsm_cli/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2006 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
-
-VDSMDIR = /usr/share/vdsm
-PYSRCS = vdsClient.py vdscli.py dumpStorageTable.py
-CONFDIR = /etc/vdsm
-BINDIR = bin
-VDSMDIR = /usr/share/vdsm
-COMPDIR = /etc/bash_completion.d
-TRUSTSTORE = /etc/pki/vdsm
-MANDIR = /usr/share/man
-
-all: rpm
-
-fixpaths:
- sed -i "s:@VDSMDIR@:$(VDSMDIR):" vdsClient
- sed -i "s:@TRUSTSTORE@:$(TRUSTSTORE):" vdscli.py
-
-install: fixpaths
- $(INSTALL) -Dd $(DESTDIR)/$(VDSMDIR)
- $(INSTALL) -Dm 644 $(PYSRCS) $(DESTDIR)/$(VDSMDIR)
- $(INSTALL) -Dm 755 vdsClient $(DESTDIR)/$(BINDIR)/vdsClient
- $(INSTALL) -Dm 644 vdsClient.completion $(DESTDIR)$(COMPDIR)/vdsClient
- $(INSTALL) -Dm 644 vdsClient.1 $(DESTDIR)$(MANDIR)/man1/vdsClient.1
-
-clean:
- $(RM) *~ *.pyc
diff --git a/vdsm_cli/Makefile.am b/vdsm_cli/Makefile.am
new file mode 100644
index 0000000..a60b193
--- /dev/null
+++ b/vdsm_cli/Makefile.am
@@ -0,0 +1,41 @@
+# Copyright 2006 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.
+#
+
+dist_bin_SCRIPTS = \
+ vdsClient
+
+dist_vdsm_DATA = \
+ dumpStorageTable.py \
+ vdsClient.py \
+ vdscli.py
+
+dist_man1_MANS = vdsClient.1
+
+vdsmcli_SUBST = \
+ vdsClient \
+ vdscli.py
+
+CLEANFILES = $(vdsmcli_SUBST)
+
+EXTRA_DIST = \
+ vdsClient.completion \
+ vdsClient.in \
+ vdscli.py.in
+
+# Reference:
+# http://www.gnu.org/software/automake/manual/html_node/Scripts.html
+do_subst = sed -e "s,[@]VDSMDIR[@],$(vdsmdir),g" \
+ -e "s,[@]TRUSTSTORE[@],$(vdsmtsdir),g"
+
+$(vdsmcli_SUBST):
+ $(do_subst) < $@.in > $@
+
+install-data-local: $(vdsmcli_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/bash_completion.d
+ $(INSTALL_DATA) vdsClient.completion \
+ $(DESTDIR)$(sysconfdir)/bash_completion.d/vdsClient
diff --git a/vdsm_cli/vdsClient b/vdsm_cli/vdsClient
deleted file mode 100755
index 7e306f9..0000000
--- a/vdsm_cli/vdsClient
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-PYTHONPATH="@VDSMDIR@:$PYTHONPATH" python -m vdsClient "$@"
diff --git a/vdsm_cli/vdsClient.in b/vdsm_cli/vdsClient.in
new file mode 100755
index 0000000..7e306f9
--- /dev/null
+++ b/vdsm_cli/vdsClient.in
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+PYTHONPATH="@VDSMDIR@:$PYTHONPATH" python -m vdsClient "$@"
diff --git a/vdsm_cli/vdscli.py b/vdsm_cli/vdscli.py
deleted file mode 100644
index 4507fe1..0000000
--- a/vdsm_cli/vdscli.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# vdscli: contact vdsm running on localhost over xmlrpc easily
-#
-# Copyright 2009-2010 Red Hat, Inc.
-#
-# 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.
-
-import xmlrpclib
-import subprocess
-import os
-
-d_useSSL = False
-d_tsPath = '@TRUSTSTORE@'
-d_addr = '0'
-d_port = '54321'
-
-def __guessDefaults():
- global d_useSSL, d_tsPath, d_addr, d_port
- VDSM_CONF = '/etc/vdsm/vdsm.conf'
- try:
- try:
- from config import config
- config.read(VDSM_CONF)
- d_useSSL = config.getboolean('vars', 'ssl')
- d_tsPath = config.get('vars', 'trust_store_path')
- d_port = config.get('addresses', 'management_port')
- if d_useSSL:
- d_addr = __getLocalVdsName(d_tsPath)
- else:
- if config.get('addresses', 'management_ip'):
- d_addr = config.get('addresses', 'management_ip')
- else:
- import netinfo
- proposed_addr = netinfo.ifconfig()['rhevm']['addr']
- if proposed_addr:
- d_addr = proposed_addr
- except:
- pass
- if os.name == 'nt':
- def getRHEVMInstallPath():
- import _winreg
- key_path = 'SOFTWARE\\RedHat\\RHEVM Service'
- root = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_path)
- val, v_type = _winreg.QueryValueEx(root,"Location")
- retval = os.path.dirname(os.path.dirname(val))
- return str(retval)
- d_tsPath = os.path.join(getRHEVMInstallPath(), "Service", "ca")
- except:
- pass
-
-def __getLocalVdsName(tsPath):
- p = subprocess.Popen(['openssl', 'x509', '-noout', '-subject', '-in',
- '%s/certs/vdsmcert.pem' % tsPath],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
- out, err = p.communicate()
- if p.returncode != 0:
- return '0'
- return out.split('=')[-1].strip()
-
-__guessDefaults()
-
-def cannonizeAddrPort(addrport=None):
- if addrport is None or addrport == '0':
- return d_addr + ':' + d_port
- elif ':' in addrport:
- return addrport
- else:
- return addrport + ':' + d_port
-
-def connect(addrport=None, useSSL=None, tsPath=None):
- addrport = cannonizeAddrPort(addrport)
- if useSSL is None: useSSL = d_useSSL
- if tsPath is None: tsPath = d_tsPath
- if useSSL:
- from M2Crypto.m2xmlrpclib import SSL_Transport
- from M2Crypto import SSL
-
- if os.name == 'nt':
- KEYFILE = tsPath + '\\keys\\rhevm.pem'
- CERTFILE = tsPath + '\\certs\\rhevm.cer'
- CACERT = tsPath + '\\certs\\ca.pem'
- else:
- KEYFILE = tsPath + '/keys/vdsmkey.pem'
- CERTFILE = tsPath + '/certs/vdsmcert.pem'
- CACERT = tsPath + '/certs/cacert.pem'
-
- ctx = SSL.Context ('sslv3')
-
- ctx.set_verify(SSL.verify_peer | SSL.verify_fail_if_no_peer_cert, 16)
- ctx.load_verify_locations(CACERT)
- ctx.load_cert(CERTFILE, KEYFILE, lambda v: "mypass")
-
- server = xmlrpclib.Server('https://%s' % addrport,
- SSL_Transport(ctx))
- else:
- server = xmlrpclib.Server('http://%s' % addrport)
- return server
-
-if __name__ == '__main__':
- print 'connecting to %s:%s ssl %s ts %s' % (d_addr, d_port, d_useSSL, d_tsPath)
- server = connect()
- print server.getVdsCapabilities()
diff --git a/vdsm_cli/vdscli.py.in b/vdsm_cli/vdscli.py.in
new file mode 100644
index 0000000..4507fe1
--- /dev/null
+++ b/vdsm_cli/vdscli.py.in
@@ -0,0 +1,103 @@
+# vdscli: contact vdsm running on localhost over xmlrpc easily
+#
+# Copyright 2009-2010 Red Hat, Inc.
+#
+# 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.
+
+import xmlrpclib
+import subprocess
+import os
+
+d_useSSL = False
+d_tsPath = '@TRUSTSTORE@'
+d_addr = '0'
+d_port = '54321'
+
+def __guessDefaults():
+ global d_useSSL, d_tsPath, d_addr, d_port
+ VDSM_CONF = '/etc/vdsm/vdsm.conf'
+ try:
+ try:
+ from config import config
+ config.read(VDSM_CONF)
+ d_useSSL = config.getboolean('vars', 'ssl')
+ d_tsPath = config.get('vars', 'trust_store_path')
+ d_port = config.get('addresses', 'management_port')
+ if d_useSSL:
+ d_addr = __getLocalVdsName(d_tsPath)
+ else:
+ if config.get('addresses', 'management_ip'):
+ d_addr = config.get('addresses', 'management_ip')
+ else:
+ import netinfo
+ proposed_addr = netinfo.ifconfig()['rhevm']['addr']
+ if proposed_addr:
+ d_addr = proposed_addr
+ except:
+ pass
+ if os.name == 'nt':
+ def getRHEVMInstallPath():
+ import _winreg
+ key_path = 'SOFTWARE\\RedHat\\RHEVM Service'
+ root = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_path)
+ val, v_type = _winreg.QueryValueEx(root,"Location")
+ retval = os.path.dirname(os.path.dirname(val))
+ return str(retval)
+ d_tsPath = os.path.join(getRHEVMInstallPath(), "Service", "ca")
+ except:
+ pass
+
+def __getLocalVdsName(tsPath):
+ p = subprocess.Popen(['openssl', 'x509', '-noout', '-subject', '-in',
+ '%s/certs/vdsmcert.pem' % tsPath],
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
+ out, err = p.communicate()
+ if p.returncode != 0:
+ return '0'
+ return out.split('=')[-1].strip()
+
+__guessDefaults()
+
+def cannonizeAddrPort(addrport=None):
+ if addrport is None or addrport == '0':
+ return d_addr + ':' + d_port
+ elif ':' in addrport:
+ return addrport
+ else:
+ return addrport + ':' + d_port
+
+def connect(addrport=None, useSSL=None, tsPath=None):
+ addrport = cannonizeAddrPort(addrport)
+ if useSSL is None: useSSL = d_useSSL
+ if tsPath is None: tsPath = d_tsPath
+ if useSSL:
+ from M2Crypto.m2xmlrpclib import SSL_Transport
+ from M2Crypto import SSL
+
+ if os.name == 'nt':
+ KEYFILE = tsPath + '\\keys\\rhevm.pem'
+ CERTFILE = tsPath + '\\certs\\rhevm.cer'
+ CACERT = tsPath + '\\certs\\ca.pem'
+ else:
+ KEYFILE = tsPath + '/keys/vdsmkey.pem'
+ CERTFILE = tsPath + '/certs/vdsmcert.pem'
+ CACERT = tsPath + '/certs/cacert.pem'
+
+ ctx = SSL.Context ('sslv3')
+
+ ctx.set_verify(SSL.verify_peer | SSL.verify_fail_if_no_peer_cert, 16)
+ ctx.load_verify_locations(CACERT)
+ ctx.load_cert(CERTFILE, KEYFILE, lambda v: "mypass")
+
+ server = xmlrpclib.Server('https://%s' % addrport,
+ SSL_Transport(ctx))
+ else:
+ server = xmlrpclib.Server('http://%s' % addrport)
+ return server
+
+if __name__ == '__main__':
+ print 'connecting to %s:%s ssl %s ts %s' % (d_addr, d_port, d_useSSL, d_tsPath)
+ server = connect()
+ print server.getVdsCapabilities()
diff --git a/vdsm_hooks/Makefile b/vdsm_hooks/Makefile
deleted file mode 100644
index 9145f4a..0000000
--- a/vdsm_hooks/Makefile
+++ /dev/null
@@ -1,30 +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
-
-SUBDIRS=faqemu vhostmd
-
-HOOKS=before_vm_start after_vm_start before_vm_cont after_vm_cont \
- before_vm_pause after_vm_pause \
- before_vm_hibernate after_vm_hibernate \
- before_vm_dehibernate after_vm_dehibernate \
- before_vm_migrate_source after_vm_migrate_source \
- before_vm_migrate_destination after_vm_migrate_destination \
- after_vm_destroy \
- before_vdsm_start after_vdsm_stop
-
-install:
- (for hook in $(HOOKS); do \
- $(INSTALL) -Dd $(DESTDIR)$(LIBEXECDIR)/hooks/$$hook; \
- done)
- $(INSTALL) -Dm 755 persist-vdsm-hooks $(DESTDIR)$(LIBEXECDIR)/persist-vdsm-hooks
- $(INSTALL) -Dm 755 unpersist-vdsm-hook $(DESTDIR)$(LIBEXECDIR)/unpersist-vdsm-hook
- (for hook in $(SUBDIRS); do \
- make -C $$hook $@; \
- done)
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
new file mode 100644
index 0000000..1a0c766
--- /dev/null
+++ b/vdsm_hooks/Makefile.am
@@ -0,0 +1,37 @@
+# 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.
+#
+
+SUBDIRS = faqemu vhostmd
+
+dist_vdsmexec_SCRIPTS = \
+ persist-vdsm-hooks \
+ unpersist-vdsm-hook
+
+VDSMHOOKS = \
+ before_vm_start \
+ after_vm_start \
+ before_vm_cont \
+ after_vm_cont \
+ before_vm_pause \
+ after_vm_pause \
+ before_vm_hibernate \
+ after_vm_hibernate \
+ before_vm_dehibernate \
+ after_vm_dehibernate \
+ before_vm_migrate_source \
+ after_vm_migrate_source \
+ before_vm_migrate_destination \
+ after_vm_migrate_destination \
+ after_vm_destroy \
+ before_vdsm_start \
+ after_vdsm_stop
+
+install-data-local:
+ (for hook in $(VDSMHOOKS); do \
+ mkdir -p $(DESTDIR)$(vdsmexecdir)/hooks/$$hook; \
+ done)
diff --git a/vdsm_hooks/faqemu/Makefile b/vdsm_hooks/faqemu/Makefile
deleted file mode 100644
index 0ec2515..0000000
--- a/vdsm_hooks/faqemu/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-INSTALL=install
-LN_S=ln -s
-BINDIR=/usr/bin
-LIBEXECDIR=/usr/libexec/vdsm
-HOOKSDIR=$(LIBEXECDIR)/hooks
-
-install:
- $(INSTALL) -Dm 755 qemu $(DESTDIR)$(BINDIR)/qemu
- $(LN_S) qemu $(DESTDIR)$(BINDIR)/qemu-system-x86_64
- $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/10_faqemu
-
-clean:
- $(RM) *~ *.pyc
diff --git a/vdsm_hooks/faqemu/Makefile.am b/vdsm_hooks/faqemu/Makefile.am
new file mode 100644
index 0000000..15519cf
--- /dev/null
+++ b/vdsm_hooks/faqemu/Makefile.am
@@ -0,0 +1,19 @@
+# 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.
+#
+
+dist_bin_SCRIPTS = \
+ qemu
+
+EXTRA_DIST = \
+ before_vm_start.py
+
+install-data-local:
+ mkdir -p $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ $(LN_S) qemu $(DESTDIR)$(bindir)/qemu-system-x86_64
+ $(INSTALL_SCRIPT) before_vm_start.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_start/10_faqemu
diff --git a/vdsm_hooks/vhostmd/Makefile b/vdsm_hooks/vhostmd/Makefile
deleted file mode 100644
index 6f13033..0000000
--- a/vdsm_hooks/vhostmd/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-INSTALL=install
-LN_S=ln -s
-LIBEXECDIR=/usr/libexec/vdsm
-HOOKSDIR=$(LIBEXECDIR)/hooks
-
-all:
-
-install:
- $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/50_vhostmd
- $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_migrate_destination/50_vhostmd
- $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_dehibernate/50_vhostmd
- $(INSTALL) -Dm 755 after_vm_destroy.py $(DESTDIR)$(HOOKSDIR)/after_vm_destroy/50_vhostmd
- $(INSTALL) -Dm 440 sudoers.vdsm_hook_vhostmd $(DESTDIR)/etc/sudoers.d/50_vdsm_hook_vhostmd
-
-clean:
- $(RM) *~ *.pyc
diff --git a/vdsm_hooks/vhostmd/Makefile.am b/vdsm_hooks/vhostmd/Makefile.am
new file mode 100644
index 0000000..f399cb5
--- /dev/null
+++ b/vdsm_hooks/vhostmd/Makefile.am
@@ -0,0 +1,31 @@
+# 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.
+#
+
+EXTRA_DIST = \
+ after_vm_destroy.py \
+ before_vm_start.py \
+ sudoers.vdsm_hook_vhostmd
+
+install-data-local: install-data-sudoers
+ mkdir -p $(DESTDIR)$(vdsmhooksdir)/before_vm_start
+ mkdir -p $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_destination
+ mkdir -p $(DESTDIR)$(vdsmhooksdir)/before_vm_dehibernate
+ mkdir -p $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy
+ $(INSTALL_SCRIPT) before_vm_start.py \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_vhostmd
+ $(INSTALL_SCRIPT) after_vm_destroy.py \
+ $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy/50_vhostmd
+ $(LN_S) ../before_vm_start/50_vhostmd \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_destination/50_vhostmd
+ $(LN_S) ../before_vm_start/50_vhostmd \
+ $(DESTDIR)$(vdsmhooksdir)/before_vm_dehibernate/50_vhostmd
+
+install-data-sudoers:
+ mkdir -p $(DESTDIR)$(sysconfdir)/sudoers.d
+ $(INSTALL_DATA) sudoers.vdsm_hook_vhostmd \
+ $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_vhostmd
diff --git a/vdsm_reg/Makefile b/vdsm_reg/Makefile
deleted file mode 100644
index fd92c48..0000000
--- a/vdsm_reg/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-INSTALL=install
-LN_S=ln -s
-VDSMREGDIR=/usr/share/vdsm-reg
-ETC=/etc
-REGCONFDIR=$(ETC)/vdsm-reg
-VDSMREGLOGDIR=/var/log/vdsm-reg
-VDSMRUNDIR=/var/run/vdsm
-MANDIR=/usr/share/man
-
-FILES=define.py config.py deployUtil.py createDaemon.py
-
-all:
- @echo only \"make install\" is available
- @false
-
-fixpaths:
- sed -i "s:@VDSMRUNDIR@:$(VDSMRUNDIR):" vdsm-reg.conf
-
-install: fixpaths
- $(INSTALL) -Dd $(DESTDIR)$(REGCONFDIR)
- $(INSTALL) -Dd $(DESTDIR)$(VDSMREGDIR)
- $(INSTALL) -Dd $(DESTDIR)$(VDSMREGLOGDIR)
- $(INSTALL) -Dd $(DESTDIR)$(OVIRT_CONFIG_SETUP)
- $(INSTALL) -Dm 755 vdsm-reg $(DESTDIR)$(ETC)/init.d/vdsm-reg
- $(INSTALL) -Dm 644 logger.conf $(DESTDIR)$(REGCONFDIR)/logger.conf
- $(INSTALL) -Dm 644 vdsm-reg.conf $(DESTDIR)$(REGCONFDIR)/vdsm-reg.conf
- $(INSTALL) -Dm 644 $(FILES) $(DESTDIR)$(VDSMREGDIR)
- $(INSTALL) -Dm 755 save-config $(DESTDIR)$(VDSMREGDIR)
- $(INSTALL) -Dm 755 config-rhev-manager $(DESTDIR)$(VDSMREGDIR)
- $(INSTALL) -Dm 755 vdsm-reg-setup.py $(DESTDIR)$(VDSMREGDIR)/vdsm-reg-setup
- $(INSTALL) -Dm 755 vdsm-gen-cert.py $(DESTDIR)$(VDSMREGDIR)/vdsm-gen-cert
- $(INSTALL) -Dm 755 vdsm-complete.py $(DESTDIR)$(VDSMREGDIR)/vdsm-complete
- $(INSTALL) -Dm 755 vdsm-upgrade.py $(DESTDIR)$(VDSMREGDIR)/vdsm-upgrade
- $(INSTALL) -Dd $(DESTDIR)$(ETC)/ovirt-config-setup.d
- $(LN_S) $(VDSMREGDIR)/config-rhev-manager \
- "$(DESTDIR)$(ETC)/ovirt-config-setup.d/40_Configure the host for RHEV"
- $(INSTALL) -Dm 755 vdsm-config $(DESTDIR)$(ETC)/ovirt-config-boot.d/vdsm-config
- $(INSTALL) -Dm 644 vdsm-reg-logrotate.conf $(DESTDIR)$(ETC)/logrotate.d/vdsm-reg
- $(INSTALL) -Dm 755 vdsm-reg-logrotate $(DESTDIR)$(ETC)/cron.hourly
- $(INSTALL) -Dm 644 vdsm-reg.8 $(DESTDIR)$(MANDIR)/man8/vdsm-reg.8
- $(INSTALL) -Dm 644 rhevm.py $(DESTDIR)$(OVIRT_CONFIG_SETUP)/rhevm.py
diff --git a/vdsm_reg/Makefile.am b/vdsm_reg/Makefile.am
new file mode 100644
index 0000000..20ed81c
--- /dev/null
+++ b/vdsm_reg/Makefile.am
@@ -0,0 +1,77 @@
+# 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.
+#
+
+dist_vdsmreg_DATA = \
+ config.py \
+ createDaemon.py \
+ define.py \
+ deployUtil.py
+
+dist_vdsmreg_SCRIPTS = \
+ config-rhev-manager \
+ save-config \
+ vdsm-complete \
+ vdsm-gen-cert \
+ vdsm-reg-setup \
+ vdsm-upgrade
+
+dist_man8_MANS = vdsm-reg.8
+
+noinst_DATA = \
+ vdsm-reg.conf
+
+vdsmreg_SUBST = \
+ $(noinst_DATA)
+
+CLEANFILES = $(vdsmreg_SUBST)
+
+EXTRA_DIST = \
+ logger.conf \
+ rhevm.py \
+ vdsm-config \
+ vdsm-reg \
+ vdsm-reg.conf.in \
+ vdsm-reg-logrotate \
+ vdsm-reg-logrotate.conf
+
+# Reference:
+# http://www.gnu.org/software/automake/manual/html_node/Scripts.html
+do_subst = sed -e "s,[@]VDSMRUNDIR[@],$(vdsmrundir),g"
+
+$(vdsmreg_SUBST):
+ $(do_subst) < $@.in > $@
+
+install-data-local: install-data-init install-data-logger install-data-ovirt \
+ install-data-logrotate
+ mkdir -p $(DESTDIR)$(vdsmreglogdir)
+
+install-data-init: $(vdsmreg_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/init.d
+ $(INSTALL_SCRIPT) vdsm-reg $(DESTDIR)$(sysconfdir)/init.d/vdsm-reg
+
+install-data-logger: $(vdsmreg_SUBST)
+ mkdir -p $(DESTDIR)$(vdsmregconfdir)
+ $(INSTALL_DATA) logger.conf $(DESTDIR)$(vdsmregconfdir)/logger.conf
+ $(INSTALL_DATA) vdsm-reg.conf $(DESTDIR)$(vdsmregconfdir)/vdsm-reg.conf
+
+install-data-ovirt: $(vdsmreg_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/ovirt-config-boot.d
+ mkdir -p $(DESTDIR)$(sysconfdir)/ovirt-config-setup.d
+ mkdir -p $(DESTDIR)$(pythondir)/ovirt_config_setup
+ $(LN_S) $(VDSMREGDIR)/config-rhev-manager \
+ $(DESTDIR)$(sysconfdir)/ovirt-config-setup.d/"40_Configure the host for RHEV"
+ $(INSTALL_SCRIPT) vdsm-config $(DESTDIR)$(sysconfdir)/ovirt-config-boot.d/vdsm-config
+ $(INSTALL_DATA) rhevm.py $(DESTDIR)$(pythondir)/ovirt_config_setup/rhevm.py
+
+install-data-logrotate: $(vdsmreg_SUBST)
+ mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d
+ mkdir -p $(DESTDIR)$(sysconfdir)/cron.hourly
+ $(INSTALL_DATA) vdsm-reg-logrotate.conf \
+ $(DESTDIR)$(sysconfdir)/logrotate.d/vdsm-reg
+ $(INSTALL_SCRIPT) vdsm-reg-logrotate \
+ $(DESTDIR)$(sysconfdir)/cron.hourly/vdsm-reg-logrotate
diff --git a/vdsm_reg/vdsm-complete b/vdsm_reg/vdsm-complete
new file mode 100755
index 0000000..316925e
--- /dev/null
+++ b/vdsm_reg/vdsm-complete
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+#
+# 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.
+#
+
+import sys
+import getopt
+import logging
+import logging.config
+from time import strftime
+import deployUtil
+
+VDSM_CONF_FILE = '/etc/vdsm/vdsm.conf'
+log_filename = '/var/log/vdsm-reg/vds_bootstrap_complete.'+strftime("%Y%m%d_%H%M%S")+'.log'
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s %(levelname)-8s %(message)s',
+ datefmt='%a, %d %b %Y %H:%M:%S',
+ filename=log_filename,
+ filemode='w')
+
+def reboot(act=1):
+ """ Reboot.
+ """
+ logging.debug("Reboot: started.")
+ action = 'Reboot'
+ message = 'Rebooting machine'
+
+ if (act==1):
+ deployUtil.reboot()
+ else:
+ action = 'Restart'
+ message = 'Restarting vdsmd service'
+ deployUtil.setService("vdsmd", "restart")
+
+ print "<BSTRAP component='" + action + "' status='OK' message='" + message + "' />"
+ sys.stdout.flush()
+ logging.debug("Reboot: ended.")
+
+def main():
+ """Usage: ovirt-vdsm-complete.py [-c vds_config_str] <random_num> [reboot]"""
+ try:
+ vds_config_str = None
+ opts, args = getopt.getopt(sys.argv[1:], "c:")
+ for o,v in opts:
+ if o == "-c":
+ # it should looks like: 'ssl=true;ksm_nice=5;images=/images/irsd'
+ # without white spaces in it.
+ vds_config_str = v
+
+ rnum = args[0]
+ except:
+ print main.__doc__
+ return 0
+ try:
+ act = args[1]
+ except:
+ act = 1
+
+ fOK = True
+ try:
+ fOK = deployUtil.instCert(rnum, VDSM_CONF_FILE)
+ if fOK:
+ fOK = deployUtil.setCoreDumpPath()
+
+ if fOK:
+ fOK = deployUtil.cleanAll(rnum)
+
+ if fOK:
+ fOK = deployUtil.setVdsConf(vds_config_str, VDSM_CONF_FILE)
+
+ if fOK:
+ deployUtil.setService("vdsmd", "reconfigure")
+ reboot(act)
+ except:
+ fOK = False
+
+ if not fOK:
+ print "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
+ logging.debug("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
+
+ else:
+ print "<BSTRAP component='RHEV_INSTALL' status='OK'/>"
+ logging.debug("<BSTRAP component='RHEV_INSTALL' status='OK'/>")
+
+ sys.stdout.flush()
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/vdsm_reg/vdsm-complete.py b/vdsm_reg/vdsm-complete.py
deleted file mode 100755
index 316925e..0000000
--- a/vdsm_reg/vdsm-complete.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-
-import sys
-import getopt
-import logging
-import logging.config
-from time import strftime
-import deployUtil
-
-VDSM_CONF_FILE = '/etc/vdsm/vdsm.conf'
-log_filename = '/var/log/vdsm-reg/vds_bootstrap_complete.'+strftime("%Y%m%d_%H%M%S")+'.log'
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(levelname)-8s %(message)s',
- datefmt='%a, %d %b %Y %H:%M:%S',
- filename=log_filename,
- filemode='w')
-
-def reboot(act=1):
- """ Reboot.
- """
- logging.debug("Reboot: started.")
- action = 'Reboot'
- message = 'Rebooting machine'
-
- if (act==1):
- deployUtil.reboot()
- else:
- action = 'Restart'
- message = 'Restarting vdsmd service'
- deployUtil.setService("vdsmd", "restart")
-
- print "<BSTRAP component='" + action + "' status='OK' message='" + message + "' />"
- sys.stdout.flush()
- logging.debug("Reboot: ended.")
-
-def main():
- """Usage: ovirt-vdsm-complete.py [-c vds_config_str] <random_num> [reboot]"""
- try:
- vds_config_str = None
- opts, args = getopt.getopt(sys.argv[1:], "c:")
- for o,v in opts:
- if o == "-c":
- # it should looks like: 'ssl=true;ksm_nice=5;images=/images/irsd'
- # without white spaces in it.
- vds_config_str = v
-
- rnum = args[0]
- except:
- print main.__doc__
- return 0
- try:
- act = args[1]
- except:
- act = 1
-
- fOK = True
- try:
- fOK = deployUtil.instCert(rnum, VDSM_CONF_FILE)
- if fOK:
- fOK = deployUtil.setCoreDumpPath()
-
- if fOK:
- fOK = deployUtil.cleanAll(rnum)
-
- if fOK:
- fOK = deployUtil.setVdsConf(vds_config_str, VDSM_CONF_FILE)
-
- if fOK:
- deployUtil.setService("vdsmd", "reconfigure")
- reboot(act)
- except:
- fOK = False
-
- if not fOK:
- print "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
- logging.debug("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
-
- else:
- print "<BSTRAP component='RHEV_INSTALL' status='OK'/>"
- logging.debug("<BSTRAP component='RHEV_INSTALL' status='OK'/>")
-
- sys.stdout.flush()
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/vdsm_reg/vdsm-gen-cert b/vdsm_reg/vdsm-gen-cert
new file mode 100755
index 0000000..f41fe00
--- /dev/null
+++ b/vdsm_reg/vdsm-gen-cert
@@ -0,0 +1,102 @@
+#!/usr/bin/python
+# Script to complete vdsm installation.
+# Input: certificate subject + current random ID.
+# Output: stdout as XML format
+#
+# Steps to perform: Initiate Certificate Initalization
+# a. Clean previous certificates / keys.
+# b. Generate certificate and sign request
+#
+
+import sys
+import getopt
+#import pwd
+#import errno
+#from stat import *
+from time import strftime
+import logging
+import logging.config
+import traceback
+import random
+import ConfigParser
+import deployUtil
+
+rnum = random.randint(100,1000000).__repr__()
+log_filename = '/var/log/vdsm-reg/vds_bootstrap_gen.'+strftime("%Y%m%d_%H%M%S")+'.log'
+
+logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s %(levelname)-8s %(message)s',
+ datefmt='%a, %d %b %Y %H:%M:%S',
+ filename=log_filename,
+ filemode='w')
+
+class CSR:
+ """
+ Makes sure that vdsmd has its Certificate in place
+ """
+ def __init__(self, sub='', num='', orgName='Red Hat, Inc.'):
+ self.orgName = orgName
+ self.subject = sub
+ self.random_num = num
+
+ # NOTE: /etc/vdsm/vdsm.conf must exist (Should exist after rpms are isntalled)
+ config = ConfigParser.ConfigParser()
+ config.read('/etc/vdsm/vdsm.conf')
+ try:
+ tsDir = config.get('vars', 'trust_store_path')
+ except:
+ tsDir = '/etc/pki/vdsm'
+
+ self.tsDir = tsDir
+ self.VDSMKEY = tsDir + "/keys/vdsmkey.pem"
+ self.VDSMCERT = tsDir + "/certs/vdsm-" + sub + "-cert.pem"
+ self.DHKEY = tsDir + '/keys/dh.pem'
+
+ def xmlOutput(self):
+ print "<BSTRAP component='Encryption setup' status='OK'/>"
+ logging.debug("<BSTRAP component='Encryption setup' status='OK'/>")
+ sys.stdout.flush()
+
+ def runTest(self):
+ deployUtil.pkiCleanup(self.VDSMKEY, self.VDSMCERT)
+ deployUtil.createCSR(self.orgName, self.subject, self.random_num, self.tsDir, self.VDSMKEY, self.DHKEY)
+ self.xmlOutput()
+
+def main():
+ """Usage: vdsm-gen-cert [-O organizationName] <subject> <random_num>"""
+ try:
+ orgName = 'Red Hat, Inc.'
+ opts, args = getopt.getopt(sys.argv[1:], "O:")
+ for o,v in opts:
+ if o == "-O":
+ orgName = v
+ subject = args[0]
+ random_num = args[1]
+ except:
+ print main.__doc__
+ return 0
+
+ try:
+ CSR(subject, random_num, orgName).runTest()
+ ret = True
+ except:
+ logging.error(traceback.format_exc())
+ logging.error(main.__doc__)
+ logging.debug("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
+ print "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
+
+ return 0
+ else:
+ if not ret:
+ print "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
+ logging.debug("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
+
+ else:
+ print "<BSTRAP component='RHEV_INSTALL' status='OK'/>"
+ logging.debug("<BSTRAP component='RHEV_INSTALL' status='OK'/>")
+
+ sys.stdout.flush()
+
+if __name__ == "__main__":
+ sys.exit(main())
+
diff --git a/vdsm_reg/vdsm-gen-cert.py b/vdsm_reg/vdsm-gen-cert.py
deleted file mode 100755
index f41fe00..0000000
--- a/vdsm_reg/vdsm-gen-cert.py
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/python
-# Script to complete vdsm installation.
-# Input: certificate subject + current random ID.
-# Output: stdout as XML format
-#
-# Steps to perform: Initiate Certificate Initalization
-# a. Clean previous certificates / keys.
-# b. Generate certificate and sign request
-#
-
-import sys
-import getopt
-#import pwd
-#import errno
-#from stat import *
-from time import strftime
-import logging
-import logging.config
-import traceback
-import random
-import ConfigParser
-import deployUtil
-
-rnum = random.randint(100,1000000).__repr__()
-log_filename = '/var/log/vdsm-reg/vds_bootstrap_gen.'+strftime("%Y%m%d_%H%M%S")+'.log'
-
-logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(levelname)-8s %(message)s',
- datefmt='%a, %d %b %Y %H:%M:%S',
- filename=log_filename,
- filemode='w')
-
-class CSR:
- """
- Makes sure that vdsmd has its Certificate in place
- """
- def __init__(self, sub='', num='', orgName='Red Hat, Inc.'):
- self.orgName = orgName
- self.subject = sub
- self.random_num = num
-
- # NOTE: /etc/vdsm/vdsm.conf must exist (Should exist after rpms are isntalled)
- config = ConfigParser.ConfigParser()
- config.read('/etc/vdsm/vdsm.conf')
- try:
- tsDir = config.get('vars', 'trust_store_path')
- except:
- tsDir = '/etc/pki/vdsm'
-
- self.tsDir = tsDir
- self.VDSMKEY = tsDir + "/keys/vdsmkey.pem"
- self.VDSMCERT = tsDir + "/certs/vdsm-" + sub + "-cert.pem"
- self.DHKEY = tsDir + '/keys/dh.pem'
-
- def xmlOutput(self):
- print "<BSTRAP component='Encryption setup' status='OK'/>"
- logging.debug("<BSTRAP component='Encryption setup' status='OK'/>")
- sys.stdout.flush()
-
- def runTest(self):
- deployUtil.pkiCleanup(self.VDSMKEY, self.VDSMCERT)
- deployUtil.createCSR(self.orgName, self.subject, self.random_num, self.tsDir, self.VDSMKEY, self.DHKEY)
- self.xmlOutput()
-
-def main():
- """Usage: vdsm-gen-cert [-O organizationName] <subject> <random_num>"""
- try:
- orgName = 'Red Hat, Inc.'
- opts, args = getopt.getopt(sys.argv[1:], "O:")
- for o,v in opts:
- if o == "-O":
- orgName = v
- subject = args[0]
- random_num = args[1]
- except:
- print main.__doc__
- return 0
-
- try:
- CSR(subject, random_num, orgName).runTest()
- ret = True
- except:
- logging.error(traceback.format_exc())
- logging.error(main.__doc__)
- logging.debug("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
- print "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
-
- return 0
- else:
- if not ret:
- print "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
- logging.debug("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
-
- else:
- print "<BSTRAP component='RHEV_INSTALL' status='OK'/>"
- logging.debug("<BSTRAP component='RHEV_INSTALL' status='OK'/>")
-
- sys.stdout.flush()
-
-if __name__ == "__main__":
- sys.exit(main())
-
diff --git a/vdsm_reg/vdsm-reg-setup b/vdsm_reg/vdsm-reg-setup
new file mode 100755
index 0000000..b1015b8
--- /dev/null
+++ b/vdsm_reg/vdsm-reg-setup
@@ -0,0 +1,303 @@
+#!/usr/bin/python
+# Script to setup basic vdsm environment and register the VDSM with VDC.
+# Input: none.
+# Output: none.
+#
+# Steps to perform: Initiate Certificate Initalization
+# a. Find menagement bridge and rename it to rhevm.
+# b. Create .ssh directory and fetch authorized_keys
+# c. Call VDC registration.
+# d. Set time according to rhev-m time.
+
+import sys
+import getopt
+import os
+import socket
+import httplib
+import time
+import logging
+import logging.config
+import traceback
+import urllib
+import ssl
+from config import config
+import deployUtil
+import createDaemon
+
+DEFAULT_CONFIG_FILE="/etc/vdsm-reg/vdsm-reg.conf"
+VDSM_CONF="/etc/vdsm/vdsm.conf"
+SCRIPT_NAME_SAVE="vdsm-store-net-config"
+MGT_BRIDGE_NAME="rhevm"
+
+class Setup:
+ """
+ Makes sure that vdsmd has its Certificate in place
+ """
+ def __init__(self):
+ logging.debug("__init__ begin.")
+ self.registered = False
+ self.fInitOK = True
+ self.vdcURL = "None"
+ self.vdcName = config.get('vars', 'vdc_host_name')
+ if self.vdcName != "None":
+ try: self.vdcURL = socket.gethostbyname(self.vdcName)
+ except: self.vdcURL = "None"
+ else:
+ self.vdcURL = config.get('vars', 'vdc_host_ip')
+
+ self.vdsmDir = config.get('vars', 'vdsm_dir')
+ if self.vdcURL != "None":
+ self.ovirtURL = deployUtil.getMGTIP(self.vdsmDir, self.vdcName)
+ self.ovirtName = socket.getfqdn()
+ self.ovirtUID = deployUtil.getHostID()
+ else:
+ self.ovirtURL = "None"
+ self.ovirtName = "None"
+ self.ovirtUID = "None"
+
+ self.vdcPORT = config.get('vars', 'vdc_host_port')
+ self.vdcURI = config.get('vars', 'vdc_reg_uri')
+ self.vdcRegPort = config.get('vars', 'vdc_reg_port')
+ self.VDCTime = None
+ logging.debug("Setup::__init__ vars:" +
+ "\n\tself.vdcURL " + self.vdcURL +
+ "\n\tself.vdcPORT " + self.vdcPORT +
+ "\n\tself.vdcURI " + self.vdcURI +
+ "\n\tself.vdcRegPort " + self.vdcRegPort +
+ "\n\tself.ovirtURL " + self.ovirtURL +
+ "\n\tself.ovirtName " + self.ovirtName +
+ "\n\tself.ovirtUID " + self.ovirtUID +
+ "\n\tself.vdcName " + self.vdcName
+ )
+
+ def validateData(self):
+ logging.debug("validate start")
+ fReturn = True
+
+ if self.ovirtURL == None or self.ovirtURL == "" or self.ovirtURL == "None" or \
+ self.ovirtName == None or self.ovirtName == "" or self.ovirtName == "None":
+ fReturn = False
+
+ logging.debug("validate end. return: " + str(fReturn))
+ return fReturn
+
+ def renameBridge(self):
+ """
+ Rename oVirt default bridge to rhevm bridge.
+ """
+ logging.debug("renameBridge begin.")
+ fReturn = True
+
+ #Rename existing bridge
+ fReturn = deployUtil.makeBridge(self.vdcName, self.vdsmDir)
+ if not fReturn:
+ logging.error("renameBridge Failed to rename existing bridge!")
+
+ #Persist changes
+ if fReturn:
+ try:
+ out, err, ret = deployUtil._logExec([os.path.join(self.vdsmDir, SCRIPT_NAME_SAVE)])
+ if ret:
+ fReturn = False
+ logging.error("renameBridge Failed to persist rhevm bridge changes. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
+ except:
+ fReturn = False
+ logging.error("renameBridge Failed to persist bridge changes. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
+
+ #Fix file permissions to relevant mask
+ if fReturn:
+ try:
+ os.chmod("/config/etc/sysconfig/network-scripts/ifcfg-" + MGT_BRIDGE_NAME, 0644)
+ except:
+ fReturn = False
+ logging.error("renameBridge: failed to chmod bridge file")
+
+ logging.debug("renameBridge return.")
+ return fReturn
+
+ def registerVDS(self):
+ logging.debug("registerVDS begin.")
+
+ strFullURI = (
+ self.vdcURI + "?vds_ip=" + urllib.quote(self.ovirtURL) +
+ "&vds_name=" + urllib.quote(self.ovirtName) +
+ "&vds_unique_id=" + urllib.quote(self.ovirtUID) +
+ "&port=" + urllib.quote(self.vdcRegPort) +
+ "&__VIEWSTATE="
+ )
+ logging.debug("registerVDS URI= " + strFullURI + "\n")
+ if self.ovirtUID == "None" and "localhost.localdomain" in self.ovirtName:
+ logging.warn("WARNING! registering RHEV-H with no UUID and no unique host-name!")
+
+ fReturn = True
+ res = None
+ nTimeout = int(config.get('vars', 'test_socket_timeout'))
+ old_timeout = socket.getdefaulttimeout()
+ socket.setdefaulttimeout(nTimeout)
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+ try:
+ sock.connect((self.vdcURL, int(self.vdcPORT)))
+ conn = httplib.HTTPSConnection(self.vdcURL + ":" + self.vdcPORT)
+ conn.sock = ssl.wrap_socket(sock)
+ conn.request("GET", strFullURI)
+ res = conn.getresponse()
+ except:
+ logging.debug("registerVDS failed in HTTPS. Retrying using HTTP.")
+ try:
+ conn = None
+ conn = httplib.HTTPConnection(self.vdcURL + ":" + self.vdcPORT)
+ conn.request("GET", strFullURI)
+ res = conn.getresponse()
+ logging.debug("registerVDS succeeded using HTTP.")
+ except:
+ fReturn = False
+ logging.error("registerVDS failed using HTTP!")
+ logging.error(traceback.format_exc())
+
+ else:
+ logging.debug("registerVDS status: " + str(res.status) +
+ " reason: " + res.reason
+ )
+
+ if res == None or res.status != 200:
+ if conn != None: conn.close()
+ fReturn = False
+
+ if fReturn:
+ try:
+ try:
+ self.VDCTime = res.read()
+ logging.debug("registerVDS time read: " + str(self.VDCTime))
+ except:
+ fReturn = False
+ logging.error(traceback.format_exc())
+ finally:
+ if conn != None: conn.close()
+
+ socket.setdefaulttimeout(old_timeout)
+ logging.debug("registerVDS end.")
+ return fReturn
+
+ def execute(self):
+ fOK = True
+ fOKNow = True
+ logging.debug("execute start.")
+ self.registered = False
+
+ if deployUtil.preventDuplicate():
+ logging.debug("execute: found existing management bridge. Skipping rename.")
+ else:
+ fOK = self.renameBridge()
+ logging.debug("execute: after renameBridge: " + str(fOK))
+
+ if fOK:
+ strKey = deployUtil.getAuthKeysFile(self.vdcURL, self.vdcPORT)
+ if strKey is not None:
+ fOKNow = deployUtil.handleSSHKey(strKey)
+ else:
+ fOKNow = False
+ fOK = fOK and fOKNow
+ logging.debug("execute: after getAuthKeysFile: " + str(fOK))
+
+ if fOK:
+ fOKNow = self.registerVDS()
+ fOK = fOK and fOKNow
+ logging.debug("execute: after registerVDS: " + str(fOK))
+
+ if fOK:
+ self.registered = True
+
+ logging.debug("Registration status:" +
+ str(self.registered)
+ )
+
+ # Utility settings. This will not fail the registration process.
+ if self.registered == True:
+ fOK = (fOK and deployUtil.setHostTime(self.VDCTime))
+ if fOK:
+ logging.debug("Node time in sync with RHEVM server")
+ else:
+ logging.warning("Node time failed to sync with RHEVM server. This may cause problems !")
+
+def run(confFile, daemonize):
+ #print "entered run(conf='%s', daemonize='%s')"%(confFile,str(daemonize))
+ import random
+
+ registered = False
+ log = None
+ pidfile = False
+ try:
+ try:
+ config.read([confFile])
+ loggerConf = config.get('vars','logger_conf')
+ vdsmDir = config.get('vars', 'vdsm_dir')
+ pidfile = config.get('vars','pidfile')
+ sleepTime = float(config.get('vars','reg_req_interval'))
+ sys.path.append(vdsmDir)
+
+ if daemonize:
+ createDaemon.createDaemon()
+ #set up logger
+ logging.config.fileConfig(loggerConf)
+ log = logging.getLogger('')
+ if daemonize:
+ log = logging.getLogger('vdsRegistrator')
+ if not daemonize:
+ log.handlers.append(logging.StreamHandler())
+
+ log.info("After daemonize - My pid is " + str(os.getpid()))
+ file(pidfile, 'w').write(str(os.getpid()) + "\n")
+ os.chmod(pidfile, 0664)
+
+ itr = 0
+ while daemonize and not registered:
+ oSetup = Setup()
+ if oSetup.validateData():
+ oSetup.execute()
+ registered = oSetup.registered;
+ oSetup = None
+ itr += 1
+ nRandom = random.randint(1, 5)
+ if not registered:
+ # wait random time, so multiple machines access randomly.
+ time.sleep(sleepTime + nRandom)
+
+ log.debug("Total retry count: %d, waited: %d seconds." % (itr, sleepTime+nRandom))
+ except:
+ if log is not None:
+ log.error(traceback.format_exc())
+ finally:
+ if pidfile and os.path.exists(pidfile):
+ os.unlink(pidfile)
+ if log:
+ log.info("Exiting ....")
+
+def usage():
+ print "Usage: %s [-c <config_file>]"
+ print " -c - configuration file"
+ print " -l - run local (= no daemon)"
+ print " -h,--help - prints this usage"
+
+if __name__ == "__main__":
+ config_file = DEFAULT_CONFIG_FILE
+ daemonize = True
+ try:
+ opts,args = getopt.getopt(sys.argv[1:], "hc:l",["help"])
+ for o,v in opts:
+ if o == "-h" or o == "--help":
+ usage()
+ sys.exit(0)
+ elif o == "-c":
+ config_file = v
+ if not os.path.exists(config_file):
+ print "ERROR: file %s does not exist"%(config_file)
+ usage()
+ sys.exit(1)
+ elif o == "-l":
+ daemonize = False
+ except getopt.GetoptError,e:
+ print "ERROR: '%s'"%(e.msg)
+ usage()
+ sys.exit(1)
+ run(config_file, daemonize)
diff --git a/vdsm_reg/vdsm-reg-setup.py b/vdsm_reg/vdsm-reg-setup.py
deleted file mode 100755
index b1015b8..0000000
--- a/vdsm_reg/vdsm-reg-setup.py
+++ /dev/null
@@ -1,303 +0,0 @@
-#!/usr/bin/python
-# Script to setup basic vdsm environment and register the VDSM with VDC.
-# Input: none.
-# Output: none.
-#
-# Steps to perform: Initiate Certificate Initalization
-# a. Find menagement bridge and rename it to rhevm.
-# b. Create .ssh directory and fetch authorized_keys
-# c. Call VDC registration.
-# d. Set time according to rhev-m time.
-
-import sys
-import getopt
-import os
-import socket
-import httplib
-import time
-import logging
-import logging.config
-import traceback
-import urllib
-import ssl
-from config import config
-import deployUtil
-import createDaemon
-
-DEFAULT_CONFIG_FILE="/etc/vdsm-reg/vdsm-reg.conf"
-VDSM_CONF="/etc/vdsm/vdsm.conf"
-SCRIPT_NAME_SAVE="vdsm-store-net-config"
-MGT_BRIDGE_NAME="rhevm"
-
-class Setup:
- """
- Makes sure that vdsmd has its Certificate in place
- """
- def __init__(self):
- logging.debug("__init__ begin.")
- self.registered = False
- self.fInitOK = True
- self.vdcURL = "None"
- self.vdcName = config.get('vars', 'vdc_host_name')
- if self.vdcName != "None":
- try: self.vdcURL = socket.gethostbyname(self.vdcName)
- except: self.vdcURL = "None"
- else:
- self.vdcURL = config.get('vars', 'vdc_host_ip')
-
- self.vdsmDir = config.get('vars', 'vdsm_dir')
- if self.vdcURL != "None":
- self.ovirtURL = deployUtil.getMGTIP(self.vdsmDir, self.vdcName)
- self.ovirtName = socket.getfqdn()
- self.ovirtUID = deployUtil.getHostID()
- else:
- self.ovirtURL = "None"
- self.ovirtName = "None"
- self.ovirtUID = "None"
-
- self.vdcPORT = config.get('vars', 'vdc_host_port')
- self.vdcURI = config.get('vars', 'vdc_reg_uri')
- self.vdcRegPort = config.get('vars', 'vdc_reg_port')
- self.VDCTime = None
- logging.debug("Setup::__init__ vars:" +
- "\n\tself.vdcURL " + self.vdcURL +
- "\n\tself.vdcPORT " + self.vdcPORT +
- "\n\tself.vdcURI " + self.vdcURI +
- "\n\tself.vdcRegPort " + self.vdcRegPort +
- "\n\tself.ovirtURL " + self.ovirtURL +
- "\n\tself.ovirtName " + self.ovirtName +
- "\n\tself.ovirtUID " + self.ovirtUID +
- "\n\tself.vdcName " + self.vdcName
- )
-
- def validateData(self):
- logging.debug("validate start")
- fReturn = True
-
- if self.ovirtURL == None or self.ovirtURL == "" or self.ovirtURL == "None" or \
- self.ovirtName == None or self.ovirtName == "" or self.ovirtName == "None":
- fReturn = False
-
- logging.debug("validate end. return: " + str(fReturn))
- return fReturn
-
- def renameBridge(self):
- """
- Rename oVirt default bridge to rhevm bridge.
- """
- logging.debug("renameBridge begin.")
- fReturn = True
-
- #Rename existing bridge
- fReturn = deployUtil.makeBridge(self.vdcName, self.vdsmDir)
- if not fReturn:
- logging.error("renameBridge Failed to rename existing bridge!")
-
- #Persist changes
- if fReturn:
- try:
- out, err, ret = deployUtil._logExec([os.path.join(self.vdsmDir, SCRIPT_NAME_SAVE)])
- if ret:
- fReturn = False
- logging.error("renameBridge Failed to persist rhevm bridge changes. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
- except:
- fReturn = False
- logging.error("renameBridge Failed to persist bridge changes. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
-
- #Fix file permissions to relevant mask
- if fReturn:
- try:
- os.chmod("/config/etc/sysconfig/network-scripts/ifcfg-" + MGT_BRIDGE_NAME, 0644)
- except:
- fReturn = False
- logging.error("renameBridge: failed to chmod bridge file")
-
- logging.debug("renameBridge return.")
- return fReturn
-
- def registerVDS(self):
- logging.debug("registerVDS begin.")
-
- strFullURI = (
- self.vdcURI + "?vds_ip=" + urllib.quote(self.ovirtURL) +
- "&vds_name=" + urllib.quote(self.ovirtName) +
- "&vds_unique_id=" + urllib.quote(self.ovirtUID) +
- "&port=" + urllib.quote(self.vdcRegPort) +
- "&__VIEWSTATE="
- )
- logging.debug("registerVDS URI= " + strFullURI + "\n")
- if self.ovirtUID == "None" and "localhost.localdomain" in self.ovirtName:
- logging.warn("WARNING! registering RHEV-H with no UUID and no unique host-name!")
-
- fReturn = True
- res = None
- nTimeout = int(config.get('vars', 'test_socket_timeout'))
- old_timeout = socket.getdefaulttimeout()
- socket.setdefaulttimeout(nTimeout)
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-
- try:
- sock.connect((self.vdcURL, int(self.vdcPORT)))
- conn = httplib.HTTPSConnection(self.vdcURL + ":" + self.vdcPORT)
- conn.sock = ssl.wrap_socket(sock)
- conn.request("GET", strFullURI)
- res = conn.getresponse()
- except:
- logging.debug("registerVDS failed in HTTPS. Retrying using HTTP.")
- try:
- conn = None
- conn = httplib.HTTPConnection(self.vdcURL + ":" + self.vdcPORT)
- conn.request("GET", strFullURI)
- res = conn.getresponse()
- logging.debug("registerVDS succeeded using HTTP.")
- except:
- fReturn = False
- logging.error("registerVDS failed using HTTP!")
- logging.error(traceback.format_exc())
-
- else:
- logging.debug("registerVDS status: " + str(res.status) +
- " reason: " + res.reason
- )
-
- if res == None or res.status != 200:
- if conn != None: conn.close()
- fReturn = False
-
- if fReturn:
- try:
- try:
- self.VDCTime = res.read()
- logging.debug("registerVDS time read: " + str(self.VDCTime))
- except:
- fReturn = False
- logging.error(traceback.format_exc())
- finally:
- if conn != None: conn.close()
-
- socket.setdefaulttimeout(old_timeout)
- logging.debug("registerVDS end.")
- return fReturn
-
- def execute(self):
- fOK = True
- fOKNow = True
- logging.debug("execute start.")
- self.registered = False
-
- if deployUtil.preventDuplicate():
- logging.debug("execute: found existing management bridge. Skipping rename.")
- else:
- fOK = self.renameBridge()
- logging.debug("execute: after renameBridge: " + str(fOK))
-
- if fOK:
- strKey = deployUtil.getAuthKeysFile(self.vdcURL, self.vdcPORT)
- if strKey is not None:
- fOKNow = deployUtil.handleSSHKey(strKey)
- else:
- fOKNow = False
- fOK = fOK and fOKNow
- logging.debug("execute: after getAuthKeysFile: " + str(fOK))
-
- if fOK:
- fOKNow = self.registerVDS()
- fOK = fOK and fOKNow
- logging.debug("execute: after registerVDS: " + str(fOK))
-
- if fOK:
- self.registered = True
-
- logging.debug("Registration status:" +
- str(self.registered)
- )
-
- # Utility settings. This will not fail the registration process.
- if self.registered == True:
- fOK = (fOK and deployUtil.setHostTime(self.VDCTime))
- if fOK:
- logging.debug("Node time in sync with RHEVM server")
- else:
- logging.warning("Node time failed to sync with RHEVM server. This may cause problems !")
-
-def run(confFile, daemonize):
- #print "entered run(conf='%s', daemonize='%s')"%(confFile,str(daemonize))
- import random
-
- registered = False
- log = None
- pidfile = False
- try:
- try:
- config.read([confFile])
- loggerConf = config.get('vars','logger_conf')
- vdsmDir = config.get('vars', 'vdsm_dir')
- pidfile = config.get('vars','pidfile')
- sleepTime = float(config.get('vars','reg_req_interval'))
- sys.path.append(vdsmDir)
-
- if daemonize:
- createDaemon.createDaemon()
- #set up logger
- logging.config.fileConfig(loggerConf)
- log = logging.getLogger('')
- if daemonize:
- log = logging.getLogger('vdsRegistrator')
- if not daemonize:
- log.handlers.append(logging.StreamHandler())
-
- log.info("After daemonize - My pid is " + str(os.getpid()))
- file(pidfile, 'w').write(str(os.getpid()) + "\n")
- os.chmod(pidfile, 0664)
-
- itr = 0
- while daemonize and not registered:
- oSetup = Setup()
- if oSetup.validateData():
- oSetup.execute()
- registered = oSetup.registered;
- oSetup = None
- itr += 1
- nRandom = random.randint(1, 5)
- if not registered:
- # wait random time, so multiple machines access randomly.
- time.sleep(sleepTime + nRandom)
-
- log.debug("Total retry count: %d, waited: %d seconds." % (itr, sleepTime+nRandom))
- except:
- if log is not None:
- log.error(traceback.format_exc())
- finally:
- if pidfile and os.path.exists(pidfile):
- os.unlink(pidfile)
- if log:
- log.info("Exiting ....")
-
-def usage():
- print "Usage: %s [-c <config_file>]"
- print " -c - configuration file"
- print " -l - run local (= no daemon)"
- print " -h,--help - prints this usage"
-
-if __name__ == "__main__":
- config_file = DEFAULT_CONFIG_FILE
- daemonize = True
- try:
- opts,args = getopt.getopt(sys.argv[1:], "hc:l",["help"])
- for o,v in opts:
- if o == "-h" or o == "--help":
- usage()
- sys.exit(0)
- elif o == "-c":
- config_file = v
- if not os.path.exists(config_file):
- print "ERROR: file %s does not exist"%(config_file)
- usage()
- sys.exit(1)
- elif o == "-l":
- daemonize = False
- except getopt.GetoptError,e:
- print "ERROR: '%s'"%(e.msg)
- usage()
- sys.exit(1)
- run(config_file, daemonize)
diff --git a/vdsm_reg/vdsm-reg.conf b/vdsm_reg/vdsm-reg.conf
deleted file mode 100644
index f6942fc..0000000
--- a/vdsm_reg/vdsm-reg.conf
+++ /dev/null
@@ -1,20 +0,0 @@
-[vars]
-# time to wait (in seconds) for the next registration request when registration fails
-reg_req_interval = 5
-#The location of the vdsm conf file
-vdsm_conf_file=/etc/vdsm/vdsm.conf
-#The location of the pid file
-pidfile=/var/run/vdsm-reg.pid
-#The logger conf file
-logger_conf=/etc/vdsm-reg/logger.conf
-#The hostname of the vdc, should be verified each boot (look for DNS SRV record)
-vdc_host_name=None
-#The port of the RHEV Manager. Allows http or https connections.
-vdc_host_port=443
-#The ssh file uri
-vdc_authkeys_path=/rhevm.ssh.key.txt
-#The registrtion uri
-vdc_reg_uri=/RHEVManagerWeb/VdsAutoRegistration.aspx
-#Upgrade settings
-upgrade_iso_file=/data/updates/ovirt-node-image.iso
-upgrade_mount_point=@VDSMRUNDIR@/image-update
diff --git a/vdsm_reg/vdsm-reg.conf.in b/vdsm_reg/vdsm-reg.conf.in
new file mode 100644
index 0000000..f6942fc
--- /dev/null
+++ b/vdsm_reg/vdsm-reg.conf.in
@@ -0,0 +1,20 @@
+[vars]
+# time to wait (in seconds) for the next registration request when registration fails
+reg_req_interval = 5
+#The location of the vdsm conf file
+vdsm_conf_file=/etc/vdsm/vdsm.conf
+#The location of the pid file
+pidfile=/var/run/vdsm-reg.pid
+#The logger conf file
+logger_conf=/etc/vdsm-reg/logger.conf
+#The hostname of the vdc, should be verified each boot (look for DNS SRV record)
+vdc_host_name=None
+#The port of the RHEV Manager. Allows http or https connections.
+vdc_host_port=443
+#The ssh file uri
+vdc_authkeys_path=/rhevm.ssh.key.txt
+#The registrtion uri
+vdc_reg_uri=/RHEVManagerWeb/VdsAutoRegistration.aspx
+#Upgrade settings
+upgrade_iso_file=/data/updates/ovirt-node-image.iso
+upgrade_mount_point=@VDSMRUNDIR@/image-update
diff --git a/vdsm_reg/vdsm-upgrade b/vdsm_reg/vdsm-upgrade
new file mode 100755
index 0000000..061e492
--- /dev/null
+++ b/vdsm_reg/vdsm-upgrade
@@ -0,0 +1,185 @@
+#!/usr/bin/python
+#
+# 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.
+#
+
+import errno
+import sys
+import os
+import logging
+import logging.config
+from time import strftime
+import ConfigParser
+import deployUtil
+
+VDSM_CONF_FILE = '/etc/vdsm/vdsm.conf'
+log_filename = '/var/log/vdsm-reg/vds_bootstrap_upgrade.'+strftime("%Y%m%d_%H%M%S")+'.log'
+
+try:
+ logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s %(levelname)-8s %(message)s',
+ datefmt='%a, %d %b %Y %H:%M:%S',
+ filename=log_filename,
+ filemode='w')
+except:
+ log_filename = '/var/log/vds_bootstrap_upgrade.'+strftime("%Y%m%d_%H%M%S")+'.log'
+ logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s %(levelname)-8s %(message)s',
+ datefmt='%a, %d %b %Y %H:%M:%S',
+ filename=log_filename,
+ filemode='w')
+
+def setMountPoint(config):
+ strFile = ""
+ try:
+ strFile = config.get('vars', 'upgrade_iso_file')
+ except:
+ strFile = '/data/updates/ovirt-node-image.iso'
+
+ try:
+ strMountPoint = config.get('vars', 'upgrade_mount_point')
+ except:
+ strMountPoint = '/var/vdsm/image-update'
+
+ try:
+ fOK = True
+ ret = None
+ err = ""
+ out = None
+
+ #First look for the upgrade file
+ if not os.path.exists(strFile):
+ fOK = False
+ msg = "<BSTRAP component='setMountPoint' status='FAIL' message='Upgrade file not found'/>"
+ logging.error(msg)
+ print (msg)
+
+ #Now, check if we need to create a mount-point dir.
+ if fOK and not os.path.exists(strMountPoint):
+ try: os.mkdir(strMountPoint)
+ except OSError, err:
+ if err.errno != errno.EEXIST:
+ fOK = False
+
+ #Now, loop-mount the upgrade iso file.
+ if not fOK:
+ msg = "<BSTRAP component='setMountPoint' status='FAIL' message='Failed to create mount point: " + deployUtil.escapeXML(str(err)) + "'/>"
+ print (msg)
+ logging.error(msg)
+ else:
+ out, err, ret = deployUtil._logExec(["/bin/mount", "-o", "loop", strFile, strMountPoint])
+ fOK = (ret != None and ret == 0)
+
+ msg = ""
+ if fOK:
+ msg = "<BSTRAP component='setMountPoint' status='OK' message='Mount succeeded.'/>"
+ logging.debug(msg)
+ else:
+ msg = "<BSTRAP component='setMountPoint' status='FAIL' message='Failed to mount ISO file: " + deployUtil.escapeXML(str(err)) + "'/>"
+ logging.error(msg)
+ print msg
+ except Exception, e:
+ fOK = False
+ msg = "<BSTRAP component='setMountPoint' status='FAIL' message='setMountPoint exception: " + deployUtil.escapeXML(str(e)) + "'/>"
+ logging.error(msg)
+ print (msg)
+
+ return fOK
+
+def doUpgrade(config):
+ out = None
+ err = None
+ ret = None
+ fReturn = True
+
+ try:
+ strMountPoint = config.get('vars', 'upgrade_mount_point')
+ except:
+ strMountPoint = '/var/vdsm/image-update'
+
+ if os.path.exists("/usr/libexec/ovirt-config-boot"):
+ out, err, ret = deployUtil._logExec(["/usr/libexec/ovirt-config-boot", strMountPoint])
+ else:
+ err = "Can not find /usr/libexec/ovirt-config-boot !"
+
+ if ret == None or ret != 0:
+ msg = "<BSTRAP component='doUpgrade' status='FAIL' message='" + deployUtil.escapeXML(str(err)) + "'/>"
+ print (msg)
+ logging.error(msg)
+ fReturn = False
+ else:
+ msg = "<BSTRAP component='doUpgrade' status='OK' message='Upgrade Succeeded. Rebooting'/>"
+ print (msg)
+ logging.debug(msg)
+
+ return fReturn
+
+def umount(config, shouldReport=True):
+ out = None
+ err = None
+ ret = None
+ fReturn = True
+
+ try:
+ strMountPoint = config.get('vars', 'upgrade_mount_point')
+ except:
+ strMountPoint = '/var/vdsm/image-update'
+
+ if os.path.exists(strMountPoint):
+ out, err, ret = deployUtil._logExec(["/bin/umount", strMountPoint])
+ fReturn = (ret != None and ret == 0)
+
+ if fReturn:
+ msg = "<BSTRAP component='umount' status='OK' message='umount Succeeded'/>"
+ else:
+ msg = "<BSTRAP component='umount' status='FAIL' message=' " + deployUtil.escapeXML(str(err)) + "'/>"
+
+ if shouldReport:
+ print (msg)
+
+ logging.debug(msg)
+ return fReturn
+
+def main():
+ """Usage: vdsm-upgrade """
+ fOK = True
+ fMounted = False
+
+ try:
+ config = ConfigParser.ConfigParser()
+ config.read('/etc/vdsm-reg/vdsm-reg.conf')
+
+ #First, quietly try to clean any previous problems.
+ umount(config, False)
+
+ #Now: Try mounting
+ fOK = setMountPoint(config)
+ if fOK:
+ fMounted = True
+ fOK = doUpgrade(config)
+
+ #Finally, is possible umount current upgrade file.
+ if fMounted:
+ umount(config) #cleanup, may fail in some cases- device busy.
+ except:
+ fOK = False
+
+ if not fOK:
+ msg = "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
+ logging.error("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
+ else:
+ msg = "<BSTRAP component='RHEV_INSTALL' status='OK'/>"
+ logging.debug("<BSTRAP component='RHEV_INSTALL' status='OK'/>")
+ print (msg)
+
+ sys.stdout.flush()
+ return fOK
+
+if __name__ == "__main__":
+ sys.exit(main())
+
diff --git a/vdsm_reg/vdsm-upgrade.py b/vdsm_reg/vdsm-upgrade.py
deleted file mode 100755
index 061e492..0000000
--- a/vdsm_reg/vdsm-upgrade.py
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/usr/bin/python
-#
-# 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.
-#
-
-import errno
-import sys
-import os
-import logging
-import logging.config
-from time import strftime
-import ConfigParser
-import deployUtil
-
-VDSM_CONF_FILE = '/etc/vdsm/vdsm.conf'
-log_filename = '/var/log/vdsm-reg/vds_bootstrap_upgrade.'+strftime("%Y%m%d_%H%M%S")+'.log'
-
-try:
- logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(levelname)-8s %(message)s',
- datefmt='%a, %d %b %Y %H:%M:%S',
- filename=log_filename,
- filemode='w')
-except:
- log_filename = '/var/log/vds_bootstrap_upgrade.'+strftime("%Y%m%d_%H%M%S")+'.log'
- logging.basicConfig(level=logging.DEBUG,
- format='%(asctime)s %(levelname)-8s %(message)s',
- datefmt='%a, %d %b %Y %H:%M:%S',
- filename=log_filename,
- filemode='w')
-
-def setMountPoint(config):
- strFile = ""
- try:
- strFile = config.get('vars', 'upgrade_iso_file')
- except:
- strFile = '/data/updates/ovirt-node-image.iso'
-
- try:
- strMountPoint = config.get('vars', 'upgrade_mount_point')
- except:
- strMountPoint = '/var/vdsm/image-update'
-
- try:
- fOK = True
- ret = None
- err = ""
- out = None
-
- #First look for the upgrade file
- if not os.path.exists(strFile):
- fOK = False
- msg = "<BSTRAP component='setMountPoint' status='FAIL' message='Upgrade file not found'/>"
- logging.error(msg)
- print (msg)
-
- #Now, check if we need to create a mount-point dir.
- if fOK and not os.path.exists(strMountPoint):
- try: os.mkdir(strMountPoint)
- except OSError, err:
- if err.errno != errno.EEXIST:
- fOK = False
-
- #Now, loop-mount the upgrade iso file.
- if not fOK:
- msg = "<BSTRAP component='setMountPoint' status='FAIL' message='Failed to create mount point: " + deployUtil.escapeXML(str(err)) + "'/>"
- print (msg)
- logging.error(msg)
- else:
- out, err, ret = deployUtil._logExec(["/bin/mount", "-o", "loop", strFile, strMountPoint])
- fOK = (ret != None and ret == 0)
-
- msg = ""
- if fOK:
- msg = "<BSTRAP component='setMountPoint' status='OK' message='Mount succeeded.'/>"
- logging.debug(msg)
- else:
- msg = "<BSTRAP component='setMountPoint' status='FAIL' message='Failed to mount ISO file: " + deployUtil.escapeXML(str(err)) + "'/>"
- logging.error(msg)
- print msg
- except Exception, e:
- fOK = False
- msg = "<BSTRAP component='setMountPoint' status='FAIL' message='setMountPoint exception: " + deployUtil.escapeXML(str(e)) + "'/>"
- logging.error(msg)
- print (msg)
-
- return fOK
-
-def doUpgrade(config):
- out = None
- err = None
- ret = None
- fReturn = True
-
- try:
- strMountPoint = config.get('vars', 'upgrade_mount_point')
- except:
- strMountPoint = '/var/vdsm/image-update'
-
- if os.path.exists("/usr/libexec/ovirt-config-boot"):
- out, err, ret = deployUtil._logExec(["/usr/libexec/ovirt-config-boot", strMountPoint])
- else:
- err = "Can not find /usr/libexec/ovirt-config-boot !"
-
- if ret == None or ret != 0:
- msg = "<BSTRAP component='doUpgrade' status='FAIL' message='" + deployUtil.escapeXML(str(err)) + "'/>"
- print (msg)
- logging.error(msg)
- fReturn = False
- else:
- msg = "<BSTRAP component='doUpgrade' status='OK' message='Upgrade Succeeded. Rebooting'/>"
- print (msg)
- logging.debug(msg)
-
- return fReturn
-
-def umount(config, shouldReport=True):
- out = None
- err = None
- ret = None
- fReturn = True
-
- try:
- strMountPoint = config.get('vars', 'upgrade_mount_point')
- except:
- strMountPoint = '/var/vdsm/image-update'
-
- if os.path.exists(strMountPoint):
- out, err, ret = deployUtil._logExec(["/bin/umount", strMountPoint])
- fReturn = (ret != None and ret == 0)
-
- if fReturn:
- msg = "<BSTRAP component='umount' status='OK' message='umount Succeeded'/>"
- else:
- msg = "<BSTRAP component='umount' status='FAIL' message=' " + deployUtil.escapeXML(str(err)) + "'/>"
-
- if shouldReport:
- print (msg)
-
- logging.debug(msg)
- return fReturn
-
-def main():
- """Usage: vdsm-upgrade """
- fOK = True
- fMounted = False
-
- try:
- config = ConfigParser.ConfigParser()
- config.read('/etc/vdsm-reg/vdsm-reg.conf')
-
- #First, quietly try to clean any previous problems.
- umount(config, False)
-
- #Now: Try mounting
- fOK = setMountPoint(config)
- if fOK:
- fMounted = True
- fOK = doUpgrade(config)
-
- #Finally, is possible umount current upgrade file.
- if fMounted:
- umount(config) #cleanup, may fail in some cases- device busy.
- except:
- fOK = False
-
- if not fOK:
- msg = "<BSTRAP component='RHEV_INSTALL' status='FAIL'/>"
- logging.error("<BSTRAP component='RHEV_INSTALL' status='FAIL'/>")
- else:
- msg = "<BSTRAP component='RHEV_INSTALL' status='OK'/>"
- logging.debug("<BSTRAP component='RHEV_INSTALL' status='OK'/>")
- print (msg)
-
- sys.stdout.flush()
- return fOK
-
-if __name__ == "__main__":
- sys.exit(main())
-
12 years, 8 months
[NEW PATCH] [WIP] Path and user substitutions using autoconf (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/714
commit 953aaac7e2c6717af6367b3e5b77a4562c98c291
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Fri Jul 15 12:50:46 2011 +0000
[WIP] Path and user substitutions using autoconf
Change-Id: I5c24d9418a592d0e582ddf41315012d2db69a76a
diff --git a/configure.ac b/configure.ac
index 738a62a..327d572 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,31 @@
AC_INIT([vdsm], [4.9], [vdsm-devel(a)lists.fedorahosted.org])
AC_SUBST([PACKAGE_RELEASE], m4_esyscmd([./build-aux/release.sh]))
+# Users and groups
+AC_ARG_WITH([vdsm-user],
+ AC_HELP_STRING([--with-vdsm-user],
+ [VDSM username @<:@default=vdsm@:>@]),
+ [VDSMUSER=${withval}], [VDSMUSER=vdsm])
+AC_SUBST([VDSMUSER], [${VDSMUSER}])
+
+AC_ARG_WITH([vdsm-group],
+ AC_HELP_STRING([--with-vdsm-group],
+ [VDSM groupname @<:@default=qemu@:>@]),
+ [VDSMGROUP=${withval}], [VDSMGROUP=qemu])
+AC_SUBST([VDSMGROUP], [${VDSMGROUP}])
+
+AC_ARG_WITH([metadata-group],
+ AC_HELP_STRING([--with-metadata-group],
+ [METADATA groupname @<:@default=kvm@:>@]),
+ [METADATAGROUP=${withval}], [METADATAGROUP=kvm])
+AC_SUBST([METADATAGROUP], [${METADATAGROUP}])
+
+AC_ARG_WITH([qemu-user],
+ AC_HELP_STRING([--with-qemu-user],
+ [QEMU username @<:@default=qemu@:>@]),
+ [QEMUUSER=${withval}], [QEMUUSER=qemu])
+AC_SUBST([QEMUUSER], [${QEMUUSER}])
+
# External programs (sorted, please keep in order)
AC_PATH_PROG([AWK_PATH], [awk], [/bin/awk])
AC_PATH_PROG([BASH_PATH], [bash], [/bin/bash])
@@ -70,6 +95,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 58f19a4..0000000
--- a/vdsm/Makefile
+++ /dev/null
@@ -1,117 +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
-
-OS_MAJOR_RELEASE=$(shell lsb_release -rs | sed 's/\..*//')
-
-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 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..6c25d19
--- /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
+
+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(a)/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(a)/udev/rules.d
+
+CFLAGS=-Wall -O
+
+OS_MAJOR_RELEASE=$(shell lsb_release -rs | sed 's/\..*//')
+
+all: storage/protect/safelease
+
+vdsm.conf.sample: config.py
+ python mk_vdsm.conf.sample.py > vdsm.conf.sample
+
+FILES_SUBSTITUTIONS = \
+ constants.py \
+ vdsm-sosplugin.py \
+ sudoers.vdsm \
+ logger.conf \
+ vdsmd \
+ sudoers.vdsm \
+ vdsm-store-net-config \
+ vdsm-restore-net-config
+
+%: %.in
+ 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" \
+ < $< > $@-t
+ mv $@-t $@
+
+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 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 1e85789..0000000
--- a/vdsm/constants.py.in
+++ /dev/null
@@ -1,157 +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(a)/client.log'
-P_VDSM_LOG = '@VDSMLOGDIR@'
-
-#
-# External programs (sorted, please keep in order).
-#
-EXT_ADDNETWORK = P_VDSM + 'addNetwork'
-EXT_AWK = '@AWK_PATH@'
-
-EXT_BLOCKDEV = '@BLOCKDEV_PATH@'
-EXT_BRCTL = '@BRCTL_PATH@'
-
-EXT_CAT = '@CAT_PATH@'
-EXT_CHMOD = '@CHMOD_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_HEAD = '@HEAD_PATH@'
-
-EXT_IFCONFIG = '@IFCONFIG_PATH@'
-EXT_IFDOWN = '@IFDOWN_PATH@'
-EXT_IFUP = '@IFUP_PATH@'
-EXT_IONICE = '@IONICE_PATH@'
-EXT_IP = '@IP_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_NETSTAT = '@NETSTAT_PATH@'
-EXT_NICE = '@NICE_PATH@'
-
-EXT_PERSIST = '@PERSIST_PATH@'
-EXT_PGREP = '@PGREP_PATH@'
-EXT_PING = '@PING_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@'
-EXT_SERVICE = '@SERVICE_PATH@'
-EXT_SETSID = '@SETSID_PATH@'
-EXT_SH = '@SH_PATH@'
-EXT_SHOWMOUNT = '@SHOWMOUNT_PATH@'
-EXT_SORT = '@SORT_PATH@'
-EXT_SU = '@SU_PATH@'
-EXT_SUDO = '@SUDO_PATH@'
-
-EXT_TAR = '@TAR_PATH@'
-EXT_TRUE = '@TRUE_PATH@'
-EXT_TUNE2FS = '@TUNE2FS_PATH@'
-
-EXT_UDEVSETTLE = '@UDEVSETTLE_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
-}
-"""
-
diff --git a/vdsm/constants.py.in.in b/vdsm/constants.py.in.in
new file mode 100644
index 0000000..7f1e024
--- /dev/null
+++ b/vdsm/constants.py.in.in
@@ -0,0 +1,153 @@
+# 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(a)/client.log'
+P_VDSM_LOG = '@VDSMLOGDIR@'
+
+#
+# External programs (sorted, please keep in order).
+#
+EXT_ADDNETWORK = '@VDSMDIR@/addNetwork'
+EXT_AWK = '@AWK_PATH@'
+
+EXT_BLOCKDEV = '@BLOCKDEV_PATH@'
+EXT_BRCTL = '@BRCTL_PATH@'
+
+EXT_CAT = '@CAT_PATH@'
+EXT_CHMOD = '@CHMOD_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_HEAD = '@HEAD_PATH@'
+
+EXT_IFCONFIG = '@IFCONFIG_PATH@'
+EXT_IFDOWN = '@IFDOWN_PATH@'
+EXT_IFUP = '@IFUP_PATH@'
+EXT_IONICE = '@IONICE_PATH@'
+EXT_IP = '@IP_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_NETSTAT = '@NETSTAT_PATH@'
+EXT_NICE = '@NICE_PATH@'
+
+EXT_PERSIST = '@PERSIST_PATH@'
+EXT_PGREP = '@PGREP_PATH@'
+EXT_PING = '@PING_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@'
+EXT_SERVICE = '@SERVICE_PATH@'
+EXT_SETSID = '@SETSID_PATH@'
+EXT_SH = '@SH_PATH@'
+EXT_SHOWMOUNT = '@SHOWMOUNT_PATH@'
+EXT_SORT = '@SORT_PATH@'
+EXT_SU = '@SU_PATH@'
+EXT_SUDO = '@SUDO_PATH@'
+
+EXT_TAR = '@TAR_PATH@'
+EXT_TRUE = '@TRUE_PATH@'
+EXT_TUNE2FS = '@TUNE2FS_PATH@'
+
+EXT_UDEVSETTLE = '@UDEVSETTLE_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
+}
+"""
+
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(a)/vdsm.log',)
-filters=storage.misc.TracebackRepeatFilter
-level=DEBUG
-formatter=long
-
-[handler_metadata]
-class=FileHandler
-args=('@P_VDSM_LOG(a)/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(a)/vdsm.log',)
+filters=storage.misc.TracebackRepeatFilter
+level=DEBUG
+formatter=long
+
+[handler_metadata]
+class=FileHandler
+args=('@VDSMLOGDIR(a)/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..1278811
--- /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 @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/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(a)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(a)/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(a)/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(a)/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 fabb11f..0000000
--- a/vdsm/vdsmd
+++ /dev/null
@@ -1,472 +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(a)vdsm.conf
-GETCONFITEM=@P_VDSM@/get-conf-item
-prog=vdsm
-PIDFILE=@P_VDSM_RUN(a)/vdsmd.pid
-RESPAWNPIDFILE=@P_VDSM_RUN(a)/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 libvirtd"
-CONFLICTING_SERVICES="libvirt-guests"
-# 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
-
- ovirt_store_config $lconf $qconf $ldconf
-
- # 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
-
- service libvirtd condrestart
-}
-
-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() {
- local ret_val
- python @P_VDSM(a)/hooks.pyc before_vdsm_start
-
- 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
- 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
-
- shutdown_conflicting_srv
- @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(a)/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..278a189
--- /dev/null
+++ b/vdsm/vdsmd.in
@@ -0,0 +1,472 @@
+#! /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(a)/vdsm.conf
+GETCONFITEM=@VDSMDIR@/get-conf-item
+prog=vdsm
+PIDFILE=@VDSMRUNDIR(a)/vdsmd.pid
+RESPAWNPIDFILE=@VDSMRUNDIR(a)/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 libvirtd"
+CONFLICTING_SERVICES="libvirt-guests"
+# 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
+
+ ovirt_store_config $lconf $qconf $ldconf
+
+ # 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
+
+ service libvirtd condrestart
+}
+
+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() {
+ local ret_val
+ python @VDSMDIR(a)/hooks.pyc before_vdsm_start
+
+ 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
+ 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
+
+ shutdown_conflicting_srv
+ @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(a)/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
12 years, 8 months
[NEW PATCH] [WIP] Use autoconf for external programs (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/712
commit b2aae54df7f9b59aaa9331cc8a68022c5d5094fa
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Thu Jul 14 12:20:09 2011 +0000
[WIP] Use autoconf for external programs
Change-Id: I26905591bcbae8303a8133581f794b581b3056d4
diff --git a/configure.ac b/configure.ac
index 8205333..738a62a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,75 @@
AC_INIT([vdsm], [4.9], [vdsm-devel(a)lists.fedorahosted.org])
AC_SUBST([PACKAGE_RELEASE], m4_esyscmd([./build-aux/release.sh]))
+
+# External programs (sorted, please keep in order)
+AC_PATH_PROG([AWK_PATH], [awk], [/bin/awk])
+AC_PATH_PROG([BASH_PATH], [bash], [/bin/bash])
+AC_PATH_PROG([BLOCKDEV_PATH], [blockdev], [/sbin/blockdev])
+AC_PATH_PROG([BRCTL_PATH], [brctl], [/usr/sbin/brctl])
+AC_PATH_PROG([CAT_PATH], [cat], [/bin/cat])
+AC_PATH_PROG([CHKCONFIG_PATH], [chkconfig], [/sbin/chkconfig])
+AC_PATH_PROG([CHMOD_PATH], [chmod], [/bin/chmod])
+AC_PATH_PROG([CHOWN_PATH], [chown], [/bin/chown])
+AC_PATH_PROG([CP_PATH], [cp], [/bin/cp])
+AC_PATH_PROG([DD_PATH], [dd], [/bin/dd])
+AC_PATH_PROG([DMIDECODE_PATH], [dmidecode], [/usr/sbin/dmidecode])
+AC_PATH_PROG([DMSETUP_PATH], [dmsetup], [/sbin/dmsetup])
+AC_PATH_PROG([ECHO_PATH], [echo], [/bin/echo])
+AC_PATH_PROG([FSCK_PATH], [fsck], [/sbin/fsck])
+AC_PATH_PROG([FUSER_PATH], [fuser], [/sbin/fuser])
+AC_PATH_PROG([GRUBBY_PATH], [grubby], [/sbin/grubby])
+AC_PATH_PROG([HEAD_PATH], [head], [/usr/bin/head])
+AC_PATH_PROG([HWCLOCK_PATH], [hwclock], [/usr/sbin/hwclock])
+AC_PATH_PROG([IFCONFIG_PATH], [ifconfig], [/sbin/ifconfig])
+AC_PATH_PROG([IFDOWN_PATH], [ifdown], [/sbin/ifdown])
+AC_PATH_PROG([IFUP_PATH], [ifup], [/sbin/ifup])
+AC_PATH_PROG([IONICE_PATH], [ionice], [/usr/bin/ionice])
+AC_PATH_PROG([IPCALC_PATH], [ipcalc], [/bin/ipcalc])
+AC_PATH_PROG([IP_PATH], [ip], [/sbin/ip])
+AC_PATH_PROG([ISCSIADM_PATH], [iscsiadm], [/sbin/iscsiadm])
+AC_PATH_PROG([KILLALL_PATH], [killall], [/usr/bin/killall])
+AC_PATH_PROG([KILL_PATH], [kill], [/bin/kill])
+AC_PATH_PROG([LSB_RELEASE_PATH], [lsb_release], [/usr/bin/lsb_release])
+AC_PATH_PROG([LVM_PATH], [lvm], [/sbin/lvm])
+AC_PATH_PROG([MKFS_PATH], [mkfs], [/sbin/mkfs])
+AC_PATH_PROG([MOUNT_PATH], [mount], [/bin/mount])
+AC_PATH_PROG([MULTIPATH_PATH], [multipath], [/sbin/multipath])
+AC_PATH_PROG([MV_PATH], [mv], [/bin/mv])
+AC_PATH_PROG([NETSTAT_PATH], [netstat], [/bin/netstat])
+AC_PATH_PROG([NICE_PATH], [nice], [/bin/nice])
+AC_PATH_PROG([OPENSSL_PATH], [openssl], [/usr/bin/openssl])
+AC_PATH_PROG([PERSIST_PATH], [persist], [/usr/sbin/persist])
+AC_PATH_PROG([PGREP_PATH], [pgrep], [/usr/bin/pgrep])
+AC_PATH_PROG([PING_PATH], [ping], [/bin/ping])
+AC_PATH_PROG([PYTHON_PATH], [python], [/usr/bin/python])
+AC_PATH_PROG([QEMUIMG_PATH], [qemu-img], [/usr/bin/qemu-img])
+AC_PATH_PROG([REBOOT_PATH], [reboot], [/usr/bin/reboot])
+AC_PATH_PROG([RPM_PATH], [rpm], [/bin/rpm])
+AC_PATH_PROG([RSYNC_PATH], [rsync], [/usr/bin/rsync])
+AC_PATH_PROG([SCSI_ID_PATH], [scsi_id], [/sbin/scsi_id])
+AC_PATH_PROG([SED_PATH], [sed], [/bin/sed])
+AC_PATH_PROG([SERVICE_PATH], [service], [/sbin/service])
+AC_PATH_PROG([SETSID_PATH], [setsid], [/usr/bin/setsid])
+AC_PATH_PROG([SHOWMOUNT_PATH], [showmount], [/usr/sbin/showmount])
+AC_PATH_PROG([SH_PATH], [sh], [/bin/sh])
+AC_PATH_PROG([SORT_PATH], [sort], [/bin/sort])
+AC_PATH_PROG([SUDO_PATH], [sudo], [/usr/bin/sudo])
+AC_PATH_PROG([SU_PATH], [su], [/bin/su])
+AC_PATH_PROG([TAR_PATH], [tar], [/bin/tar])
+AC_PATH_PROG([TRACEROUTE_PATH], [traceroute], [/bin/traceroute])
+AC_PATH_PROG([TRUE_PATH], [true], [/bin/true])
+AC_PATH_PROG([TUNE2FS_PATH], [tune2fs], [/sbin/tune2fs])
+AC_PATH_PROG([UDEVSETTLE_PATH], [udevsettle], [/sbin/udevsettle])
+AC_PATH_PROG([UMOUNT_PATH], [umount], [/bin/umount])
+AC_PATH_PROG([UNAME_PATH], [uname], [/bin/uname])
+AC_PATH_PROG([UNPERSIST_PATH], [unpersist], [/usr/sbin/unpersist])
+AC_PATH_PROG([VCONFIG_PATH], [vconfig], [/sbin/vconfig])
+AC_PATH_PROG([WGET_PATH], [wget], [/usr/bin/wget])
+AC_PATH_PROG([YUM_PATH], [yum], [/usr/bin/yum])
+
AC_OUTPUT([
vdsm.spec
Makefile
+ vdsm/constants.py
+ vdsm_reg/deployUtil.py
])
diff --git a/vdsm/constants.py b/vdsm/constants.py
deleted file mode 100644
index ae9a79b..0000000
--- a/vdsm/constants.py
+++ /dev/null
@@ -1,158 +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(a)/client.log'
-P_VDSM_LOG = '@VDSMLOGDIR@'
-
-#
-# External programs (sorted, please keep in order).
-#
-EXT_ADDNETWORK = P_VDSM + 'addNetwork'
-EXT_AWK = P_BIN + 'awk'
-
-EXT_BLOCKDEV = P_SBIN + 'blockdev'
-EXT_BRCTL = P_USR_SBIN + 'brctl'
-
-EXT_CAT = P_BIN + 'cat'
-EXT_CHMOD = P_BIN + 'chmod'
-EXT_CHOWN = P_BIN + 'chown'
-EXT_CP = P_BIN + 'cp'
-
-EXT_DD = P_BIN + 'dd'
-EXT_DELNETWORK = P_VDSM + 'delNetwork'
-EXT_DMIDECODE = P_USR_SBIN + 'dmidecode'
-EXT_DMSETUP = P_SBIN + 'dmsetup'
-
-EXT_EDITNETWORK = P_VDSM + 'editNetwork'
-
-EXT_FENCE_PREFIX = P_USR_SBIN + 'fence_'
-EXT_FSCK = P_SBIN + 'e2fsck'
-EXT_FUSER = P_SBIN + 'fuser'
-
-EXT_GET_VM_PID = P_VDSM + 'get-vm-pid'
-
-EXT_HEAD = P_USR_BIN + 'head'
-
-EXT_IFCONFIG = P_SBIN + 'ifconfig'
-EXT_IFDOWN = P_SBIN + 'ifdown'
-EXT_IFUP = P_SBIN + 'ifup'
-EXT_IONICE = P_USR_BIN + 'ionice'
-EXT_IP = P_SBIN + 'ip'
-EXT_IPCALC = P_BIN + 'ipcalc'
-EXT_ISCSIADM = P_SBIN + 'iscsiadm'
-
-EXT_KILLALL = P_USR_BIN + 'killall'
-EXT_KILL = P_BIN + 'kill'
-
-EXT_LVM = P_SBIN + 'lvm'
-
-EXT_MKFS = P_SBIN + 'mke2fs'
-EXT_MK_SYSPREP_FLOPPY = P_VDSM + 'mk_sysprep_floppy'
-EXT_MOUNT = P_BIN + 'mount'
-EXT_MULTIPATH = P_SBIN + 'multipath'
-EXT_MV = P_BIN + 'mv'
-
-EXT_NETSTAT = P_BIN + 'netstat'
-EXT_NICE = P_BIN + 'nice'
-
-EXT_PERSIST = P_USR_SBIN + 'persist'
-EXT_PGREP = P_USR_BIN + 'pgrep'
-EXT_PING = P_BIN + 'ping'
-EXT_PREPARE_VMCHANNEL = P_VDSM + 'prepare-vmchannel'
-EXT_PYTHON = P_USR_BIN + 'python'
-
-EXT_QEMUIMG = P_USR_BIN + 'qemu-img'
-
-EXT_REBOOT = P_SBIN + 'reboot'
-EXT_RPM = P_BIN + 'rpm'
-EXT_RSYNC = P_USR_BIN + 'rsync'
-
-EXT_SCSI_ID = P_SBIN + 'scsi_id' #TBD !
-EXT_SERVICE = P_SBIN + 'service'
-EXT_SETSID = P_USR_BIN + 'setsid'
-EXT_SH = P_BIN + 'sh'
-EXT_SHOWMOUNT = P_USR_SBIN + 'showmount'
-EXT_SORT = P_BIN + 'sort'
-EXT_SU = P_BIN + 'su'
-EXT_SUDO = P_USR_BIN + 'sudo'
-
-EXT_TAR = P_BIN + 'tar'
-EXT_TRUE = P_BIN + 'true' #TBD
-EXT_TUNE2FS = P_SBIN + 'tune2fs'
-
-EXT_UDEVSETTLE = P_SBIN + 'udevsettle'
-EXT_UMOUNT = P_BIN + 'umount'
-EXT_UNPERSIST = P_USR_SBIN + 'unpersist'
-
-EXT_VCONFIG = P_SBIN + 'vconfig'
-EXT_VDSM_STORE_NET_CONFIG = P_VDSM + 'vdsm-store-net-config'
-EXT_VDSCLIENT = P_USR_BIN + 'vdsClient'
-
-EXT_WGET = P_USR_BIN + 'wget'
-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
-}
-"""
-
diff --git a/vdsm/constants.py.in b/vdsm/constants.py.in
new file mode 100644
index 0000000..5098134
--- /dev/null
+++ b/vdsm/constants.py.in
@@ -0,0 +1,158 @@
+# 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(a)/client.log'
+P_VDSM_LOG = '@VDSMLOGDIR@'
+
+#
+# External programs (sorted, please keep in order).
+#
+EXT_ADDNETWORK = P_VDSM + 'addNetwork'
+EXT_AWK = '@AWK_PATH@'
+
+EXT_BLOCKDEV = '@BLOCKDEV_PATH@'
+EXT_BRCTL = '@BRCTL_PATH@'
+
+EXT_CAT = '@CAT_PATH@'
+EXT_CHMOD = '@CHMOD_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_HEAD = '@HEAD_PATH@'
+
+EXT_IFCONFIG = '@IFCONFIG_PATH@'
+EXT_IFDOWN = '@IFDOWN_PATH@'
+EXT_IFUP = '@IFUP_PATH@'
+EXT_IONICE = '@IONICE_PATH@'
+EXT_IP = '@IP_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_NETSTAT = '@NETSTAT_PATH@'
+EXT_NICE = '@NICE_PATH@'
+
+EXT_PERSIST = '@PERSIST_PATH@'
+EXT_PGREP = '@PGREP_PATH@'
+EXT_PING = '@PING_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@'
+EXT_SERVICE = '@SERVICE_PATH@'
+EXT_SETSID = '@SETSID_PATH@'
+EXT_SH = '@SH_PATH@'
+EXT_SHOWMOUNT = '@SHOWMOUNT_PATH@'
+EXT_SORT = '@SORT_PATH@'
+EXT_SU = '@SU_PATH@'
+EXT_SUDO = '@SUDO_PATH@'
+
+EXT_TAR = '@TAR_PATH@'
+EXT_TRUE = '@TRUE_PATH@'
+EXT_TUNE2FS = '@TUNE2FS_PATH@'
+
+EXT_UDEVSETTLE = '@UDEVSETTLE_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_VDSCLIENT = '@VDSCLIENT_PATH@'
+
+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
+}
+"""
+
diff --git a/vdsm_reg/deployUtil.py b/vdsm_reg/deployUtil.py
deleted file mode 100644
index 7564ed0..0000000
--- a/vdsm_reg/deployUtil.py
+++ /dev/null
@@ -1,1393 +0,0 @@
-# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Description: Deployment utilities.
-
-import subprocess
-import logging
-import traceback
-import socket
-import re
-import sys
-import os
-import os.path
-import time
-import grp
-import pwd
-import shutil
-from xml.sax import saxutils
-import struct
-import httplib
-import glob
-import imp
-from optparse import OptionParser
-
-try:
- from ovirtnode import ovirtfunctions
-except ImportError:
- pass
-
-# Path constants
-P_BIN = '/bin/'
-P_ETC_INITD = '/etc/init.d/'
-P_ROOT_SSH = '/root/.ssh'
-P_ROOT_AUTH_KEYS = P_ROOT_SSH + '/authorized_keys'
-P_SBIN = '/sbin/'
-P_USR_BIN = '/usr/bin/'
-P_USR_SBIN = '/usr/sbin/'
-P_LIBEXEC = '/usr/libexec/'
-
-# Executables
-EX_AWK = P_BIN + 'awk'
-EX_BASH = P_BIN + 'bash'
-EX_CAT = P_BIN + 'cat'
-EX_CHKCONFIG = P_SBIN + 'chkconfig'
-EX_DMIDECODE = P_USR_SBIN + 'dmidecode'
-EX_ECHO = P_BIN + 'echo'
-EX_GRUBBY = P_SBIN + 'grubby'
-EX_HEAD = P_USR_BIN + 'head'
-EX_HWCLOCK = P_SBIN + 'hwclock'
-EX_IFCONFIG = P_SBIN + 'ifconfig'
-EX_LSB_RELEASE = P_USR_BIN + 'lsb_release'
-EX_OPENSSL = P_USR_BIN + 'openssl'
-EX_REBOOT = P_SBIN + 'reboot'
-EX_RPM = P_BIN + 'rpm'
-EX_SED = P_BIN + 'sed'
-EX_SERVICE = P_SBIN + 'service'
-EX_SORT = P_BIN + 'sort'
-EX_TRACEROUTE = P_BIN + 'traceroute'
-EX_UNAME = P_BIN + 'uname'
-EX_YUM = P_USR_BIN + 'yum'
-
-# Other constants
-READ_BUF_SIZE = 1024
-DEF_KEY_LEN = 1024
-HTTP_TIMEOUT = 30
-ERR_NO_ROUTE = 7
-SCRIPT_NAME_ADD = "addNetwork"
-SCRIPT_NAME_DEL = "delNetwork"
-IFACE_CONFIG = "/etc/sysconfig/network-scripts/ifcfg-"
-MGT_BRIDGE_NAME = "rhevm"
-REMOTE_SSH_KEY_FILE = "/rhevm.ssh.key.txt"
-CORE_DUMP_PATH = '/var/lib/vdsm/core'
-CORE_PATTERN = '/proc/sys/kernel/core_pattern'
-XML_QUOTES = {
- "\n":' ',
- "'":'~'
-}
-
-def _logExec(argv):
- """
- This function executes a given shell command while logging it.
- """
- out = None
- err = None
- rc = None
- try:
- logging.debug(argv)
- p = subprocess.Popen(argv , stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- rc = p.returncode
- logging.debug(out)
- logging.debug(err)
- except:
- logging.error(traceback.format_exc())
- return (out, err, rc)
-
-#############################################################################################################
-# Host Misc functions.
-#############################################################################################################
-def escapeXML(message):
- """
- Escape '&', '<', '>', and '\n' in a given string.
- """
- return saxutils.escape(message, XML_QUOTES)
-
-def reboot():
- """
- This function reboots the machine.
- """
- fReturn = True
-
- out, err, ret = _logExec([EX_REBOOT])
- if ret:
- fReturn = False
-
- return fReturn
-
-def setCoreDumpPath():
- logging.debug("setCoreDumpPath started.")
- fReturn = True
- try:
- _logExec([EX_ECHO, CORE_DUMP_PATH, ">", CORE_PATTERN])
- print "<BSTRAP component='CoreDump' status='OK'/>"
- except:
- fReturn = False
- print "<BSTRAP component='CoreDump' status='FAIL'/>"
-
- logging.debug("setCoreDumpPath end:" + str(fReturn))
- return fReturn
-
-def cleanAll(random_num):
- """ Remove temp files.
- """
- fReturn = True
- try:
- # build semi-random filenames
- req_conffile = '/tmp/req_' + random_num + '.conf'
- cert_reqfile = '/tmp/cert_' + random_num + '.req'
- cert_pemfile = '/tmp/cert_' + random_num + '.pem'
- ca_pemfile = '/tmp/CA_' + random_num + '.pem'
- # remove unnecessary files
- os.unlink(req_conffile)
- os.unlink(cert_reqfile)
- os.unlink(cert_pemfile)
- os.unlink(ca_pemfile)
-
- if not isOvirt():
- vds_bstrap = '/tmp/vds_bootstrap_' + random_num + '.py'
- vds_bstrap_cmp = '/tmp/vds_bootstrap_complete_' + random_num + '.py'
- vds_bstrap_pyc = '/tmp/vds_bootstrap_' + random_num + '.pyc'
- vds_bstrap_cmp_pyc = '/tmp/vds_bootstrap_complete_' + random_num + '.pyc'
- vds_bstrap_deployutil = '/tmp/deployUtil.py'
- vds_bstrap_deployutil_pyc = '/tmp/deployUtil.pyc'
- os.unlink(vds_bstrap)
- os.unlink(vds_bstrap_cmp)
- os.unlink(vds_bstrap_pyc)
- os.unlink(vds_bstrap_cmp_pyc)
- os.unlink(vds_bstrap_deployutil)
- os.unlink(vds_bstrap_deployutil_pyc)
-
- except:
- pass
-
- print "<BSTRAP component='cleanAll' status='OK'/>"
- logging.debug("cleanAll end:" + str(fReturn))
-
- return fReturn
-
-def setVdsConf(configStr, confFile):
- """
- This function changes local configuration according to the
- given 'key=value;' string.
- """
- fReturn = True
- logging.debug("setVdsConf: started. config:" + str(configStr))
- if not configStr:
- logging.debug("setVdsConf: nothing to set.")
- return True
-
- if not os.path.exists(confFile):
- strMessage = escapeXML("File " + confFile + "does not exist.")
- print "<BSTRAP component='VDS Configuration' status='FAIL' message='" + strMessage + "'/>"
- logging.debug("setVdsConf: " + strMessage)
- return False
-
- try:
- new_config_params = {}
- config_params = configStr.split(';')
- for item in config_params:
- key = item.split('=')[0].strip()
- val = item.split('=')[1].strip()
- new_config_params[key] = val
-
- for key in new_config_params.keys():
- val = new_config_params[key]
- logging.debug("setVdsConf: setting Key=" + str(key) + " to val=" + str(val))
- _updateFileLine(confFile, key, val)
- #_logExec([EX_SED, "-i", "s:^\s*"+key+"\s*=.*:"+key+"="+val+":", confFile])
-
- if isOvirt():
- # save the updated file
- logging.debug("setVdsConf: saving new config file")
- ovirtfunctions.ovirt_store_config(confFile)
-
- print "<BSTRAP component='VDS Configuration' status='OK'/>"
- except Exception, e:
- msg = escapeXML(str(e))
- print "<BSTRAP component='VDS Configuration' status='FAIL' message='%s'/>" % (msg)
- logging.debug("setVdsConf: exception " + msg)
- fReturn = False
-
- logging.debug("setVdsConf: ended.")
- return fReturn
-
-def getMachineUUID():
- """
- This function parses the DMI data for the host's UUID. If not found, returns "None".
- """
- strReturn = "None"
-
- out, err, ret = _logExec([EX_BASH, "-c", EX_DMIDECODE + "|" + EX_AWK + " ' /^\tUUID: /{ print $2; } '"])
- if ret == 0 and "Not" not in out: #Avoid error string- 'Not Settable' or 'Not Present'
- strReturn = out.replace ("\n", "")
- else:
- logging.error("getMachineUUID: Could not find machine's UUID.")
-
- return strReturn
-
-def getMacs():
- macs = []
- for b in glob.glob('/sys/class/net/*/device'):
- nic = b.split('/')[-2]
- addr = '/sys/class/net/' + nic + '/address'
- mac = file(addr).readlines()[0].split()[0]
- macs.append(mac)
-
- return macs
-
-def getHostID():
- """
- This function concatenate the first serted mac address to the machine's UUID.
- """
- strReturn = getMachineUUID()
-
- macs = getMacs()
-
- if len(macs) > 0:
- strMAC = sorted(macs)[0]
- else:
- strMAC = ""
- logging.warning("getHostID: Could not find machine's MAC, returning UUID only.")
-
- if strReturn != "None":
- strReturn += "_" + strMAC
- else:
- strReturn = "_" + strMAC
-
- logging.debug("getHostID: " + str(strReturn))
- return strReturn
-
-def _getIfaceByIP(addr):
- remote = struct.unpack('I', socket.inet_aton(addr))[0]
- for line in file('/proc/net/route').readlines()[1:]:
- iface, dest, gateway, flags, refcnt, use, metric, \
- mask, mtu, window, irtt = line.split()
- dest = int(dest, 16)
- mask = int(mask, 16)
- if remote & mask == dest & mask:
- return iface
-
- return None # should never get here w/ default gw
-
-def _getMGTIface(vdcHostName):
- strVDCIP = "None"
- strReturn = None
- strVDCName = vdcHostName
-
- try:
- if vdcHostName != "None":
- logging.debug("_getMGTIface: read vdc_host_name: " + strVDCName)
- #Now find the IP. Note that gethostbyname(IP) == IP
- strVDCIP = socket.gethostbyname(strVDCName)
- except:
- strVDCIP = "None"
- logging.debug("_getMGTIface: error trying to figure out VDC's IP")
-
- logging.debug("_getMGTIface: using vdc_host_name " + strVDCName + " strVDCIP= " + strVDCIP)
-
- # Find the interface of the management IP
- if strVDCIP != "None":
- strReturn = _getIfaceByIP(strVDCIP)
-
- logging.debug("_getMGTIface VDC IP=" + str(strVDCIP) + " strIface=" + str(strReturn))
- return strReturn
-
-def getMGTIP(vdsmDir, vdcHostName):
- strReturn = "None"
-
- try:
- sys.path.append(vdsmDir)
- import netinfo # taken from vdsm rpm
- except:
- logging.error("getMGTIP: Faild to find vdsm modules!")
- return strReturn
-
- arNICs = None
- strIface = _getMGTIface(vdcHostName)
-
- if strIface is not None:
- arNICs = netinfo.ifconfig()
-
- logging.debug("getMGTIP: Host parsed interfaces:\n" + str(arNICs) + "\n")
-
- if arNICs != None:
- strReturn = arNICs[strIface]['addr']
-
- logging.debug("getMGTIP: Host MGT IP=" + strReturn)
- return strReturn
-
-def preventDuplicate():
- """
- This function checks if the needed bridge (rhevm) already exist.
- """
- fFound = False
-
- if os.path.exists('/sys/class/net/' + MGT_BRIDGE_NAME):
- fFound = True
- logging.debug("Bridge rhevm already exists.")
- else:
- logging.debug("Bridge rhevm not found, need to create it.")
-
- return fFound
-
-def isOvirt():
- """
- This function checks if current machine runs ovirt platform.
- """
- return os.path.exists('/etc/rhev-hypervisor-release')
-
-def getOSVersion():
- """
- Return the OS' release from accordong to LSB specification.
- """
- strReturn = "Unknown OS"
-
- if os.path.exists(EX_LSB_RELEASE):
- out, err, rc = _logExec([EX_LSB_RELEASE, "-rs"])
- try:
- strReturn = out.replace("\n","")
- except:
- strReturn = "Unknown OS"
-
- return strReturn
-
-def getKernelVersion():
- """
- Return current kernel release.
- """
- strReturn = '0'
- out, err, rc = _logExec([EX_UNAME, "-r"])
- if not rc:
- strReturn = out
-
- return strReturn
-
-def updateKernelArgs(arg):
- """
- Update current kernel arguments using grubby.
- """
- fReturn = False
- try:
- out, err, ret = _logExec([EX_GRUBBY, "--update-kernel",
- "DEFAULT", "--args", arg] )
- if not ret:
- fReturn = True
- except:
- pass
-
- return fReturn
-
-def getAddress(url):
- logging.debug("getAddress Entry. url=" + str(url))
- import urlparse
- strRetAddress = None
- strRetPort = None
- scheme = None
- netloc = None
- path = None
- query = None
- fragment = None
-
- (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
- if scheme != '': #('http', 'www.redhat.com', '/rhel/virtualization/', '', '')
- strRetAddress = netloc
- elif path != '': #('', '', 'www.redhat.com', '', '')
- strRetAddress = path
- else:
- logging.error("Unable to parse: " + str(url))
-
- # Find port
- if strRetAddress is not None and ":" in strRetAddress:
- strRetAddress, strRetPort = strRetAddress.split(":")
-
- logging.debug("getAddress return. address=" + str(strRetAddress) + " port=" + str(strRetPort))
- return strRetAddress, strRetPort
-
-def waitRouteRestore(maxCount, targetIP):
- logging.debug("waitRouteRestore Entry. maxCount=" + str(maxCount) + " targetIP:" + targetIP)
-
- fReturn = True
- count = 0
- ret1 = ERR_NO_ROUTE #no route error code
- while(count<maxCount and ret1 == ERR_NO_ROUTE):
- try:
- out1, err1, ret1 = _logExec([
- '/usr/bin/curl',
- '-s',
- '--connect-timeout', '10',
- '--max-filesize', '10',
- targetIP
- ])
- except:
- pass
-
- count = count + 1
- logging.debug(
- " count=" + str(count-1) +
- "\nout=" + out1 +
- "\nerr=" + str(err1) +
- "\nret=" + str(ret1)
- )
- time.sleep(1)
-
- if ret1 == ERR_NO_ROUTE:
- fReturn = False
-
- logging.debug("waitRouteRestore Return. fReturn=" + str(fReturn))
- return fReturn
-
-def setService(srvName, action):
- """
- Perform an action (stop/start/status/...) on a service
- """
- nReturn = 0
- out = None
- err = None
- if type(srvName) == type(None):
- nReturn = 1
- message = "setService: ignoring None service."
- err = message
- logging.error(message)
- elif os.path.exists(P_ETC_INITD + srvName):
- out, err, nReturn = _logExec([EX_SERVICE, srvName, action])
- else:
- nReturn = 1
- err = "No such service: " + srvName
-
- return out, err, nReturn
-
-def chkConfig(srvName, action, level=None):
- """
- Perform a set action (on/off/reset) on an init script
- """
- nReturn = 0
- out = None
- err = None
- if type(srvName) == type(None):
- nReturn = 1
- message = "chkConfig: ignoring None service."
- err = message
- logging.error(message)
- elif os.path.exists(P_ETC_INITD + srvName):
- if level:
- out, err, nReturn = _logExec([EX_CHKCONFIG, '--level', level, srvName, action])
- else:
- out, err, nReturn = _logExec([EX_CHKCONFIG, srvName, action])
- else:
- if action != "off":
- nReturn = 1
- err = "No such service: " + srvName
- else:
- logging.debug("chkConfig: ignoring uninstalled service: " + str(srvName))
-
- return out, err, nReturn
-
-
-#############################################################################################################
-# Host SSH functions.
-#############################################################################################################
-
-def getAuthKeysFile(IP, port):
- """
- This functions returns the public ssh key of rhev-m.
- """
- CACERT, dontcare = certPaths('')
- return getRemoteFile(IP, port, REMOTE_SSH_KEY_FILE, timeout=HTTP_TIMEOUT,
- certPath=CACERT)
-
-def addSSHKey(path, strKey):
- resKeys = []
-
- try:
- for key in file(path):
- if key != '\n' and not key.endswith("== rhevm") or key.startswith("#"):
- resKeys.append(key)
- except IOError:
- logging.debug("Failed to read %s" % path)
- resKeys.append('\n' + strKey)
-
- if isOvirt():
- # No problem to write to the original file here, since until it is not
- # persisted the old values are in place
- open(path, 'w').write(''.join(resKeys))
- else:
- tmpFilePath = path + '.tmp'
- open(tmpFilePath, 'w').write(''.join(resKeys))
- os.rename(tmpFilePath, path)
-
-def handleSSHKey(strKey):
- """
- This functions appends a given key to the root's authorized_keys file.
- """
- fReturn = True
- logging.debug('handleSSHKey start')
- if not os.path.exists(P_ROOT_SSH):
- logging.debug("handleSSHKey: creating .ssh dir.")
- try:
- os.mkdir(P_ROOT_SSH, 0700)
- except OSError:
- fReturn = False
- logging.debug("handleSSHKey: failed to create ssh dir!")
-
- if fReturn:
- try:
- addSSHKey(P_ROOT_AUTH_KEYS, strKey)
- except:
- fReturn = False
- logging.debug("handleSSHKey: failed to write authorized_keys!",
- exc_info=True)
-
- if fReturn:
- try:
- os.chmod(P_ROOT_AUTH_KEYS, 0644)
- except:
- fReturn = False
- logging.debug("handleSSHKey: failed to chmod authorized_keys")
-
- if fReturn and isOvirt():
- # persist authorized_keys
- logging.debug("handleSSHKey: persist authorized_keys")
- ovirtfunctions.ovirt_store_config(P_ROOT_AUTH_KEYS)
-
- logging.debug('handleSSHKey end')
- return fReturn
-
-#############################################################################################################
-# Host time functions.
-#############################################################################################################
-
-def setHostTime(VDCTime):
- logging.debug('setHostTime start.')
- import time
- fReturn = True
-
- try:
- ttp = time.strptime(VDCTime, '%Y-%m-%dT%H:%M:%S')
- except ValueError, e:
- logging.debug("setHostTime: Failed to parse RHEVM time. message= " + str(e))
- fReturn = False
-
- if fReturn:
- out, err, rc = _logExec([EX_HWCLOCK, "--set", "--utc",
- time.strftime('--date=%Y-%m-%d %H:%M:%S UTC', ttp)])
- if rc:
- logging.debug("setHostTime: Failed to set hwclock time. out=" + out + "\nerr=" + str(err) + "\nrc=" + str(rc))
- fReturn = False
-
- if fReturn:
- out, err, rc = _logExec([EX_HWCLOCK, "-s"])
- if rc:
- logging.debug("setHostTime: Failed to sync hwclock time to host. out=" + out + "\nerr=" + str(err) + "\nrc=" + str(rc))
- fReturn = False
-
- logging.debug('setHostTime end. Return:' + str(fReturn))
- return fReturn
-
-#############################################################################################################
-# Update configuration file functions.
-#############################################################################################################
-
-def _updateFileLine(fileName, key, value):
- """
- Update a line of a configuration file. This function will replace the whole line!
- The function returns success is replacment took place.
- """
- import stat
- from tempfile import mkstemp
- fReplaced = False
- logging.debug(
- "_updateFileLine: entry. File: " + str(fileName) +
- " key=" + str(key) +
- " value=" + str(value)
- )
-
- try:
- #Preserve current file mode
- mode = os.stat(fileName)[stat.ST_MODE]
-
- #Create temp file
- fh, abs_path = mkstemp()
- new_file = open(abs_path,'w')
- old_file = open(fileName)
- #Iterate over the existing file, while replacing if needed.
- for line in old_file:
- #Note: the line below must not have spaces before or after the '=', since it'll fail bash scripts !
- newLine = re.sub('^[#\s]*%s\s*=.*' % key , '%s=%s' % (key, value), line)
- if re.match('^%s=%s$' % (re.escape(key), re.escape(value)), newLine):
- logging.debug("_updateFileLine: replacing " + str(line) + " with: " + newLine)
- fReplaced = True
- line = newLine
- new_file.write(line)
- new_file.close()
- os.close(fh)
- old_file.close()
- #Move new file
- shutil.move(abs_path, fileName)
-
- #Restore original file mode
- os.chmod(fileName, mode)
- except:
- try:
- old_file.close()
- except:
- pass
- logging.error("_updateFileLine: error replacing " + str(key) + "=" + str(value))
- logging.error(traceback.format_exc())
-
- logging.debug("_updateFileLine: return: " + str(fReplaced))
- return fReplaced
-
-#############################################################################################################
-# Host bridge functions.
-#############################################################################################################
-
-def _getBridgeParams(bridgeName):
- import shlex
-
- fIsBridgeDevice = False
- lstReturn = []
- fileName = IFACE_CONFIG + bridgeName
-
- try:
- for line in file(fileName):
- line = line.strip()
- if line.startswith("DEVICE=") or \
- line.startswith("#") or \
- line.startswith("HWADDR="):
- pass
- elif line.startswith("TYPE="):
- t = line.split("=", 1)[1].strip()
- fIsBridgeDevice = (t == "Bridge")
- else:
- try:
- line = ''.join(shlex.split(line))
- except:
- logging.warn("_getBridgeParams: failed to read parse line %s", line)
- lstReturn.append(line)
- except Exception, e:
- logging.error("_getBridgeParams: failed to read params of file " + fileName + ".\n Error:" + str(e))
- lstReturn = []
-
- return lstReturn, fIsBridgeDevice
-
-def _getOvirtBridgeParams(mgtBridge):
- """
- This helper function extract the relevant parameters of the existing
- ovirt bridge in order to re-create it as a managment bridge.
- """
- import netinfo # taken from vdsm rpm
- vlan = ''
- bonding = ''
- nic = None
- nics = []
-
- try:
- vlan, bonding, nics = netinfo.getVlanBondingNic(mgtBridge)
- nic = nics[0]
- except:
- nic = None
- logging.error("_getOvirtBridgeParams Failed to get bridge data:")
- logging.error(traceback.format_exc())
-
- return vlan, bonding, nic
-
-def _getRHELBridgeParams(mgtIface):
- """
- This helper function extract the relevant parameters of the existing
- RHEL interface, in order to create a managment bridge.
- """
- import netinfo # taken from vdsm rpm
- vlan = ''
- bonding = ''
- nic = None
-
- try:
- vlans = netinfo.vlans()
- if mgtIface in vlans:
- nic = netinfo.getVlanDevice(mgtIface)
- vlan = netinfo.getVlanID(mgtIface)
- else:
- nic = mgtIface
-
- if nic in netinfo.bondings():
- logging.error(
- "_getRHELBridgeParams Found bonding: " +
- str(nic) +
- ". This network configuration is not supported! Please configure rhevm bridge manually and re-install."
- )
- nic = None
- except:
- logging.error("_getRHELBridgeParams Failed to test for VLAN data")
- logging.error(traceback.format_exc())
- nic = None
-
- return vlan, bonding, nic
-
-def setSafeVdsmNetworkConfig():
- """consider current network configuration as safe and remove its backup"""
- if versionCompare(getOSVersion(), "6.0") < 0:
- shutil.rmtree("/etc/sysconfig/network-scripts/.vdsmback")
- else:
- import glob
- for f in glob.glob("/var/lib/vdsm/netconfback/*"):
- if os.path.isdir(f):
- shutil.rmtree(f)
- else:
- os.remove(f)
-
-
-def makeBridge(vdcName, vdsmDir):
- """
- Create (for RHEL) or rename (oVirt default bridge) to rhevm bridge.
- """
- logging.debug('makeBridge begin.')
- sys.path.append(vdsmDir)
- try:
- imp.find_module('netinfo') # taken from vdsm rpm
- except ImportError:
- logging.error("makeBridge Faild to find vdsm modules!")
- return False
-
- fReturn = True
- out = ""
- err = None
- ret = None
- nic = None
- fIsOvirt = isOvirt()
-
- # get current management interface
- mgtIface = _getMGTIface(vdcName)
- if mgtIface is None:
- fReturn = False
- logging.debug("makeBridge got mgtIface None. This is a routing or resolution issue.")
- else:
- mgtBridge = mgtIface
- if fIsOvirt and mgtIface.startswith('br'):
- mgtIface = mgtIface.replace("br", "", 1) #oVirt naming convention: br + iface
-
- if fReturn:
- # Read params from current bridge (bootproto, etc)
- Iface = mgtIface
- if fIsOvirt: Iface = mgtBridge
- lstBridgeOptions, fIsBridgeDevice = _getBridgeParams(Iface)
-
- if len(lstBridgeOptions) == 0:
- logging.error("makeBridge Failed to read existing nic parameters")
- fReturn = False
- elif fIsBridgeDevice and not fIsOvirt:
- logging.error("makeBridge found existing bridge named: " + Iface)
- fReturn = False
- else:
- logging.debug("makeBridge found the following bridge paramaters: " + str(lstBridgeOptions))
- # No more handling GATEWAYDEV.
-
- if fReturn:
- if fIsOvirt:
- vlan, bonding, nic = _getOvirtBridgeParams(mgtBridge)
- else:
- vlan, bonding, nic = _getRHELBridgeParams(mgtIface)
- fReturn = (nic is not None)
-
- #Delete existing bridge in oVirt
- if fReturn and fIsOvirt:
- try:
- out, err, ret = _logExec([os.path.join(vdsmDir, SCRIPT_NAME_DEL), mgtBridge, vlan, bonding, nic])
- if ret:
- if ret == 17: #ERR_BAD_BRIDGE
- logging.debug("makeBridge Ignoring error of del existing bridge. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
- else:
- fReturn = False
- logging.debug("makeBridge Failed to del existing bridge. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
- except:
- fReturn = False
- logging.debug("makeBridge Failed to del existing bridge. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
-
- #Add rhevm bridge
- if fReturn:
- try:
- lstBridgeOptions.append('blockingdhcp=true')
- out, err, ret = _logExec([os.path.join(vdsmDir, SCRIPT_NAME_ADD) , MGT_BRIDGE_NAME, vlan, bonding, nic] + lstBridgeOptions)
- if ret:
- fReturn = False
- logging.debug("makeBridge Failed to add rhevm bridge out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
- except:
- fReturn = False
- logging.debug("makeBridge Failed to add rhevm bridge out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
-
- #Save current config by removing the undo files:
- try:
- if fReturn and not fIsOvirt:
- setSafeVdsmNetworkConfig()
- except:
- logging.debug(traceback.format_exc())
-
- if not fReturn:
- logging.error(
- "makeBridge errored: " +
- " out=" + out +
- "\nerr=" + str(err) +
- "\nret=" + str(ret)
- )
-
- logging.debug('makeBridge return.')
- return fReturn
-
-#############################################################################################################
-# Host package / rpm functions.
-#############################################################################################################
-
-def getPackageInfo(pckg_type, rpm_name, op):
- """
- Return an indication if given package name is installed or not.
- """
- strReturn = "FAIL"
- out, err, rc = _logExec([EX_RPM, "-q", rpm_name])
- if rc:
- if op == 'install':
- if pckg_type != "DEVEL":
- strReturn = "FAIL"
- out += err
- else:
- strReturn = "WARN"
- else:
- strReturn = "WARN"
- else:
- strReturn = "OK"
-
- return strReturn, out
-
-def versionCompare(pkg1, pkg2):
- """
- Return an indication if given package1 is:
- -1: pkg1 < pkg2
- 0: pkg1 == pkg2
- 1: pkg1 > pkg2
- 99 import Exception
- """
- nReturn = 0
-
- try:
- import rpmUtils
- import rpmUtils.miscutils
- except:
- nReturn = 99
-
- if nReturn == 0:
- nReturn = rpmUtils.miscutils.compareEVR(
- rpmUtils.miscutils.stringToVersion(pkg1),
- rpmUtils.miscutils.stringToVersion(pkg2)
- )
-
- return nReturn
-
-def yumCleanCache():
- """
- Clean yum's current cache.
- """
- fReturn = False
- out, err, ret = _logExec([EX_YUM, "clean", "all"] )
- if not ret:
- fReturn = True
-
- return fReturn
-
-def yumInstallDeleteUpdate(pckgName, action, args=None):
- """
- Call yum to install, delete or update a given package name.
- """
- execFunc = [EX_YUM, "-y"]
- if args is not None:
- execFunc += args
-
- if action == "install":
- execFunc.append(action)
- elif action == "remove":
- execFunc.append(action)
- else:
- execFunc.append("update")
- execFunc.append(pckgName)
-
- return _logExec(execFunc)
-
-def installAndVerify(pckgType, pckgName, action, args=None):
- """
- This function uses other module functions to install or update
- a package, and then verify it.
- """
- fReturn = True
- out, err, ret = yumInstallDeleteUpdate(pckgName, action, args=None)
- msg = None
- if not ret:
- fReturn, msg = getPackageInfo(pckgType, pckgName, 'install')
- else:
- fReturn = False
- msg = out + err
-
- return fReturn, msg
-
-def yumFind(pkgName):
- """
- Returns a list of available packages exists in yum's db.
- """
- import yum
- lReturn = None
-
- my = yum.YumBase()
- my.preconf.debuglevel = 0 # Remove yum noise
- lReturn = my.pkgSack.searchNevra(name=pkgName)
-
- return lReturn
-
-def yumSearch(pkgName):
- """
- Returns True is package exists in yum's db.
- """
- fReturn = False
-
- pkgs = yumFind(pkgName)
- if pkgs and len(pkgs)>0:
- fReturn = True
- logging.debug("yumSearch: found " + str(pkgName) + " entries: " + str(pkgs))
- else:
- logging.debug("yumSearch: package " + str(pkgName) + " not found!")
-
- return fReturn
-
-def yumSearchVersion(pkgName, ver, startWith=True):
- """
- Returns True is package exists in yum's db with the given version.
- Note: yum internal code has verEQ and verGT. We should use it ASAP.
- """
- fReturn = False
-
- pkgs = yumFind(pkgName)
- if pkgs and len(pkgs)>0:
- for item in pkgs:
- if startWith:
- if str(item).startswith(ver):
- fReturn = True
- logging.debug("yumSearchVersion: pkg " + str(item) + " starts with: " + ver)
- else:
- logging.debug("yumSearchVersion: pkg " + str(item) + " does not start with: " + ver)
- else:
- if str(item) == ver:
- fReturn = True
- logging.debug("yumSearchVersion: pkg " + str(item) + " matches: " + ver)
- else:
- logging.debug("yumSearchVersion: pkg " + str(item) + " does not match: " + ver)
- else:
- logging.debug("yumSearchVersion: package " + str(pkgName) + " not found!")
-
- return fReturn
-
-#############################################################################################################
-# Host PKI functions.
-#############################################################################################################
-
-def _tsDir(confFile):
- import ConfigParser
-
- config = ConfigParser.ConfigParser()
- config.read(confFile)
- try:
- tsDir = config.get('vars', 'trust_store_path')
- except:
- tsDir = '/etc/pki/vdsm'
- return tsDir
-
-def certPaths(confFile, fAddID=False):
- tsDir = _tsDir(confFile)
-
- VDSMCERT = tsDir + "/certs/vdsmcert.pem"
- if fAddID:
- VDSMCERT = tsDir + "/certs/vdsm-" + os.environ.get("SSH_CONNECTION").split()[2] + "-cert.pem"
- CACERT = tsDir + "/certs/cacert.pem"
-
- return CACERT, VDSMCERT
-
-def pkiCleanup(key, cert):
- """
- Removes all the previously installed keys and certificates
- """
- if os.path.exists(key):
- if isOvirt():
- ovirtfunctions.ovirt_safe_delete_config(key)
- else:
- os.unlink(key)
-
- if os.path.exists(cert):
- if isOvirt():
- ovirtfunctions.ovirt_safe_delete_config(cert)
- else:
- os.unlink(cert)
-
-def _linkOrPersist(src, dst):
- # we have to copy the key and cert since ovirt currently cannot persist
- # softlinks
- if isOvirt():
- shutil.copy2(src, dst)
- st = os.stat(src)
- os.chown(dst, st.st_uid, st.st_gid)
- ovirtfunctions.ovirt_store_config(dst)
- else:
- try:
- os.unlink(dst)
- except:
- pass
- os.symlink(src, dst)
-
-def instCert(random_num, confFile):
- """ Install certificate.
- """
- fReturn = True
-
- try:
- logging.debug("instCert: start. num=" + str(random_num))
- # build semi-random filenames
- cert_pemfile = '/tmp/cert_' + random_num + '.pem'
- ca_pemfile = '/tmp/CA_' + random_num + '.pem'
- gGroup = grp.getgrnam('kvm')
- nGID = gGroup.gr_gid
- uUserInfo = pwd.getpwnam('vdsm')
- nUID = uUserInfo.pw_uid
- CACERT, VDSMCERT = certPaths(confFile)
-
- # Delete old certificates
- logging.debug("instCert: try to delete old certificates")
- pkiCleanup(VDSMCERT, CACERT)
-
- logging.debug("instCert: install new certificates")
- # install .pem files
- shutil.copy(cert_pemfile, VDSMCERT)
- os.chown (VDSMCERT, nUID, nGID)
- os.chmod (VDSMCERT, 0444)
- if not os.path.exists(CACERT):
- shutil.copy(ca_pemfile, CACERT)
- os.chown (CACERT, nUID, nGID)
- os.chmod (CACERT, 0444)
-
- if isOvirt():
- # save the certificates
- logging.debug("instCert: persist new certificates")
- ovirtfunctions.ovirt_store_config(VDSMCERT)
- ovirtfunctions.ovirt_store_config(CACERT)
-
-
-
- ts = _tsDir(confFile)
- VDSMKEY = ts + '/keys/vdsmkey.pem'
- if not os.path.exists(ts + '/libvirt-spice'):
- os.makedirs(ts + '/libvirt-spice')
- _linkOrPersist(CACERT, ts + '/libvirt-spice/ca-cert.pem')
- _linkOrPersist(VDSMCERT, ts + '/libvirt-spice/server-cert.pem')
- _linkOrPersist(VDSMKEY, ts + '/libvirt-spice/server-key.pem')
- if not os.path.exists('/etc/pki/libvirt/private'):
- os.makedirs('/etc/pki/libvirt/private')
- _linkOrPersist(VDSMCERT, '/etc/pki/libvirt/clientcert.pem')
- _linkOrPersist(VDSMKEY, '/etc/pki/libvirt/private/clientkey.pem')
- _linkOrPersist(CACERT, '/etc/pki/CA/cacert.pem')
-
- print "<BSTRAP component='instCert' status='OK'/>"
- logging.debug("instCert: ended.")
- except:
- fReturn = False
- logging.debug("instCert: failed.", exc_info=True)
- print "<BSTRAP component='instCert' status='FAIL'/>"
-
- return fReturn
-
-def getSSLSocket(sock, certPath=None):
- """
- Returns ssl socket according to python version
- """
- try:
- import ssl
- if not certPath:
- return ssl.wrap_socket(sock)
- else:
- return ssl.wrap_socket(sock, ca_certs=certPath,
- cert_reqs=ssl.CERT_REQUIRED)
- except ImportError:
- # in python 2.4 importing ssl will fail
- ssl = socket.ssl(sock)
- return httplib.FakeSocket(sock, ssl)
-
-def createCSR(orgName, subject, random_num, tsDir, vdsmKey, dhKey):
- template = """
- RANDFILE = ~/.rnd
- [ req ]
- distinguished_name = req_distinguished_name
- prompt = no
- [ v3_ca ]
- subjectKeyIdentifier=hash
- authorityKeyIdentifier=keyid:always,issuer:always
- basicConstraints = CA:true
- [ req_distinguished_name ]
- O = %s
- CN = %s
- """ % (repr(orgName), subject)
-
- req_conffile = '/tmp/req_' + random_num + '.conf'
- cert_reqfile = '/tmp/cert_' + random_num + '.req'
- open(req_conffile, "w").write(template)
-
- if not os.path.exists(tsDir + "/keys"):
- os.mkdir(tsDir + "/keys")
-
- if not os.path.exists(tsDir + "/certs"):
- os.mkdir(tsDir + "/certs")
-
- # create private key
- _logExec([EX_OPENSSL, "genrsa", "-out", vdsmKey, str(DEF_KEY_LEN)])
- # create request for certificate
- execfn = [EX_OPENSSL, "req", "-new", "-key", vdsmKey,
- "-config", req_conffile, "-out", cert_reqfile]
- _logExec(execfn)
- if versionCompare(getOSVersion(), "6.0") < 0:
- gGroup = grp.getgrnam('kvm')
- else:
- gGroup = grp.getgrnam('qemu')
- nGID = gGroup.gr_gid
- uUserInfo = pwd.getpwnam('vdsm')
- nUID = uUserInfo.pw_uid
- os.chown (vdsmKey, nUID, nGID)
- os.chmod (vdsmKey, 0440)
-
- # openssl dhparam -out dh1024.pem 1024
- _logExec([EX_OPENSSL, "dhparam", "-out", dhKey, str(DEF_KEY_LEN)])
- os.chown (dhKey, nUID, nGID)
- os.chmod (dhKey, 0440)
-
- if isOvirt():
- # save the certificates
- ovirtfunctions.ovirt_store_config(vdsmKey)
- ovirtfunctions.ovirt_store_config(dhKey)
-
-def _cpuid(func):
- f = file('/dev/cpu/0/cpuid')
- f.seek(func)
- return struct.unpack('IIII', f.read(16))
-
-def _prdmsr(cpu, index):
- f = file("/dev/cpu/%d/msr" % cpu)
- f.seek(index)
- try:
- return struct.unpack('L', f.read(8))[0]
- except:
- return -1
-
-def _cpu_has_vmx_support():
- eax, ebx, ecx, edx = _cpuid(1)
- # CPUID.1:ECX.VMX[bit 5] -> VT
- return ecx & (1 << 5) != 0
-
-def _vmx_enabled_by_bios():
- MSR_IA32_FEATURE_CONTROL = 0x3a
- MSR_IA32_FEATURE_CONTROL_LOCKED = 0x1
- MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED = 0x4
-
- msr = _prdmsr(0, MSR_IA32_FEATURE_CONTROL);
- return (msr & (MSR_IA32_FEATURE_CONTROL_LOCKED |
- MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED)) != MSR_IA32_FEATURE_CONTROL_LOCKED
-
-def _cpu_has_svm_support():
- SVM_CPUID_FEATURE_SHIFT = 2
- SVM_CPUID_FUNC = 0x8000000a
-
- eax, ebx, ecx, edx = _cpuid(0x80000000)
- if eax < SVM_CPUID_FUNC:
- return 0
-
- eax, ebx, ecx, edx = _cpuid(0x80000001)
- if not (ecx & (1 << SVM_CPUID_FEATURE_SHIFT)):
- return 0
- return 1
-
-def _svm_enabled_by_bios():
- SVM_VM_CR_SVM_DISABLE = 4
- MSR_VM_CR = 0xc0010114
-
- vm_cr = _prdmsr(0, MSR_VM_CR)
- if vm_cr & (1 << SVM_VM_CR_SVM_DISABLE):
- return 0
- return 1
-
-def cpuVendorID():
- for line in file('/proc/cpuinfo').readlines():
- if ':' in line:
- k, v = line.split(':', 1)
- k = k.strip()
- v = v.strip()
- if k == 'vendor_id':
- if v == 'GenuineIntel':
- return v
- elif v == 'AuthenticAMD':
- return v
- return ''
-
-def virtEnabledInCpuAndBios():
- try:
- vendor = cpuVendorID()
- logging.debug('CPU vendor is %s', vendor)
-
- if vendor == 'GenuineIntel':
- bios_en = _vmx_enabled_by_bios()
- has_cpu = _cpu_has_vmx_support();
- elif vendor == 'AuthenticAMD':
- bios_en = _svm_enabled_by_bios();
- has_cpu = _cpu_has_svm_support();
- else:
- return False
-
- logging.debug('virt support in cpu: %s, in bios: %s', has_cpu, bios_en)
- return bios_en and has_cpu
- except:
- logging.error(traceback.format_exc())
- return False
-
-def getRemoteFile(IP, port, fileName, timeout=None, certPath=None):
- logging.debug("getRemoteFile start. IP = %s port = %s fileName = \"%s\""
- % (IP, port, fileName))
- data = None
- response = None
- conn = None
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.settimeout(timeout)
- fOK = True
-
- try:
- nPort = 443
- if port is not None:
- nPort = int(port)
-
- sock.connect((IP, nPort))
- conn = httplib.HTTPSConnection(IP, nPort)
- conn.sock = getSSLSocket(sock, certPath)
- conn.request("GET", fileName)
- response = conn.getresponse()
- except:
- logging.debug("%s failed in HTTPS. Retrying using HTTP." % fileName,
- exc_info=True)
- strPort = ":"
- if port is None:
- strPort += "80"
- else:
- strPort += port
-
- try:
- conn = httplib.HTTPConnection(IP + strPort)
- conn.request("GET", fileName)
- response = conn.getresponse()
- except:
- logging.error("Failed to fetch %s using http." % fileName,
- exc_info=True)
- fOK = False
- else:
- logging.debug("%s status: %s reason: %s" % \
- (fileName, str(response.status), response.reason))
-
- if response == None or response.status != 200:
- status = ""
- if response != None:
- status = str(response.status)
- if conn != None: conn.close()
- fOK = False
- logging.error("Failed to fetch %s status %s" % (fileName, status))
-
- if fOK:
- try:
- try:
- data = str(response.read())
- except:
- logging.error("Failed to read %s" % fileName, exc_info=True)
- finally:
- if conn != None: conn.close()
-
- logging.debug('getRemoteFile end.')
- return data
-
-def getRhevmCert(IP, port):
-
- CACERT, VDSMCERT = certPaths('')
- RHEVM_CERT_FILE = "/ca.crt"
- rhevmCert = getRemoteFile(str(IP), str(port), RHEVM_CERT_FILE)
- if rhevmCert:
- dirName = os.path.dirname(CACERT)
- if not os.path.exists(dirName):
- os.makedirs(dirName)
- crt = file(CACERT, "w+")
- try:
- crt.write(rhevmCert)
- finally:
- crt.close()
- return True
- else:
- return False
-
-def generateFingerPrint(path):
- fp = ''
- cmd = [EX_OPENSSL, 'x509', '-fingerprint', '-in', path]
- out, err, rc = _logExec(cmd)
- if rc is 0:
- try:
- fp = filter(lambda l: 'Fingerprint' in l, out.split())[0].split('=')[1]
- except Exception:
- logging.error("Failed generating finger print for %s" % path,
- exc_info=True)
- else:
- logging.error("Command %s failed with return value %d" % \
- (' '.join(cmd), rc))
-
- return fp
-
-def parseOptions():
- parser = OptionParser()
-
- parser.add_option("-s", "--server-address",
- action="store", dest="serverIp", type="string", default=None,
- help="IP address of RHEVM")
- parser.add_option("-p", "--server-port",
- action="store", dest="serverPort", default=None, type="string",
- help="Port of RHEVM")
-
- parser.add_option("-d", "--download-rhevm-cert", action="store_true",
- default=False, dest="downloadRhevmCert",
- help="Download certificate from RHEVM")
- parser.add_option("-f", "--fingerprint", action="store",
- dest="fingerPrint", default=None, type="string",
- help="""
- The fingerprint to compare to the fingerprint of the downloaded
- certificate""")
-
- options, args = parser.parse_args()
-
- return (options, args)
-
-def main():
- options, args = parseOptions()
-
- if options.downloadRhevmCert:
- if not options.serverIp or not options.serverPort or \
- not options.fingerPrint:
- print "Must supply RHEVM's IP, port and a fingerprint to " + \
- "verify against"
- return -1
- if not getRhevmCert(options.serverIp, options.serverPort):
- print 'Failed downloading the RHEVM certificate file'
- return -1
- CACERT, dontcare = certPaths('')
- fp = generateFingerPrint(CACERT)
- if options.fingerPrint != fp:
- print 'Expected fingerprint %s is different from recieved fingerprint %s' % (options.fingerPrint, fp)
- return -1
-
- if isOvirt():
- ovirtfunctions.ovirt_store_config(CACERT)
- print 'RHEVM certificate downloaded and verified successfully.'
- return 0
- print 'Missing arguments'
- return -1
-
-if __name__ == '__main__':
- sys.exit(main())
diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
new file mode 100644
index 0000000..5756b2e
--- /dev/null
+++ b/vdsm_reg/deployUtil.py.in
@@ -0,0 +1,1393 @@
+# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# Description: Deployment utilities.
+
+import subprocess
+import logging
+import traceback
+import socket
+import re
+import sys
+import os
+import os.path
+import time
+import grp
+import pwd
+import shutil
+from xml.sax import saxutils
+import struct
+import httplib
+import glob
+import imp
+from optparse import OptionParser
+
+try:
+ from ovirtnode import ovirtfunctions
+except ImportError:
+ pass
+
+# Path constants
+P_BIN = '/bin/'
+P_ETC_INITD = '/etc/init.d/'
+P_ROOT_SSH = '/root/.ssh'
+P_ROOT_AUTH_KEYS = P_ROOT_SSH + '/authorized_keys'
+P_SBIN = '/sbin/'
+P_USR_BIN = '/usr/bin/'
+P_USR_SBIN = '/usr/sbin/'
+P_LIBEXEC = '/usr/libexec/'
+
+# Executables
+EX_AWK = '@AWK_PATH@'
+EX_BASH = '@BASH_PATH@'
+EX_CAT = '@CAT_PATH@'
+EX_CHKCONFIG = '@CHKCONFIG_PATH@'
+EX_DMIDECODE = '@DMIDECODE_PATH@'
+EX_ECHO = '@ECHO_PATH@'
+EX_GRUBBY = '@GRUBBY_PATH@'
+EX_HEAD = '@HEAD_PATH@'
+EX_HWCLOCK = '@HWCLOCK_PATH@'
+EX_IFCONFIG = '@IFCONFIG_PATH@'
+EX_LSB_RELEASE = '@LSB_RELEASE_PATH@'
+EX_OPENSSL = '@OPENSSL_PATH@'
+EX_REBOOT = '@REBOOT_PATH@'
+EX_RPM = '@RPM_PATH@'
+EX_SED = '@SED_PATH@'
+EX_SERVICE = '@SERVICE_PATH@'
+EX_SORT = '@SORT_PATH@'
+EX_TRACEROUTE = '@TRACEROUTE_PATH@'
+EX_UNAME = '@UNAME_PATH@'
+EX_YUM = '@YUM_PATH@'
+
+# Other constants
+READ_BUF_SIZE = 1024
+DEF_KEY_LEN = 1024
+HTTP_TIMEOUT = 30
+ERR_NO_ROUTE = 7
+SCRIPT_NAME_ADD = "addNetwork"
+SCRIPT_NAME_DEL = "delNetwork"
+IFACE_CONFIG = "/etc/sysconfig/network-scripts/ifcfg-"
+MGT_BRIDGE_NAME = "rhevm"
+REMOTE_SSH_KEY_FILE = "/rhevm.ssh.key.txt"
+CORE_DUMP_PATH = '/var/lib/vdsm/core'
+CORE_PATTERN = '/proc/sys/kernel/core_pattern'
+XML_QUOTES = {
+ "\n":' ',
+ "'":'~'
+}
+
+def _logExec(argv):
+ """
+ This function executes a given shell command while logging it.
+ """
+ out = None
+ err = None
+ rc = None
+ try:
+ logging.debug(argv)
+ p = subprocess.Popen(argv , stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ out, err = p.communicate()
+ rc = p.returncode
+ logging.debug(out)
+ logging.debug(err)
+ except:
+ logging.error(traceback.format_exc())
+ return (out, err, rc)
+
+#############################################################################################################
+# Host Misc functions.
+#############################################################################################################
+def escapeXML(message):
+ """
+ Escape '&', '<', '>', and '\n' in a given string.
+ """
+ return saxutils.escape(message, XML_QUOTES)
+
+def reboot():
+ """
+ This function reboots the machine.
+ """
+ fReturn = True
+
+ out, err, ret = _logExec([EX_REBOOT])
+ if ret:
+ fReturn = False
+
+ return fReturn
+
+def setCoreDumpPath():
+ logging.debug("setCoreDumpPath started.")
+ fReturn = True
+ try:
+ _logExec([EX_ECHO, CORE_DUMP_PATH, ">", CORE_PATTERN])
+ print "<BSTRAP component='CoreDump' status='OK'/>"
+ except:
+ fReturn = False
+ print "<BSTRAP component='CoreDump' status='FAIL'/>"
+
+ logging.debug("setCoreDumpPath end:" + str(fReturn))
+ return fReturn
+
+def cleanAll(random_num):
+ """ Remove temp files.
+ """
+ fReturn = True
+ try:
+ # build semi-random filenames
+ req_conffile = '/tmp/req_' + random_num + '.conf'
+ cert_reqfile = '/tmp/cert_' + random_num + '.req'
+ cert_pemfile = '/tmp/cert_' + random_num + '.pem'
+ ca_pemfile = '/tmp/CA_' + random_num + '.pem'
+ # remove unnecessary files
+ os.unlink(req_conffile)
+ os.unlink(cert_reqfile)
+ os.unlink(cert_pemfile)
+ os.unlink(ca_pemfile)
+
+ if not isOvirt():
+ vds_bstrap = '/tmp/vds_bootstrap_' + random_num + '.py'
+ vds_bstrap_cmp = '/tmp/vds_bootstrap_complete_' + random_num + '.py'
+ vds_bstrap_pyc = '/tmp/vds_bootstrap_' + random_num + '.pyc'
+ vds_bstrap_cmp_pyc = '/tmp/vds_bootstrap_complete_' + random_num + '.pyc'
+ vds_bstrap_deployutil = '/tmp/deployUtil.py'
+ vds_bstrap_deployutil_pyc = '/tmp/deployUtil.pyc'
+ os.unlink(vds_bstrap)
+ os.unlink(vds_bstrap_cmp)
+ os.unlink(vds_bstrap_pyc)
+ os.unlink(vds_bstrap_cmp_pyc)
+ os.unlink(vds_bstrap_deployutil)
+ os.unlink(vds_bstrap_deployutil_pyc)
+
+ except:
+ pass
+
+ print "<BSTRAP component='cleanAll' status='OK'/>"
+ logging.debug("cleanAll end:" + str(fReturn))
+
+ return fReturn
+
+def setVdsConf(configStr, confFile):
+ """
+ This function changes local configuration according to the
+ given 'key=value;' string.
+ """
+ fReturn = True
+ logging.debug("setVdsConf: started. config:" + str(configStr))
+ if not configStr:
+ logging.debug("setVdsConf: nothing to set.")
+ return True
+
+ if not os.path.exists(confFile):
+ strMessage = escapeXML("File " + confFile + "does not exist.")
+ print "<BSTRAP component='VDS Configuration' status='FAIL' message='" + strMessage + "'/>"
+ logging.debug("setVdsConf: " + strMessage)
+ return False
+
+ try:
+ new_config_params = {}
+ config_params = configStr.split(';')
+ for item in config_params:
+ key = item.split('=')[0].strip()
+ val = item.split('=')[1].strip()
+ new_config_params[key] = val
+
+ for key in new_config_params.keys():
+ val = new_config_params[key]
+ logging.debug("setVdsConf: setting Key=" + str(key) + " to val=" + str(val))
+ _updateFileLine(confFile, key, val)
+ #_logExec([EX_SED, "-i", "s:^\s*"+key+"\s*=.*:"+key+"="+val+":", confFile])
+
+ if isOvirt():
+ # save the updated file
+ logging.debug("setVdsConf: saving new config file")
+ ovirtfunctions.ovirt_store_config(confFile)
+
+ print "<BSTRAP component='VDS Configuration' status='OK'/>"
+ except Exception, e:
+ msg = escapeXML(str(e))
+ print "<BSTRAP component='VDS Configuration' status='FAIL' message='%s'/>" % (msg)
+ logging.debug("setVdsConf: exception " + msg)
+ fReturn = False
+
+ logging.debug("setVdsConf: ended.")
+ return fReturn
+
+def getMachineUUID():
+ """
+ This function parses the DMI data for the host's UUID. If not found, returns "None".
+ """
+ strReturn = "None"
+
+ out, err, ret = _logExec([EX_BASH, "-c", EX_DMIDECODE + "|" + EX_AWK + " ' /^\tUUID: /{ print $2; } '"])
+ if ret == 0 and "Not" not in out: #Avoid error string- 'Not Settable' or 'Not Present'
+ strReturn = out.replace ("\n", "")
+ else:
+ logging.error("getMachineUUID: Could not find machine's UUID.")
+
+ return strReturn
+
+def getMacs():
+ macs = []
+ for b in glob.glob('/sys/class/net/*/device'):
+ nic = b.split('/')[-2]
+ addr = '/sys/class/net/' + nic + '/address'
+ mac = file(addr).readlines()[0].split()[0]
+ macs.append(mac)
+
+ return macs
+
+def getHostID():
+ """
+ This function concatenate the first serted mac address to the machine's UUID.
+ """
+ strReturn = getMachineUUID()
+
+ macs = getMacs()
+
+ if len(macs) > 0:
+ strMAC = sorted(macs)[0]
+ else:
+ strMAC = ""
+ logging.warning("getHostID: Could not find machine's MAC, returning UUID only.")
+
+ if strReturn != "None":
+ strReturn += "_" + strMAC
+ else:
+ strReturn = "_" + strMAC
+
+ logging.debug("getHostID: " + str(strReturn))
+ return strReturn
+
+def _getIfaceByIP(addr):
+ remote = struct.unpack('I', socket.inet_aton(addr))[0]
+ for line in file('/proc/net/route').readlines()[1:]:
+ iface, dest, gateway, flags, refcnt, use, metric, \
+ mask, mtu, window, irtt = line.split()
+ dest = int(dest, 16)
+ mask = int(mask, 16)
+ if remote & mask == dest & mask:
+ return iface
+
+ return None # should never get here w/ default gw
+
+def _getMGTIface(vdcHostName):
+ strVDCIP = "None"
+ strReturn = None
+ strVDCName = vdcHostName
+
+ try:
+ if vdcHostName != "None":
+ logging.debug("_getMGTIface: read vdc_host_name: " + strVDCName)
+ #Now find the IP. Note that gethostbyname(IP) == IP
+ strVDCIP = socket.gethostbyname(strVDCName)
+ except:
+ strVDCIP = "None"
+ logging.debug("_getMGTIface: error trying to figure out VDC's IP")
+
+ logging.debug("_getMGTIface: using vdc_host_name " + strVDCName + " strVDCIP= " + strVDCIP)
+
+ # Find the interface of the management IP
+ if strVDCIP != "None":
+ strReturn = _getIfaceByIP(strVDCIP)
+
+ logging.debug("_getMGTIface VDC IP=" + str(strVDCIP) + " strIface=" + str(strReturn))
+ return strReturn
+
+def getMGTIP(vdsmDir, vdcHostName):
+ strReturn = "None"
+
+ try:
+ sys.path.append(vdsmDir)
+ import netinfo # taken from vdsm rpm
+ except:
+ logging.error("getMGTIP: Faild to find vdsm modules!")
+ return strReturn
+
+ arNICs = None
+ strIface = _getMGTIface(vdcHostName)
+
+ if strIface is not None:
+ arNICs = netinfo.ifconfig()
+
+ logging.debug("getMGTIP: Host parsed interfaces:\n" + str(arNICs) + "\n")
+
+ if arNICs != None:
+ strReturn = arNICs[strIface]['addr']
+
+ logging.debug("getMGTIP: Host MGT IP=" + strReturn)
+ return strReturn
+
+def preventDuplicate():
+ """
+ This function checks if the needed bridge (rhevm) already exist.
+ """
+ fFound = False
+
+ if os.path.exists('/sys/class/net/' + MGT_BRIDGE_NAME):
+ fFound = True
+ logging.debug("Bridge rhevm already exists.")
+ else:
+ logging.debug("Bridge rhevm not found, need to create it.")
+
+ return fFound
+
+def isOvirt():
+ """
+ This function checks if current machine runs ovirt platform.
+ """
+ return os.path.exists('/etc/rhev-hypervisor-release')
+
+def getOSVersion():
+ """
+ Return the OS' release from accordong to LSB specification.
+ """
+ strReturn = "Unknown OS"
+
+ if os.path.exists(EX_LSB_RELEASE):
+ out, err, rc = _logExec([EX_LSB_RELEASE, "-rs"])
+ try:
+ strReturn = out.replace("\n","")
+ except:
+ strReturn = "Unknown OS"
+
+ return strReturn
+
+def getKernelVersion():
+ """
+ Return current kernel release.
+ """
+ strReturn = '0'
+ out, err, rc = _logExec([EX_UNAME, "-r"])
+ if not rc:
+ strReturn = out
+
+ return strReturn
+
+def updateKernelArgs(arg):
+ """
+ Update current kernel arguments using grubby.
+ """
+ fReturn = False
+ try:
+ out, err, ret = _logExec([EX_GRUBBY, "--update-kernel",
+ "DEFAULT", "--args", arg] )
+ if not ret:
+ fReturn = True
+ except:
+ pass
+
+ return fReturn
+
+def getAddress(url):
+ logging.debug("getAddress Entry. url=" + str(url))
+ import urlparse
+ strRetAddress = None
+ strRetPort = None
+ scheme = None
+ netloc = None
+ path = None
+ query = None
+ fragment = None
+
+ (scheme, netloc, path, query, fragment) = urlparse.urlsplit(url)
+ if scheme != '': #('http', 'www.redhat.com', '/rhel/virtualization/', '', '')
+ strRetAddress = netloc
+ elif path != '': #('', '', 'www.redhat.com', '', '')
+ strRetAddress = path
+ else:
+ logging.error("Unable to parse: " + str(url))
+
+ # Find port
+ if strRetAddress is not None and ":" in strRetAddress:
+ strRetAddress, strRetPort = strRetAddress.split(":")
+
+ logging.debug("getAddress return. address=" + str(strRetAddress) + " port=" + str(strRetPort))
+ return strRetAddress, strRetPort
+
+def waitRouteRestore(maxCount, targetIP):
+ logging.debug("waitRouteRestore Entry. maxCount=" + str(maxCount) + " targetIP:" + targetIP)
+
+ fReturn = True
+ count = 0
+ ret1 = ERR_NO_ROUTE #no route error code
+ while(count<maxCount and ret1 == ERR_NO_ROUTE):
+ try:
+ out1, err1, ret1 = _logExec([
+ '/usr/bin/curl',
+ '-s',
+ '--connect-timeout', '10',
+ '--max-filesize', '10',
+ targetIP
+ ])
+ except:
+ pass
+
+ count = count + 1
+ logging.debug(
+ " count=" + str(count-1) +
+ "\nout=" + out1 +
+ "\nerr=" + str(err1) +
+ "\nret=" + str(ret1)
+ )
+ time.sleep(1)
+
+ if ret1 == ERR_NO_ROUTE:
+ fReturn = False
+
+ logging.debug("waitRouteRestore Return. fReturn=" + str(fReturn))
+ return fReturn
+
+def setService(srvName, action):
+ """
+ Perform an action (stop/start/status/...) on a service
+ """
+ nReturn = 0
+ out = None
+ err = None
+ if type(srvName) == type(None):
+ nReturn = 1
+ message = "setService: ignoring None service."
+ err = message
+ logging.error(message)
+ elif os.path.exists(P_ETC_INITD + srvName):
+ out, err, nReturn = _logExec([EX_SERVICE, srvName, action])
+ else:
+ nReturn = 1
+ err = "No such service: " + srvName
+
+ return out, err, nReturn
+
+def chkConfig(srvName, action, level=None):
+ """
+ Perform a set action (on/off/reset) on an init script
+ """
+ nReturn = 0
+ out = None
+ err = None
+ if type(srvName) == type(None):
+ nReturn = 1
+ message = "chkConfig: ignoring None service."
+ err = message
+ logging.error(message)
+ elif os.path.exists(P_ETC_INITD + srvName):
+ if level:
+ out, err, nReturn = _logExec([EX_CHKCONFIG, '--level', level, srvName, action])
+ else:
+ out, err, nReturn = _logExec([EX_CHKCONFIG, srvName, action])
+ else:
+ if action != "off":
+ nReturn = 1
+ err = "No such service: " + srvName
+ else:
+ logging.debug("chkConfig: ignoring uninstalled service: " + str(srvName))
+
+ return out, err, nReturn
+
+
+#############################################################################################################
+# Host SSH functions.
+#############################################################################################################
+
+def getAuthKeysFile(IP, port):
+ """
+ This functions returns the public ssh key of rhev-m.
+ """
+ CACERT, dontcare = certPaths('')
+ return getRemoteFile(IP, port, REMOTE_SSH_KEY_FILE, timeout=HTTP_TIMEOUT,
+ certPath=CACERT)
+
+def addSSHKey(path, strKey):
+ resKeys = []
+
+ try:
+ for key in file(path):
+ if key != '\n' and not key.endswith("== rhevm") or key.startswith("#"):
+ resKeys.append(key)
+ except IOError:
+ logging.debug("Failed to read %s" % path)
+ resKeys.append('\n' + strKey)
+
+ if isOvirt():
+ # No problem to write to the original file here, since until it is not
+ # persisted the old values are in place
+ open(path, 'w').write(''.join(resKeys))
+ else:
+ tmpFilePath = path + '.tmp'
+ open(tmpFilePath, 'w').write(''.join(resKeys))
+ os.rename(tmpFilePath, path)
+
+def handleSSHKey(strKey):
+ """
+ This functions appends a given key to the root's authorized_keys file.
+ """
+ fReturn = True
+ logging.debug('handleSSHKey start')
+ if not os.path.exists(P_ROOT_SSH):
+ logging.debug("handleSSHKey: creating .ssh dir.")
+ try:
+ os.mkdir(P_ROOT_SSH, 0700)
+ except OSError:
+ fReturn = False
+ logging.debug("handleSSHKey: failed to create ssh dir!")
+
+ if fReturn:
+ try:
+ addSSHKey(P_ROOT_AUTH_KEYS, strKey)
+ except:
+ fReturn = False
+ logging.debug("handleSSHKey: failed to write authorized_keys!",
+ exc_info=True)
+
+ if fReturn:
+ try:
+ os.chmod(P_ROOT_AUTH_KEYS, 0644)
+ except:
+ fReturn = False
+ logging.debug("handleSSHKey: failed to chmod authorized_keys")
+
+ if fReturn and isOvirt():
+ # persist authorized_keys
+ logging.debug("handleSSHKey: persist authorized_keys")
+ ovirtfunctions.ovirt_store_config(P_ROOT_AUTH_KEYS)
+
+ logging.debug('handleSSHKey end')
+ return fReturn
+
+#############################################################################################################
+# Host time functions.
+#############################################################################################################
+
+def setHostTime(VDCTime):
+ logging.debug('setHostTime start.')
+ import time
+ fReturn = True
+
+ try:
+ ttp = time.strptime(VDCTime, '%Y-%m-%dT%H:%M:%S')
+ except ValueError, e:
+ logging.debug("setHostTime: Failed to parse RHEVM time. message= " + str(e))
+ fReturn = False
+
+ if fReturn:
+ out, err, rc = _logExec([EX_HWCLOCK, "--set", "--utc",
+ time.strftime('--date=%Y-%m-%d %H:%M:%S UTC', ttp)])
+ if rc:
+ logging.debug("setHostTime: Failed to set hwclock time. out=" + out + "\nerr=" + str(err) + "\nrc=" + str(rc))
+ fReturn = False
+
+ if fReturn:
+ out, err, rc = _logExec([EX_HWCLOCK, "-s"])
+ if rc:
+ logging.debug("setHostTime: Failed to sync hwclock time to host. out=" + out + "\nerr=" + str(err) + "\nrc=" + str(rc))
+ fReturn = False
+
+ logging.debug('setHostTime end. Return:' + str(fReturn))
+ return fReturn
+
+#############################################################################################################
+# Update configuration file functions.
+#############################################################################################################
+
+def _updateFileLine(fileName, key, value):
+ """
+ Update a line of a configuration file. This function will replace the whole line!
+ The function returns success is replacment took place.
+ """
+ import stat
+ from tempfile import mkstemp
+ fReplaced = False
+ logging.debug(
+ "_updateFileLine: entry. File: " + str(fileName) +
+ " key=" + str(key) +
+ " value=" + str(value)
+ )
+
+ try:
+ #Preserve current file mode
+ mode = os.stat(fileName)[stat.ST_MODE]
+
+ #Create temp file
+ fh, abs_path = mkstemp()
+ new_file = open(abs_path,'w')
+ old_file = open(fileName)
+ #Iterate over the existing file, while replacing if needed.
+ for line in old_file:
+ #Note: the line below must not have spaces before or after the '=', since it'll fail bash scripts !
+ newLine = re.sub('^[#\s]*%s\s*=.*' % key , '%s=%s' % (key, value), line)
+ if re.match('^%s=%s$' % (re.escape(key), re.escape(value)), newLine):
+ logging.debug("_updateFileLine: replacing " + str(line) + " with: " + newLine)
+ fReplaced = True
+ line = newLine
+ new_file.write(line)
+ new_file.close()
+ os.close(fh)
+ old_file.close()
+ #Move new file
+ shutil.move(abs_path, fileName)
+
+ #Restore original file mode
+ os.chmod(fileName, mode)
+ except:
+ try:
+ old_file.close()
+ except:
+ pass
+ logging.error("_updateFileLine: error replacing " + str(key) + "=" + str(value))
+ logging.error(traceback.format_exc())
+
+ logging.debug("_updateFileLine: return: " + str(fReplaced))
+ return fReplaced
+
+#############################################################################################################
+# Host bridge functions.
+#############################################################################################################
+
+def _getBridgeParams(bridgeName):
+ import shlex
+
+ fIsBridgeDevice = False
+ lstReturn = []
+ fileName = IFACE_CONFIG + bridgeName
+
+ try:
+ for line in file(fileName):
+ line = line.strip()
+ if line.startswith("DEVICE=") or \
+ line.startswith("#") or \
+ line.startswith("HWADDR="):
+ pass
+ elif line.startswith("TYPE="):
+ t = line.split("=", 1)[1].strip()
+ fIsBridgeDevice = (t == "Bridge")
+ else:
+ try:
+ line = ''.join(shlex.split(line))
+ except:
+ logging.warn("_getBridgeParams: failed to read parse line %s", line)
+ lstReturn.append(line)
+ except Exception, e:
+ logging.error("_getBridgeParams: failed to read params of file " + fileName + ".\n Error:" + str(e))
+ lstReturn = []
+
+ return lstReturn, fIsBridgeDevice
+
+def _getOvirtBridgeParams(mgtBridge):
+ """
+ This helper function extract the relevant parameters of the existing
+ ovirt bridge in order to re-create it as a managment bridge.
+ """
+ import netinfo # taken from vdsm rpm
+ vlan = ''
+ bonding = ''
+ nic = None
+ nics = []
+
+ try:
+ vlan, bonding, nics = netinfo.getVlanBondingNic(mgtBridge)
+ nic = nics[0]
+ except:
+ nic = None
+ logging.error("_getOvirtBridgeParams Failed to get bridge data:")
+ logging.error(traceback.format_exc())
+
+ return vlan, bonding, nic
+
+def _getRHELBridgeParams(mgtIface):
+ """
+ This helper function extract the relevant parameters of the existing
+ RHEL interface, in order to create a managment bridge.
+ """
+ import netinfo # taken from vdsm rpm
+ vlan = ''
+ bonding = ''
+ nic = None
+
+ try:
+ vlans = netinfo.vlans()
+ if mgtIface in vlans:
+ nic = netinfo.getVlanDevice(mgtIface)
+ vlan = netinfo.getVlanID(mgtIface)
+ else:
+ nic = mgtIface
+
+ if nic in netinfo.bondings():
+ logging.error(
+ "_getRHELBridgeParams Found bonding: " +
+ str(nic) +
+ ". This network configuration is not supported! Please configure rhevm bridge manually and re-install."
+ )
+ nic = None
+ except:
+ logging.error("_getRHELBridgeParams Failed to test for VLAN data")
+ logging.error(traceback.format_exc())
+ nic = None
+
+ return vlan, bonding, nic
+
+def setSafeVdsmNetworkConfig():
+ """consider current network configuration as safe and remove its backup"""
+ if versionCompare(getOSVersion(), "6.0") < 0:
+ shutil.rmtree("/etc/sysconfig/network-scripts/.vdsmback")
+ else:
+ import glob
+ for f in glob.glob("/var/lib/vdsm/netconfback/*"):
+ if os.path.isdir(f):
+ shutil.rmtree(f)
+ else:
+ os.remove(f)
+
+
+def makeBridge(vdcName, vdsmDir):
+ """
+ Create (for RHEL) or rename (oVirt default bridge) to rhevm bridge.
+ """
+ logging.debug('makeBridge begin.')
+ sys.path.append(vdsmDir)
+ try:
+ imp.find_module('netinfo') # taken from vdsm rpm
+ except ImportError:
+ logging.error("makeBridge Faild to find vdsm modules!")
+ return False
+
+ fReturn = True
+ out = ""
+ err = None
+ ret = None
+ nic = None
+ fIsOvirt = isOvirt()
+
+ # get current management interface
+ mgtIface = _getMGTIface(vdcName)
+ if mgtIface is None:
+ fReturn = False
+ logging.debug("makeBridge got mgtIface None. This is a routing or resolution issue.")
+ else:
+ mgtBridge = mgtIface
+ if fIsOvirt and mgtIface.startswith('br'):
+ mgtIface = mgtIface.replace("br", "", 1) #oVirt naming convention: br + iface
+
+ if fReturn:
+ # Read params from current bridge (bootproto, etc)
+ Iface = mgtIface
+ if fIsOvirt: Iface = mgtBridge
+ lstBridgeOptions, fIsBridgeDevice = _getBridgeParams(Iface)
+
+ if len(lstBridgeOptions) == 0:
+ logging.error("makeBridge Failed to read existing nic parameters")
+ fReturn = False
+ elif fIsBridgeDevice and not fIsOvirt:
+ logging.error("makeBridge found existing bridge named: " + Iface)
+ fReturn = False
+ else:
+ logging.debug("makeBridge found the following bridge paramaters: " + str(lstBridgeOptions))
+ # No more handling GATEWAYDEV.
+
+ if fReturn:
+ if fIsOvirt:
+ vlan, bonding, nic = _getOvirtBridgeParams(mgtBridge)
+ else:
+ vlan, bonding, nic = _getRHELBridgeParams(mgtIface)
+ fReturn = (nic is not None)
+
+ #Delete existing bridge in oVirt
+ if fReturn and fIsOvirt:
+ try:
+ out, err, ret = _logExec([os.path.join(vdsmDir, SCRIPT_NAME_DEL), mgtBridge, vlan, bonding, nic])
+ if ret:
+ if ret == 17: #ERR_BAD_BRIDGE
+ logging.debug("makeBridge Ignoring error of del existing bridge. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
+ else:
+ fReturn = False
+ logging.debug("makeBridge Failed to del existing bridge. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
+ except:
+ fReturn = False
+ logging.debug("makeBridge Failed to del existing bridge. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
+
+ #Add rhevm bridge
+ if fReturn:
+ try:
+ lstBridgeOptions.append('blockingdhcp=true')
+ out, err, ret = _logExec([os.path.join(vdsmDir, SCRIPT_NAME_ADD) , MGT_BRIDGE_NAME, vlan, bonding, nic] + lstBridgeOptions)
+ if ret:
+ fReturn = False
+ logging.debug("makeBridge Failed to add rhevm bridge out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
+ except:
+ fReturn = False
+ logging.debug("makeBridge Failed to add rhevm bridge out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret))
+
+ #Save current config by removing the undo files:
+ try:
+ if fReturn and not fIsOvirt:
+ setSafeVdsmNetworkConfig()
+ except:
+ logging.debug(traceback.format_exc())
+
+ if not fReturn:
+ logging.error(
+ "makeBridge errored: " +
+ " out=" + out +
+ "\nerr=" + str(err) +
+ "\nret=" + str(ret)
+ )
+
+ logging.debug('makeBridge return.')
+ return fReturn
+
+#############################################################################################################
+# Host package / rpm functions.
+#############################################################################################################
+
+def getPackageInfo(pckg_type, rpm_name, op):
+ """
+ Return an indication if given package name is installed or not.
+ """
+ strReturn = "FAIL"
+ out, err, rc = _logExec([EX_RPM, "-q", rpm_name])
+ if rc:
+ if op == 'install':
+ if pckg_type != "DEVEL":
+ strReturn = "FAIL"
+ out += err
+ else:
+ strReturn = "WARN"
+ else:
+ strReturn = "WARN"
+ else:
+ strReturn = "OK"
+
+ return strReturn, out
+
+def versionCompare(pkg1, pkg2):
+ """
+ Return an indication if given package1 is:
+ -1: pkg1 < pkg2
+ 0: pkg1 == pkg2
+ 1: pkg1 > pkg2
+ 99 import Exception
+ """
+ nReturn = 0
+
+ try:
+ import rpmUtils
+ import rpmUtils.miscutils
+ except:
+ nReturn = 99
+
+ if nReturn == 0:
+ nReturn = rpmUtils.miscutils.compareEVR(
+ rpmUtils.miscutils.stringToVersion(pkg1),
+ rpmUtils.miscutils.stringToVersion(pkg2)
+ )
+
+ return nReturn
+
+def yumCleanCache():
+ """
+ Clean yum's current cache.
+ """
+ fReturn = False
+ out, err, ret = _logExec([EX_YUM, "clean", "all"] )
+ if not ret:
+ fReturn = True
+
+ return fReturn
+
+def yumInstallDeleteUpdate(pckgName, action, args=None):
+ """
+ Call yum to install, delete or update a given package name.
+ """
+ execFunc = [EX_YUM, "-y"]
+ if args is not None:
+ execFunc += args
+
+ if action == "install":
+ execFunc.append(action)
+ elif action == "remove":
+ execFunc.append(action)
+ else:
+ execFunc.append("update")
+ execFunc.append(pckgName)
+
+ return _logExec(execFunc)
+
+def installAndVerify(pckgType, pckgName, action, args=None):
+ """
+ This function uses other module functions to install or update
+ a package, and then verify it.
+ """
+ fReturn = True
+ out, err, ret = yumInstallDeleteUpdate(pckgName, action, args=None)
+ msg = None
+ if not ret:
+ fReturn, msg = getPackageInfo(pckgType, pckgName, 'install')
+ else:
+ fReturn = False
+ msg = out + err
+
+ return fReturn, msg
+
+def yumFind(pkgName):
+ """
+ Returns a list of available packages exists in yum's db.
+ """
+ import yum
+ lReturn = None
+
+ my = yum.YumBase()
+ my.preconf.debuglevel = 0 # Remove yum noise
+ lReturn = my.pkgSack.searchNevra(name=pkgName)
+
+ return lReturn
+
+def yumSearch(pkgName):
+ """
+ Returns True is package exists in yum's db.
+ """
+ fReturn = False
+
+ pkgs = yumFind(pkgName)
+ if pkgs and len(pkgs)>0:
+ fReturn = True
+ logging.debug("yumSearch: found " + str(pkgName) + " entries: " + str(pkgs))
+ else:
+ logging.debug("yumSearch: package " + str(pkgName) + " not found!")
+
+ return fReturn
+
+def yumSearchVersion(pkgName, ver, startWith=True):
+ """
+ Returns True is package exists in yum's db with the given version.
+ Note: yum internal code has verEQ and verGT. We should use it ASAP.
+ """
+ fReturn = False
+
+ pkgs = yumFind(pkgName)
+ if pkgs and len(pkgs)>0:
+ for item in pkgs:
+ if startWith:
+ if str(item).startswith(ver):
+ fReturn = True
+ logging.debug("yumSearchVersion: pkg " + str(item) + " starts with: " + ver)
+ else:
+ logging.debug("yumSearchVersion: pkg " + str(item) + " does not start with: " + ver)
+ else:
+ if str(item) == ver:
+ fReturn = True
+ logging.debug("yumSearchVersion: pkg " + str(item) + " matches: " + ver)
+ else:
+ logging.debug("yumSearchVersion: pkg " + str(item) + " does not match: " + ver)
+ else:
+ logging.debug("yumSearchVersion: package " + str(pkgName) + " not found!")
+
+ return fReturn
+
+#############################################################################################################
+# Host PKI functions.
+#############################################################################################################
+
+def _tsDir(confFile):
+ import ConfigParser
+
+ config = ConfigParser.ConfigParser()
+ config.read(confFile)
+ try:
+ tsDir = config.get('vars', 'trust_store_path')
+ except:
+ tsDir = '/etc/pki/vdsm'
+ return tsDir
+
+def certPaths(confFile, fAddID=False):
+ tsDir = _tsDir(confFile)
+
+ VDSMCERT = tsDir + "/certs/vdsmcert.pem"
+ if fAddID:
+ VDSMCERT = tsDir + "/certs/vdsm-" + os.environ.get("SSH_CONNECTION").split()[2] + "-cert.pem"
+ CACERT = tsDir + "/certs/cacert.pem"
+
+ return CACERT, VDSMCERT
+
+def pkiCleanup(key, cert):
+ """
+ Removes all the previously installed keys and certificates
+ """
+ if os.path.exists(key):
+ if isOvirt():
+ ovirtfunctions.ovirt_safe_delete_config(key)
+ else:
+ os.unlink(key)
+
+ if os.path.exists(cert):
+ if isOvirt():
+ ovirtfunctions.ovirt_safe_delete_config(cert)
+ else:
+ os.unlink(cert)
+
+def _linkOrPersist(src, dst):
+ # we have to copy the key and cert since ovirt currently cannot persist
+ # softlinks
+ if isOvirt():
+ shutil.copy2(src, dst)
+ st = os.stat(src)
+ os.chown(dst, st.st_uid, st.st_gid)
+ ovirtfunctions.ovirt_store_config(dst)
+ else:
+ try:
+ os.unlink(dst)
+ except:
+ pass
+ os.symlink(src, dst)
+
+def instCert(random_num, confFile):
+ """ Install certificate.
+ """
+ fReturn = True
+
+ try:
+ logging.debug("instCert: start. num=" + str(random_num))
+ # build semi-random filenames
+ cert_pemfile = '/tmp/cert_' + random_num + '.pem'
+ ca_pemfile = '/tmp/CA_' + random_num + '.pem'
+ gGroup = grp.getgrnam('kvm')
+ nGID = gGroup.gr_gid
+ uUserInfo = pwd.getpwnam('vdsm')
+ nUID = uUserInfo.pw_uid
+ CACERT, VDSMCERT = certPaths(confFile)
+
+ # Delete old certificates
+ logging.debug("instCert: try to delete old certificates")
+ pkiCleanup(VDSMCERT, CACERT)
+
+ logging.debug("instCert: install new certificates")
+ # install .pem files
+ shutil.copy(cert_pemfile, VDSMCERT)
+ os.chown (VDSMCERT, nUID, nGID)
+ os.chmod (VDSMCERT, 0444)
+ if not os.path.exists(CACERT):
+ shutil.copy(ca_pemfile, CACERT)
+ os.chown (CACERT, nUID, nGID)
+ os.chmod (CACERT, 0444)
+
+ if isOvirt():
+ # save the certificates
+ logging.debug("instCert: persist new certificates")
+ ovirtfunctions.ovirt_store_config(VDSMCERT)
+ ovirtfunctions.ovirt_store_config(CACERT)
+
+
+
+ ts = _tsDir(confFile)
+ VDSMKEY = ts + '/keys/vdsmkey.pem'
+ if not os.path.exists(ts + '/libvirt-spice'):
+ os.makedirs(ts + '/libvirt-spice')
+ _linkOrPersist(CACERT, ts + '/libvirt-spice/ca-cert.pem')
+ _linkOrPersist(VDSMCERT, ts + '/libvirt-spice/server-cert.pem')
+ _linkOrPersist(VDSMKEY, ts + '/libvirt-spice/server-key.pem')
+ if not os.path.exists('/etc/pki/libvirt/private'):
+ os.makedirs('/etc/pki/libvirt/private')
+ _linkOrPersist(VDSMCERT, '/etc/pki/libvirt/clientcert.pem')
+ _linkOrPersist(VDSMKEY, '/etc/pki/libvirt/private/clientkey.pem')
+ _linkOrPersist(CACERT, '/etc/pki/CA/cacert.pem')
+
+ print "<BSTRAP component='instCert' status='OK'/>"
+ logging.debug("instCert: ended.")
+ except:
+ fReturn = False
+ logging.debug("instCert: failed.", exc_info=True)
+ print "<BSTRAP component='instCert' status='FAIL'/>"
+
+ return fReturn
+
+def getSSLSocket(sock, certPath=None):
+ """
+ Returns ssl socket according to python version
+ """
+ try:
+ import ssl
+ if not certPath:
+ return ssl.wrap_socket(sock)
+ else:
+ return ssl.wrap_socket(sock, ca_certs=certPath,
+ cert_reqs=ssl.CERT_REQUIRED)
+ except ImportError:
+ # in python 2.4 importing ssl will fail
+ ssl = socket.ssl(sock)
+ return httplib.FakeSocket(sock, ssl)
+
+def createCSR(orgName, subject, random_num, tsDir, vdsmKey, dhKey):
+ template = """
+ RANDFILE = ~/.rnd
+ [ req ]
+ distinguished_name = req_distinguished_name
+ prompt = no
+ [ v3_ca ]
+ subjectKeyIdentifier=hash
+ authorityKeyIdentifier=keyid:always,issuer:always
+ basicConstraints = CA:true
+ [ req_distinguished_name ]
+ O = %s
+ CN = %s
+ """ % (repr(orgName), subject)
+
+ req_conffile = '/tmp/req_' + random_num + '.conf'
+ cert_reqfile = '/tmp/cert_' + random_num + '.req'
+ open(req_conffile, "w").write(template)
+
+ if not os.path.exists(tsDir + "/keys"):
+ os.mkdir(tsDir + "/keys")
+
+ if not os.path.exists(tsDir + "/certs"):
+ os.mkdir(tsDir + "/certs")
+
+ # create private key
+ _logExec([EX_OPENSSL, "genrsa", "-out", vdsmKey, str(DEF_KEY_LEN)])
+ # create request for certificate
+ execfn = [EX_OPENSSL, "req", "-new", "-key", vdsmKey,
+ "-config", req_conffile, "-out", cert_reqfile]
+ _logExec(execfn)
+ if versionCompare(getOSVersion(), "6.0") < 0:
+ gGroup = grp.getgrnam('kvm')
+ else:
+ gGroup = grp.getgrnam('qemu')
+ nGID = gGroup.gr_gid
+ uUserInfo = pwd.getpwnam('vdsm')
+ nUID = uUserInfo.pw_uid
+ os.chown (vdsmKey, nUID, nGID)
+ os.chmod (vdsmKey, 0440)
+
+ # openssl dhparam -out dh1024.pem 1024
+ _logExec([EX_OPENSSL, "dhparam", "-out", dhKey, str(DEF_KEY_LEN)])
+ os.chown (dhKey, nUID, nGID)
+ os.chmod (dhKey, 0440)
+
+ if isOvirt():
+ # save the certificates
+ ovirtfunctions.ovirt_store_config(vdsmKey)
+ ovirtfunctions.ovirt_store_config(dhKey)
+
+def _cpuid(func):
+ f = file('/dev/cpu/0/cpuid')
+ f.seek(func)
+ return struct.unpack('IIII', f.read(16))
+
+def _prdmsr(cpu, index):
+ f = file("/dev/cpu/%d/msr" % cpu)
+ f.seek(index)
+ try:
+ return struct.unpack('L', f.read(8))[0]
+ except:
+ return -1
+
+def _cpu_has_vmx_support():
+ eax, ebx, ecx, edx = _cpuid(1)
+ # CPUID.1:ECX.VMX[bit 5] -> VT
+ return ecx & (1 << 5) != 0
+
+def _vmx_enabled_by_bios():
+ MSR_IA32_FEATURE_CONTROL = 0x3a
+ MSR_IA32_FEATURE_CONTROL_LOCKED = 0x1
+ MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED = 0x4
+
+ msr = _prdmsr(0, MSR_IA32_FEATURE_CONTROL);
+ return (msr & (MSR_IA32_FEATURE_CONTROL_LOCKED |
+ MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED)) != MSR_IA32_FEATURE_CONTROL_LOCKED
+
+def _cpu_has_svm_support():
+ SVM_CPUID_FEATURE_SHIFT = 2
+ SVM_CPUID_FUNC = 0x8000000a
+
+ eax, ebx, ecx, edx = _cpuid(0x80000000)
+ if eax < SVM_CPUID_FUNC:
+ return 0
+
+ eax, ebx, ecx, edx = _cpuid(0x80000001)
+ if not (ecx & (1 << SVM_CPUID_FEATURE_SHIFT)):
+ return 0
+ return 1
+
+def _svm_enabled_by_bios():
+ SVM_VM_CR_SVM_DISABLE = 4
+ MSR_VM_CR = 0xc0010114
+
+ vm_cr = _prdmsr(0, MSR_VM_CR)
+ if vm_cr & (1 << SVM_VM_CR_SVM_DISABLE):
+ return 0
+ return 1
+
+def cpuVendorID():
+ for line in file('/proc/cpuinfo').readlines():
+ if ':' in line:
+ k, v = line.split(':', 1)
+ k = k.strip()
+ v = v.strip()
+ if k == 'vendor_id':
+ if v == 'GenuineIntel':
+ return v
+ elif v == 'AuthenticAMD':
+ return v
+ return ''
+
+def virtEnabledInCpuAndBios():
+ try:
+ vendor = cpuVendorID()
+ logging.debug('CPU vendor is %s', vendor)
+
+ if vendor == 'GenuineIntel':
+ bios_en = _vmx_enabled_by_bios()
+ has_cpu = _cpu_has_vmx_support();
+ elif vendor == 'AuthenticAMD':
+ bios_en = _svm_enabled_by_bios();
+ has_cpu = _cpu_has_svm_support();
+ else:
+ return False
+
+ logging.debug('virt support in cpu: %s, in bios: %s', has_cpu, bios_en)
+ return bios_en and has_cpu
+ except:
+ logging.error(traceback.format_exc())
+ return False
+
+def getRemoteFile(IP, port, fileName, timeout=None, certPath=None):
+ logging.debug("getRemoteFile start. IP = %s port = %s fileName = \"%s\""
+ % (IP, port, fileName))
+ data = None
+ response = None
+ conn = None
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.settimeout(timeout)
+ fOK = True
+
+ try:
+ nPort = 443
+ if port is not None:
+ nPort = int(port)
+
+ sock.connect((IP, nPort))
+ conn = httplib.HTTPSConnection(IP, nPort)
+ conn.sock = getSSLSocket(sock, certPath)
+ conn.request("GET", fileName)
+ response = conn.getresponse()
+ except:
+ logging.debug("%s failed in HTTPS. Retrying using HTTP." % fileName,
+ exc_info=True)
+ strPort = ":"
+ if port is None:
+ strPort += "80"
+ else:
+ strPort += port
+
+ try:
+ conn = httplib.HTTPConnection(IP + strPort)
+ conn.request("GET", fileName)
+ response = conn.getresponse()
+ except:
+ logging.error("Failed to fetch %s using http." % fileName,
+ exc_info=True)
+ fOK = False
+ else:
+ logging.debug("%s status: %s reason: %s" % \
+ (fileName, str(response.status), response.reason))
+
+ if response == None or response.status != 200:
+ status = ""
+ if response != None:
+ status = str(response.status)
+ if conn != None: conn.close()
+ fOK = False
+ logging.error("Failed to fetch %s status %s" % (fileName, status))
+
+ if fOK:
+ try:
+ try:
+ data = str(response.read())
+ except:
+ logging.error("Failed to read %s" % fileName, exc_info=True)
+ finally:
+ if conn != None: conn.close()
+
+ logging.debug('getRemoteFile end.')
+ return data
+
+def getRhevmCert(IP, port):
+
+ CACERT, VDSMCERT = certPaths('')
+ RHEVM_CERT_FILE = "/ca.crt"
+ rhevmCert = getRemoteFile(str(IP), str(port), RHEVM_CERT_FILE)
+ if rhevmCert:
+ dirName = os.path.dirname(CACERT)
+ if not os.path.exists(dirName):
+ os.makedirs(dirName)
+ crt = file(CACERT, "w+")
+ try:
+ crt.write(rhevmCert)
+ finally:
+ crt.close()
+ return True
+ else:
+ return False
+
+def generateFingerPrint(path):
+ fp = ''
+ cmd = [EX_OPENSSL, 'x509', '-fingerprint', '-in', path]
+ out, err, rc = _logExec(cmd)
+ if rc is 0:
+ try:
+ fp = filter(lambda l: 'Fingerprint' in l, out.split())[0].split('=')[1]
+ except Exception:
+ logging.error("Failed generating finger print for %s" % path,
+ exc_info=True)
+ else:
+ logging.error("Command %s failed with return value %d" % \
+ (' '.join(cmd), rc))
+
+ return fp
+
+def parseOptions():
+ parser = OptionParser()
+
+ parser.add_option("-s", "--server-address",
+ action="store", dest="serverIp", type="string", default=None,
+ help="IP address of RHEVM")
+ parser.add_option("-p", "--server-port",
+ action="store", dest="serverPort", default=None, type="string",
+ help="Port of RHEVM")
+
+ parser.add_option("-d", "--download-rhevm-cert", action="store_true",
+ default=False, dest="downloadRhevmCert",
+ help="Download certificate from RHEVM")
+ parser.add_option("-f", "--fingerprint", action="store",
+ dest="fingerPrint", default=None, type="string",
+ help="""
+ The fingerprint to compare to the fingerprint of the downloaded
+ certificate""")
+
+ options, args = parser.parse_args()
+
+ return (options, args)
+
+def main():
+ options, args = parseOptions()
+
+ if options.downloadRhevmCert:
+ if not options.serverIp or not options.serverPort or \
+ not options.fingerPrint:
+ print "Must supply RHEVM's IP, port and a fingerprint to " + \
+ "verify against"
+ return -1
+ if not getRhevmCert(options.serverIp, options.serverPort):
+ print 'Failed downloading the RHEVM certificate file'
+ return -1
+ CACERT, dontcare = certPaths('')
+ fp = generateFingerPrint(CACERT)
+ if options.fingerPrint != fp:
+ print 'Expected fingerprint %s is different from recieved fingerprint %s' % (options.fingerPrint, fp)
+ return -1
+
+ if isOvirt():
+ ovirtfunctions.ovirt_store_config(CACERT)
+ print 'RHEVM certificate downloaded and verified successfully.'
+ return 0
+ print 'Missing arguments'
+ return -1
+
+if __name__ == '__main__':
+ sys.exit(main())
12 years, 8 months
[NEW PATCH] [WIP] Initial support for autoconf (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/711
commit 7a1cbe56176b075df3044d39f2305cd334d3e0e6
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Thu Jul 14 08:08:05 2011 +0000
[WIP] Initial support for autoconf
Change-Id: Id3fa9b33559e6a7721faa417752da6b7ba1f4c10
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..623b625
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..7d1c323
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,365 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package. Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below. The lack of an optional feature in a given package is not
+necessarily a bug. More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
+ this time using the binaries in their final installed location.
+ This target does not install anything. Running this target as a
+ regular user, particularly if the prior `make install' required
+ root privileges, verifies that the installation completed
+ correctly.
+
+ 6. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 7. Often, you can also type `make uninstall' to remove the installed
+ files again. In practice, not all packages have tested that
+ uninstallation works correctly, even though it is required by the
+ GNU Coding Standards.
+
+ 8. Some packages, particularly those that use Automake, provide `make
+ distcheck', which can by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'. This
+is known as a "VPATH" build.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them. In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+ On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'. It is recommended to use the following options:
+
+ ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/LICENSE_GPL_v2 b/LICENSE_GPL_v2
deleted file mode 100644
index 623b625..0000000
--- a/LICENSE_GPL_v2
+++ /dev/null
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 908b56f..0000000
--- a/Makefile
+++ /dev/null
@@ -1,71 +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.
-#
-SUBDIRS=vdsm_cli re vds_bootstrap vdsm vdsm_reg vdsm_hooks
-DOCS=LICENSE_GPL_v2 README
-
-all: rpm
-
-_lastrelease:=$(shell git describe | cut -d- -f3 | tr -d '[a-zA-Z_]')
-_hash:=.g$(shell git rev-parse HEAD | cut -c 1-6)
-_branch:=$(shell git branch | grep '^*' | sed 's/^..\(.*\)/.\1/' |\
- sed 's/[^a-zA-Z0-9_.]//g')
-rpmrelease:=$(_lastrelease).1$(_hash)$(_branch)
-rpmversion=4.9
-RPMTOP=$(shell bash -c "pwd -P")/rpmtop
-SPEC=vdsm.spec
-
-TARBALL=vdsm-$(rpmversion)-$(rpmrelease).tar.gz
-SRPM=$(RPMTOP)/SRPMS/vdsm-$(rpmversion)-$(rpmrelease).src.rpm
-
-TESTS=pyflakes
-
-test: pyflakes exceptions
- echo $(rpmrelease) $(rpmversion)
-
-exceptions:
- python vdsm/storage/storage_exception.py | grep Collision && exit 1 || true
-
-pyflakes:
- @which pyflakes > /dev/null && git ls-files '*.py' | xargs pyflakes || (echo "Pyflakes errors or pyflakes not found"; exit 1)
-
-permissive_pyflakes:
- @which pyflakes > /dev/null 2>&1 || (echo "pyflakes not found" && false)
- if git ls-files '*.py' | xargs pyflakes | grep -v used ; then \
- echo "pyflakes errors" && false ; \
- fi
-
-pylint_all:
- cd vdsm; find storage -name "*.py" | xargs pylint -e 2> /dev/null
-
-pylint:
- cd vdsm; ls storage/*.py | xargs pylint -e 2> /dev/null
-
-install:
- for subdir in $(SUBDIRS); do make -C $$subdir $@; done
-
-.PHONY: tarball
-tarball: $(TARBALL)
-$(TARBALL): Makefile $(SUBDIRS) $(DOCS) $(TESTS)
- tar zcf $(TARBALL) `git ls-files | grep -v /ut/` \
- `git ls-files vdsm/ut/faqemu`
-
-.PHONY: srpm rpm
-srpm: $(SRPM)
-$(SRPM): $(TARBALL) vdsm.spec.in
- sed 's/^Version:.*/Version: $(rpmversion)/;s/^Release:.*/Release: $(rpmrelease)/' vdsm.spec.in > $(SPEC)
- mkdir -p $(RPMTOP)/{RPMS,SRPMS,SOURCES,BUILD}
- rpmbuild -bs \
- --define="_topdir $(RPMTOP)" \
- --define="_sourcedir ." $(SPEC)
-
-rpm: $(SRPM)
- rpmbuild --define="_topdir $(RPMTOP)" --rebuild $<
-
-clean:
- $(RM) *~ *.pyc vdsm*.tar.gz $(SPEC)
- $(RM) -r rpmtop
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..ebdde9f
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,65 @@
+# 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.
+#
+SUBDIRS=vdsm_cli re vds_bootstrap vdsm vdsm_reg vdsm_hooks
+DOCS=COPYING README
+
+all: rpm
+
+rpmversion=@PACKAGE_VERSION@
+rpmrelease=@PACKAGE_RELEASE@
+RPMTOP=$(PWD)/rpmtop
+SPEC=vdsm.spec
+
+TARBALL=vdsm-$(rpmversion)-$(rpmrelease).tar.gz
+SRPM=$(RPMTOP)/SRPMS/vdsm-$(rpmversion)-$(rpmrelease).src.rpm
+
+TESTS=pyflakes
+
+test: pyflakes exceptions
+ echo $(rpmrelease) $(rpmversion)
+
+exceptions:
+ python vdsm/storage/storage_exception.py | grep Collision && exit 1 || true
+
+pyflakes:
+ @which pyflakes > /dev/null && git ls-files '*.py' | xargs pyflakes || (echo "Pyflakes errors or pyflakes not found"; exit 1)
+
+permissive_pyflakes:
+ @which pyflakes > /dev/null 2>&1 || (echo "pyflakes not found" && false)
+ if git ls-files '*.py' | xargs pyflakes | grep -v used ; then \
+ echo "pyflakes errors" && false ; \
+ fi
+
+pylint_all:
+ cd vdsm; find storage -name "*.py" | xargs pylint -e 2> /dev/null
+
+pylint:
+ cd vdsm; ls storage/*.py | xargs pylint -e 2> /dev/null
+
+install:
+ for subdir in $(SUBDIRS); do make -C $$subdir $@; done
+
+.PHONY: tarball
+tarball: $(TARBALL)
+$(TARBALL): Makefile $(SUBDIRS) $(DOCS) $(TESTS)
+ tar zcf $(TARBALL) `git ls-files | grep -v /ut/` vdsm.spec configure
+
+.PHONY: srpm rpm
+srpm: $(SRPM)
+$(SRPM): $(TARBALL) vdsm.spec.in
+ mkdir -p $(RPMTOP)/{RPMS,SRPMS,SOURCES,BUILD}
+ rpmbuild -ts \
+ --define="_topdir $(RPMTOP)" \
+ --define="_sourcedir $(PWD)" $(TARBALL)
+
+rpm: $(SRPM)
+ rpmbuild --define="_topdir $(RPMTOP)" -ta $(TARBALL)
+
+clean:
+ $(RM) *~ *.pyc vdsm*.tar.gz $(SPEC)
+ $(RM) -r rpmtop
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..4e7cc05
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+autoreconf -if
diff --git a/build-aux/release.sh b/build-aux/release.sh
new file mode 100755
index 0000000..40d76bc
--- /dev/null
+++ b/build-aux/release.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+GIT_RELEASE=`git describe | awk -F- '{print $3 "." $5}' | tr -d '\n'`
+GIT_BRANCH=`git branch | awk '/^*/{print $2}' | sed 's/[^a-zA-Z0-9_.]//g'`
+echo -n $GIT_RELEASE.$GIT_BRANCH
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..8205333
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,6 @@
+AC_INIT([vdsm], [4.9], [vdsm-devel(a)lists.fedorahosted.org])
+AC_SUBST([PACKAGE_RELEASE], m4_esyscmd([./build-aux/release.sh]))
+AC_OUTPUT([
+ vdsm.spec
+ Makefile
+])
diff --git a/vdsm.spec.in b/vdsm.spec.in
index e3a99be..ad408c3 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1,16 +1,17 @@
%define vdsm_reg vdsm-reg
%define vdsm_name vdsm
%define vdsm_bootstrap vdsm-bootstrap
+%define vdsm_release @PACKAGE_RELEASE@
%include %{_rpmconfigdir}/macros.python
Summary: Virtual Desktop Server Manager
Name: vdsm
-Source: %{vdsm_name}-%{version}-%{release}.tar.gz
+Source: %{vdsm_name}-%{version}-%{vdsm_release}.tar.gz
# Url: no upstream project exists
# tarball built from internal git repo with
# make tarball rpmversion=<version> rpmrelease=<release>
-Version: 0.0
-Release: 1%{?dist}
+Version: @PACKAGE_VERSION@
+Release: %{vdsm_release}%{?dist}
License: GPLv2+
Group: Applications/System
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
@@ -45,6 +46,7 @@ administration tasks, statistics gathering, and log collection.
%setup -c -q
%build
+%configure
make -C vdsm CFLAGS="$RPM_OPT_FLAGS"
baserelease=`echo "%{release}" | sed 's/\([0-9]\+\(\.[0-9]\+\)\?\).*/\1/'`
sed -i 's/^software_version =.*/software_version = "%{version}"/;s/software_revision =.*/software_revision = "'"$baserelease"'"/' re/dsaversion.py
@@ -328,7 +330,7 @@ machines without running real guests.
%dir %{_localstatedir}/log/core
/etc/init.d/vdsmd
-%doc LICENSE_GPL_v2 README
+%doc COPYING README
%{py_sitedir}/sos/plugins/vdsm.py*
%{_mandir}/man8/vdsmd.8*
@@ -348,7 +350,7 @@ machines without running real guests.
%files hook-vhostmd
%defattr(-,root,root,-)
-%doc LICENSE_GPL_v2
+%doc COPYING
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_vhostmd
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_migrate_destination/50_vhostmd
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_dehibernate/50_vhostmd
@@ -361,7 +363,7 @@ machines without running real guests.
%files cli
%defattr(-,root,root,-)
-%doc LICENSE_GPL_v2
+%doc COPYING
%{_datadir}/%{vdsm_name}/vdsClient.py*
%{_sysconfdir}/bash_completion.d/vdsClient
%{_datadir}/%{vdsm_name}/vdscli.py*
@@ -371,7 +373,7 @@ machines without running real guests.
%files bootstrap
%defattr(-,root,root,-)
-%doc LICENSE_GPL_v2
+%doc COPYING
%{_datadir}/%{vdsm_bootstrap}/vds_bootstrap.py*
%{_datadir}/%{vdsm_bootstrap}/deployUtil.py*
%{_datadir}/%{vdsm_bootstrap}/vds_bootstrap_complete.py*
@@ -379,7 +381,7 @@ machines without running real guests.
%files reg
%defattr(-,root,root,-)
-%doc LICENSE_GPL_v2
+%doc COPYING
%dir %{_sysconfdir}/%{vdsm_reg}
%dir %{_datadir}/%{vdsm_reg}
%config(noreplace) %{_sysconfdir}/%{vdsm_reg}/vdsm-reg.conf
@@ -406,7 +408,7 @@ machines without running real guests.
%files hook-faqemu
%defattr(-,root,root,-)
-%doc LICENSE_GPL_v2
+%doc COPYING
%{_bindir}/qemu
%{_bindir}/qemu-system-x86_64
%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/10_faqemu
12 years, 8 months
[NEW PATCH] [WIP] Add a recursive install target in Makefile (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/705
commit 3b0f6935d4921632f92049568f178722e99761e9
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Wed Jul 13 15:52:56 2011 +0000
[WIP] Add a recursive install target in Makefile
Change-Id: Id579f1ebea23e4f89e9b3b7c0e0695164c505019
diff --git a/Makefile b/Makefile
index c43c755..908b56f 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@
# (at your option) any later version. See the files README and
# LICENSE_GPL_v2 which accompany this distribution.
#
-DIRS=vdsm_cli re vds_bootstrap vdsm vdsm_reg
+SUBDIRS=vdsm_cli re vds_bootstrap vdsm vdsm_reg vdsm_hooks
DOCS=LICENSE_GPL_v2 README
all: rpm
@@ -45,9 +45,12 @@ pylint_all:
pylint:
cd vdsm; ls storage/*.py | xargs pylint -e 2> /dev/null
+install:
+ for subdir in $(SUBDIRS); do make -C $$subdir $@; done
+
.PHONY: tarball
tarball: $(TARBALL)
-$(TARBALL): Makefile $(DIRS) $(DOCS) $(TESTS)
+$(TARBALL): Makefile $(SUBDIRS) $(DOCS) $(TESTS)
tar zcf $(TARBALL) `git ls-files | grep -v /ut/` \
`git ls-files vdsm/ut/faqemu`
diff --git a/vds_bootstrap/Makefile b/vds_bootstrap/Makefile
index 6ba23bc..2c023ae 100644
--- a/vds_bootstrap/Makefile
+++ b/vds_bootstrap/Makefile
@@ -7,15 +7,15 @@
#
INSTALL = install
-TARGET = /usr/share/vdsm-bootstrap
+VDSMBOOTDIR = /usr/share/vdsm-bootstrap
PYSRCS = vds_bootstrap.py vds_bootstrap_complete.py
all: $(PYSRCS)
install:
- $(INSTALL) -Dd 755 $(DESTDIR)$(TARGET)
- $(INSTALL) -Dm 755 $(PYSRCS) $(DESTDIR)$(TARGET)
- $(INSTALL) -Dm 644 deployUtil.py $(DESTDIR)$(TARGET)
+ $(INSTALL) -Dd 755 $(DESTDIR)$(VDSMBOOTDIR)
+ $(INSTALL) -Dm 755 $(PYSRCS) $(DESTDIR)$(VDSMBOOTDIR)
+ $(INSTALL) -Dm 644 deployUtil.py $(DESTDIR)$(VDSMBOOTDIR)
clean:
$(RM) *.pyc *.pyo *~
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 9f526b9..e3a99be 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -53,55 +53,25 @@ sed -i 's/^software_version =.*/software_version = "%{version}"/;s/software_revi
%install
rm -rf "%{buildroot}"
mkdir -p "%{buildroot}"
-make -C vdsm DESTDIR="%{buildroot}" \
- VDSMDIR=%{_datadir}/%{vdsm_name} \
- VDSMLOGDIR=%{_localstatedir}/log/%{vdsm_name} \
- TRUSTSTORE=%{_sysconfdir}/pki/%{vdsm_name} \
- BINDIR=%{_bindir} \
- LIBEXECDIR=%{_libexecdir}/%{vdsm_name} \
- CONFDIR=%{_sysconfdir}/%{vdsm_name} \
- VDSMRUNDIR=%{_localstatedir}/run/%{vdsm_name} \
- VDSMLIBDIR=%{_localstatedir}/lib/%{vdsm_name} \
- SOSPLUGINDIR=%{py_sitedir}/sos/plugins \
- install
+make DESTDIR="%{buildroot}" \
+ ETC=%{_sysconfdir} \
+ VDSMDIR=%{_datadir}/%{vdsm_name} \
+ VDSMLOGDIR=%{_localstatedir}/log/%{vdsm_name} \
+ TRUSTSTORE=%{_sysconfdir}/pki/%{vdsm_name} \
+ BINDIR=%{_bindir} \
+ LIBEXECDIR=%{_libexecdir}/%{vdsm_name} \
+ CONFDIR=%{_sysconfdir}/%{vdsm_name} \
+ REGCONFDIR=%{_sysconfdir}/%{vdsm_name}-reg \
+ VDSMRUNDIR=%{_localstatedir}/run/%{vdsm_name} \
+ VDSMLIBDIR=%{_localstatedir}/lib/%{vdsm_name} \
+ SOSPLUGINDIR=%{py_sitedir}/sos/plugins \
+ OVIRT_CONFIG_SETUP=%{py_sitedir}/ovirt_config_setup \
+ install
# this is not commonplace, but we want /var/log/core to be a world-writable
# dropbox for core dumps.
install -dDm 1777 "%{buildroot}"%{_localstatedir}/log/core
-# hook vhostmd
-make -C vdsm_hooks DESTDIR="%{buildroot}" \
- LIBEXECDIR=%{_libexecdir}/%{vdsm_name} \
- install
-
-#vdsm-cli
-make -C vdsm_cli DESTDIR="%{buildroot}" \
- CONFDIR=%{_sysconfdir}/%{vdsm_name} \
- BINDIR=%{_bindir} \
- COMPDIR=%{_sysconfdir}/bash_completion.d \
- VDSMDIR=%{_datadir}/%{vdsm_name} \
- TRUSTSTORE=%{_sysconfdir}/pki/%{vdsm_name} \
- TARGET=%{_datadir}/%{vdsm_name} install
-
-#vdsm-reg
-make -C vdsm_reg \
- DESTDIR="%{buildroot}" \
- ETC=%{_sysconfdir} \
- CONFDIR=%{_sysconfdir}/%{vdsm_reg} \
- LOGDIR=%{_localstatedir}/log/%{vdsm_reg} \
- VDSMREGDIR=%{_datadir}/%{vdsm_reg} \
- TRUSTSTORE=%{_sysconfdir}/pki/%{vdsm_name} \
- VDSMRUNDIR=%{_localstatedir}/run/%{vdsm_name} \
- OVIRT_CONFIG_SETUP=%{py_sitedir}/ovirt_config_setup \
- install
-
-#vdsm-bootstrap
-make -C vds_bootstrap \
- DESTDIR="%{buildroot}" \
- TARGET=%{_datadir}/%{vdsm_bootstrap} install
-
-
-
%clean
%{__rm} -rf %{buildroot}
diff --git a/vdsm_cli/Makefile b/vdsm_cli/Makefile
index f135d27..287284b 100644
--- a/vdsm_cli/Makefile
+++ b/vdsm_cli/Makefile
@@ -8,7 +8,7 @@
INSTALL = install
-TARGET = /usr/share/vdsm
+VDSMDIR = /usr/share/vdsm
PYSRCS = vdsClient.py vdscli.py dumpStorageTable.py
CONFDIR = /etc/vdsm
BINDIR = bin
@@ -24,8 +24,8 @@ fixpaths:
sed -i "s:@TRUSTSTORE@:$(TRUSTSTORE):" vdscli.py
install: fixpaths
- $(INSTALL) -Dd $(DESTDIR)/$(TARGET)
- $(INSTALL) -Dm 644 $(PYSRCS) $(DESTDIR)/$(TARGET)
+ $(INSTALL) -Dd $(DESTDIR)/$(VDSMDIR)
+ $(INSTALL) -Dm 644 $(PYSRCS) $(DESTDIR)/$(VDSMDIR)
$(INSTALL) -Dm 755 vdsClient $(DESTDIR)/$(BINDIR)/vdsClient
$(INSTALL) -Dm 644 vdsClient.completion $(DESTDIR)$(COMPDIR)/vdsClient
$(INSTALL) -Dm 644 vdsClient.1 $(DESTDIR)$(MANDIR)/man1/vdsClient.1
diff --git a/vdsm_hooks/Makefile b/vdsm_hooks/Makefile
index 64dd604..9145f4a 100644
--- a/vdsm_hooks/Makefile
+++ b/vdsm_hooks/Makefile
@@ -26,5 +26,5 @@ install:
$(INSTALL) -Dm 755 persist-vdsm-hooks $(DESTDIR)$(LIBEXECDIR)/persist-vdsm-hooks
$(INSTALL) -Dm 755 unpersist-vdsm-hook $(DESTDIR)$(LIBEXECDIR)/unpersist-vdsm-hook
(for hook in $(SUBDIRS); do \
- make -C $$hook $@ \
+ make -C $$hook $@; \
done)
diff --git a/vdsm_reg/Makefile b/vdsm_reg/Makefile
index 5e1cdc0..fd92c48 100644
--- a/vdsm_reg/Makefile
+++ b/vdsm_reg/Makefile
@@ -2,8 +2,8 @@ INSTALL=install
LN_S=ln -s
VDSMREGDIR=/usr/share/vdsm-reg
ETC=/etc
-CONFDIR=$(ETC)/vdsm-reg
-LOGDIR=/var/log/vdsm-reg
+REGCONFDIR=$(ETC)/vdsm-reg
+VDSMREGLOGDIR=/var/log/vdsm-reg
VDSMRUNDIR=/var/run/vdsm
MANDIR=/usr/share/man
@@ -17,13 +17,13 @@ fixpaths:
sed -i "s:@VDSMRUNDIR@:$(VDSMRUNDIR):" vdsm-reg.conf
install: fixpaths
- $(INSTALL) -Dd $(DESTDIR)$(CONFDIR)
+ $(INSTALL) -Dd $(DESTDIR)$(REGCONFDIR)
$(INSTALL) -Dd $(DESTDIR)$(VDSMREGDIR)
- $(INSTALL) -Dd $(DESTDIR)$(LOGDIR)
+ $(INSTALL) -Dd $(DESTDIR)$(VDSMREGLOGDIR)
$(INSTALL) -Dd $(DESTDIR)$(OVIRT_CONFIG_SETUP)
$(INSTALL) -Dm 755 vdsm-reg $(DESTDIR)$(ETC)/init.d/vdsm-reg
- $(INSTALL) -Dm 644 logger.conf $(DESTDIR)$(CONFDIR)/logger.conf
- $(INSTALL) -Dm 644 vdsm-reg.conf $(DESTDIR)$(CONFDIR)/vdsm-reg.conf
+ $(INSTALL) -Dm 644 logger.conf $(DESTDIR)$(REGCONFDIR)/logger.conf
+ $(INSTALL) -Dm 644 vdsm-reg.conf $(DESTDIR)$(REGCONFDIR)/vdsm-reg.conf
$(INSTALL) -Dm 644 $(FILES) $(DESTDIR)$(VDSMREGDIR)
$(INSTALL) -Dm 755 save-config $(DESTDIR)$(VDSMREGDIR)
$(INSTALL) -Dm 755 config-rhev-manager $(DESTDIR)$(VDSMREGDIR)
@@ -38,4 +38,4 @@ install: fixpaths
$(INSTALL) -Dm 644 vdsm-reg-logrotate.conf $(DESTDIR)$(ETC)/logrotate.d/vdsm-reg
$(INSTALL) -Dm 755 vdsm-reg-logrotate $(DESTDIR)$(ETC)/cron.hourly
$(INSTALL) -Dm 644 vdsm-reg.8 $(DESTDIR)$(MANDIR)/man8/vdsm-reg.8
- $(INSTALL) -Dm 644 rhevm.py $(DESTDIR)$(OVIRT_CONFIG_SETUP)
+ $(INSTALL) -Dm 644 rhevm.py $(DESTDIR)$(OVIRT_CONFIG_SETUP)/rhevm.py
12 years, 8 months
[NEW PATCH] [WIP] Move vdsm/hooks to vdsm_hooks (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/704
commit 75f6afe98ffbd8b8e83f61e4d5b233e3fbd782eb
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Wed Jul 13 15:44:24 2011 +0000
[WIP] Move vdsm/hooks to vdsm_hooks
Change-Id: I2247df4e87edaac6979da30b17bbdeae299944b9
diff --git a/vdsm.spec.in b/vdsm.spec.in
index e57ead5..9f526b9 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -70,12 +70,7 @@ make -C vdsm DESTDIR="%{buildroot}" \
install -dDm 1777 "%{buildroot}"%{_localstatedir}/log/core
# hook vhostmd
-make -C vdsm/hooks/vhostmd DESTDIR="%{buildroot}" \
- LIBEXECDIR=%{_libexecdir}/%{vdsm_name} \
- install
-
-# hook faqemu
-make -C vdsm/hooks/faqemu DESTDIR="%{buildroot}" \
+make -C vdsm_hooks DESTDIR="%{buildroot}" \
LIBEXECDIR=%{_libexecdir}/%{vdsm_name} \
install
diff --git a/vdsm/Makefile b/vdsm/Makefile
index ef4137f..a0811af 100644
--- a/vdsm/Makefile
+++ b/vdsm/Makefile
@@ -10,8 +10,7 @@ INSTALL=install
FILES=define.py utils.py constants.py \
vm.py libvirtvm.py libvirtev.py \
- caps.py clientIF.py \
- hooks.py hooks/hooking.py \
+ caps.py clientIF.py hooks.py hooking.py \
guestIF.py dsaversion.py \
configNetwork.py SecureXMLRPCServer.py ksm.py \
netinfo.py neterrors.py \
@@ -86,15 +85,6 @@ fixpaths:
img_verifier vdsmd \
vdsm-store-net-config vdsm-restore-net-config
-HOOKS=before_vm_start after_vm_start before_vm_cont after_vm_cont \
- before_vm_pause after_vm_pause \
- before_vm_hibernate after_vm_hibernate \
- before_vm_dehibernate after_vm_dehibernate \
- before_vm_migrate_source after_vm_migrate_source \
- before_vm_migrate_destination after_vm_migrate_destination \
- after_vm_destroy \
- before_vdsm_start after_vdsm_stop
-
install: all sudoers.vdsm vdsm.conf.sample
$(INSTALL) -Dd $(DESTDIR)$(VDSMDIR)/storage/protect
$(INSTALL) -Dd $(DESTDIR)$(TRUSTSTORE)/{certs,keys}
@@ -104,12 +94,10 @@ install: all sudoers.vdsm vdsm.conf.sample
$(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
- (for hook in $(HOOKS); do \
- $(INSTALL) -Dd $(DESTDIR)$(LIBEXECDIR)/hooks/$$hook; \
- done)
$(INSTALL) -Dm 644 $(FILES) $(DESTDIR)$(VDSMDIR)
$(INSTALL) -Dm 755 $(SCRIPTFILES) $(DESTDIR)$(VDSMDIR)
(cd storage; \
@@ -125,8 +113,6 @@ install: all sudoers.vdsm vdsm.conf.sample
$(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
- $(INSTALL) -Dm 755 hooks/persist-vdsm-hooks $(DESTDIR)$(LIBEXECDIR)/persist-vdsm-hooks
- $(INSTALL) -Dm 755 hooks/unpersist-vdsm-hook $(DESTDIR)$(LIBEXECDIR)/unpersist-vdsm-hook
clean:
$(RM) *~ *.pyc storage/protect/safelease vdsm.conf.sample
diff --git a/vdsm/hooking.py b/vdsm/hooking.py
new file mode 100644
index 0000000..e0ca856
--- /dev/null
+++ b/vdsm/hooking.py
@@ -0,0 +1,39 @@
+"""
+hooking - various stuff useful when writing vdsm hooks
+
+A vm hook expects domain xml in a file named by an environment variable called
+_hook_domxml. The hook may change the xml, but the "china store rule" applies -
+if you break something, you own it.
+
+before_migration_destination hook receives the xml of the domain from the
+source host. The xml of the domain at the destination will differ in various
+details.
+
+Return codes:
+0 - the hook ended successfully.
+1 - the hook failed, other hooks should be processed.
+2 - the hook failed, no further hooks should be processed.
+>2 - reserverd
+"""
+
+import os
+from xml.dom import minidom
+
+def tobool(s):
+ """Convert the argument into a boolean"""
+ try:
+ if s == None:
+ return False
+ if type(s) == bool:
+ return s
+ if s.lower() == 'true':
+ return True
+ return bool(int(s))
+ except:
+ return False
+
+def read_domxml():
+ return minidom.parseString(file(os.environ['_hook_domxml']).read())
+
+def write_domxml(domxml):
+ file(os.environ['_hook_domxml'], 'w').write(domxml.toxml(encoding='utf-8'))
diff --git a/vdsm/hooks/faqemu/Makefile b/vdsm/hooks/faqemu/Makefile
deleted file mode 100644
index 0ec2515..0000000
--- a/vdsm/hooks/faqemu/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-INSTALL=install
-LN_S=ln -s
-BINDIR=/usr/bin
-LIBEXECDIR=/usr/libexec/vdsm
-HOOKSDIR=$(LIBEXECDIR)/hooks
-
-install:
- $(INSTALL) -Dm 755 qemu $(DESTDIR)$(BINDIR)/qemu
- $(LN_S) qemu $(DESTDIR)$(BINDIR)/qemu-system-x86_64
- $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/10_faqemu
-
-clean:
- $(RM) *~ *.pyc
diff --git a/vdsm/hooks/faqemu/before_vm_start.py b/vdsm/hooks/faqemu/before_vm_start.py
deleted file mode 100755
index bda1a71..0000000
--- a/vdsm/hooks/faqemu/before_vm_start.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/python
-
-import hooking
-from config import config
-
-if config.getboolean('vars', 'fake_kvm_support'):
- domxml = hooking.read_domxml()
-
- graphics = domxml.getElementsByTagName("graphics")[0]
- graphics.removeAttribute("passwdValidTo")
-
- for memtag in ("memory", "currentMemory"):
- memvalue = domxml.getElementsByTagName(memtag)[0]
- while memvalue.firstChild:
- memvalue.removeChild(memvalue.firstChild)
- memvalue.appendChild(domxml.createTextNode("20480"))
-
- for cputag in domxml.getElementsByTagName("cpu"):
- cputag.parentNode.removeChild(cputag)
-
- hooking.write_domxml(domxml)
diff --git a/vdsm/hooks/faqemu/qemu b/vdsm/hooks/faqemu/qemu
deleted file mode 100644
index b05ced0..0000000
--- a/vdsm/hooks/faqemu/qemu
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-
-qemu_bin = "/usr/libexec/qemu-kvm"
-qemu_argv = [ qemu_bin ]
-
-if not "-no-kvm" in sys.argv:
- qemu_argv += [ "-no-kvm" ]
-
-qemu_argv += filter(lambda x: x != "-enable-kvm", sys.argv[1:])
-os.execv(qemu_bin, qemu_argv)
diff --git a/vdsm/hooks/hooking.py b/vdsm/hooks/hooking.py
deleted file mode 100644
index e0ca856..0000000
--- a/vdsm/hooks/hooking.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""
-hooking - various stuff useful when writing vdsm hooks
-
-A vm hook expects domain xml in a file named by an environment variable called
-_hook_domxml. The hook may change the xml, but the "china store rule" applies -
-if you break something, you own it.
-
-before_migration_destination hook receives the xml of the domain from the
-source host. The xml of the domain at the destination will differ in various
-details.
-
-Return codes:
-0 - the hook ended successfully.
-1 - the hook failed, other hooks should be processed.
-2 - the hook failed, no further hooks should be processed.
->2 - reserverd
-"""
-
-import os
-from xml.dom import minidom
-
-def tobool(s):
- """Convert the argument into a boolean"""
- try:
- if s == None:
- return False
- if type(s) == bool:
- return s
- if s.lower() == 'true':
- return True
- return bool(int(s))
- except:
- return False
-
-def read_domxml():
- return minidom.parseString(file(os.environ['_hook_domxml']).read())
-
-def write_domxml(domxml):
- file(os.environ['_hook_domxml'], 'w').write(domxml.toxml(encoding='utf-8'))
diff --git a/vdsm/hooks/persist-vdsm-hooks b/vdsm/hooks/persist-vdsm-hooks
deleted file mode 100755
index 2ac677a..0000000
--- a/vdsm/hooks/persist-vdsm-hooks
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Description: Persist all VDSM hooks
-#
-
-HOOKS_DIR=/usr/libexec/vdsm/hooks
-
-if [[ -f /etc/rhev-hypervisor-release ]]
-then
- . /usr/libexec/ovirt-functions
- for hook in "$HOOKS_DIR"/*/*
- do
- if [[ -f "$hook" ]]
- then
- ovirt_store_config "$hook"
- fi
- done
-else
- echo "Host is not RHEV-Hypervisor"
- exit 1
-fi
diff --git a/vdsm/hooks/unpersist-vdsm-hook b/vdsm/hooks/unpersist-vdsm-hook
deleted file mode 100755
index af5af27..0000000
--- a/vdsm/hooks/unpersist-vdsm-hook
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Description: Unpersist VDSM Hook
-# Input: VDSM Hook file full path
-#
-
-HOOKS_DIR=/usr/libexec/vdsm/hooks
-HOOK_TO_UNPERSIST="$1"
-
-if [[ -z "$HOOK_TO_UNPERSIST" ]]; then
- echo "usage: $0 hook_file"
- exit 1
-fi
-
-if [[ -f /etc/rhev-hypervisor-release ]]
-then
- . /usr/libexec/ovirt-functions
- if [[ "$HOOK_TO_UNPERSIST" =~ ^"$HOOKS_DIR" ]]
- then
- # try to unpersist files only
- if [[ -f "$HOOK_TO_UNPERSIST" ]]
- then
- ovirt_safe_delete_config "$HOOK_TO_UNPERSIST"
- fi
- fi
-else
- echo "Host is not RHEV-Hypervisor"
- exit 1
-fi
diff --git a/vdsm/hooks/vhostmd/Makefile b/vdsm/hooks/vhostmd/Makefile
deleted file mode 100644
index 6f13033..0000000
--- a/vdsm/hooks/vhostmd/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-INSTALL=install
-LN_S=ln -s
-LIBEXECDIR=/usr/libexec/vdsm
-HOOKSDIR=$(LIBEXECDIR)/hooks
-
-all:
-
-install:
- $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/50_vhostmd
- $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_migrate_destination/50_vhostmd
- $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_dehibernate/50_vhostmd
- $(INSTALL) -Dm 755 after_vm_destroy.py $(DESTDIR)$(HOOKSDIR)/after_vm_destroy/50_vhostmd
- $(INSTALL) -Dm 440 sudoers.vdsm_hook_vhostmd $(DESTDIR)/etc/sudoers.d/50_vdsm_hook_vhostmd
-
-clean:
- $(RM) *~ *.pyc
diff --git a/vdsm/hooks/vhostmd/after_vm_destroy.py b/vdsm/hooks/vhostmd/after_vm_destroy.py
deleted file mode 100644
index ae06ead..0000000
--- a/vdsm/hooks/vhostmd/after_vm_destroy.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/python
-
-import os
-import subprocess
-import hooking
-import vdscli
-
-s = vdscli.connect()
-
-res = s.list(True)
-if res['status']['code'] == 0:
- if not [ v for v in res['vmList']
- if v.get('vmId') != os.environ.get('vmId') and
- hooking.tobool(v.get('custom', {}).get('sap_agent', False)) ]:
- subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd',
- 'stop'])
diff --git a/vdsm/hooks/vhostmd/before_vm_start.py b/vdsm/hooks/vhostmd/before_vm_start.py
deleted file mode 100644
index a76d19f..0000000
--- a/vdsm/hooks/vhostmd/before_vm_start.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/python
-
-import os
-import subprocess
-import hooking
-
-
-if hooking.tobool(os.environ.get('sap_agent', False)):
- domxml = hooking.read_domxml()
-
- subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd',
- 'start'])
- devs = domxml.getElementsByTagName('devices')[0]
- diskelem = domxml.createElement('disk')
- diskelem.setAttribute('device', 'disk')
-
- source = domxml.createElement('source')
- diskelem.setAttribute('type', 'file')
- source.setAttribute('file', '/dev/shm/vhostmd0')
- diskelem.appendChild(source)
-
- target = domxml.createElement('target')
- target.setAttribute('dev', 'vdzz') # FIXME do not use a static location
- target.setAttribute('bus', 'virtio')
- diskelem.appendChild(target)
-
- diskelem.appendChild(domxml.createElement('readonly'))
-
- devs.appendChild(diskelem)
-
- hooking.write_domxml(domxml)
diff --git a/vdsm/hooks/vhostmd/sudoers.vdsm_hook_vhostmd b/vdsm/hooks/vhostmd/sudoers.vdsm_hook_vhostmd
deleted file mode 100644
index ea34057..0000000
--- a/vdsm/hooks/vhostmd/sudoers.vdsm_hook_vhostmd
+++ /dev/null
@@ -1 +0,0 @@
-vdsm ALL=(ALL) NOPASSWD: /sbin/service vhostmd *
diff --git a/vdsm_hooks/Makefile b/vdsm_hooks/Makefile
new file mode 100644
index 0000000..64dd604
--- /dev/null
+++ b/vdsm_hooks/Makefile
@@ -0,0 +1,30 @@
+# 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
+
+SUBDIRS=faqemu vhostmd
+
+HOOKS=before_vm_start after_vm_start before_vm_cont after_vm_cont \
+ before_vm_pause after_vm_pause \
+ before_vm_hibernate after_vm_hibernate \
+ before_vm_dehibernate after_vm_dehibernate \
+ before_vm_migrate_source after_vm_migrate_source \
+ before_vm_migrate_destination after_vm_migrate_destination \
+ after_vm_destroy \
+ before_vdsm_start after_vdsm_stop
+
+install:
+ (for hook in $(HOOKS); do \
+ $(INSTALL) -Dd $(DESTDIR)$(LIBEXECDIR)/hooks/$$hook; \
+ done)
+ $(INSTALL) -Dm 755 persist-vdsm-hooks $(DESTDIR)$(LIBEXECDIR)/persist-vdsm-hooks
+ $(INSTALL) -Dm 755 unpersist-vdsm-hook $(DESTDIR)$(LIBEXECDIR)/unpersist-vdsm-hook
+ (for hook in $(SUBDIRS); do \
+ make -C $$hook $@ \
+ done)
diff --git a/vdsm_hooks/faqemu/Makefile b/vdsm_hooks/faqemu/Makefile
new file mode 100644
index 0000000..0ec2515
--- /dev/null
+++ b/vdsm_hooks/faqemu/Makefile
@@ -0,0 +1,13 @@
+INSTALL=install
+LN_S=ln -s
+BINDIR=/usr/bin
+LIBEXECDIR=/usr/libexec/vdsm
+HOOKSDIR=$(LIBEXECDIR)/hooks
+
+install:
+ $(INSTALL) -Dm 755 qemu $(DESTDIR)$(BINDIR)/qemu
+ $(LN_S) qemu $(DESTDIR)$(BINDIR)/qemu-system-x86_64
+ $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/10_faqemu
+
+clean:
+ $(RM) *~ *.pyc
diff --git a/vdsm_hooks/faqemu/before_vm_start.py b/vdsm_hooks/faqemu/before_vm_start.py
new file mode 100755
index 0000000..bda1a71
--- /dev/null
+++ b/vdsm_hooks/faqemu/before_vm_start.py
@@ -0,0 +1,21 @@
+#!/usr/bin/python
+
+import hooking
+from config import config
+
+if config.getboolean('vars', 'fake_kvm_support'):
+ domxml = hooking.read_domxml()
+
+ graphics = domxml.getElementsByTagName("graphics")[0]
+ graphics.removeAttribute("passwdValidTo")
+
+ for memtag in ("memory", "currentMemory"):
+ memvalue = domxml.getElementsByTagName(memtag)[0]
+ while memvalue.firstChild:
+ memvalue.removeChild(memvalue.firstChild)
+ memvalue.appendChild(domxml.createTextNode("20480"))
+
+ for cputag in domxml.getElementsByTagName("cpu"):
+ cputag.parentNode.removeChild(cputag)
+
+ hooking.write_domxml(domxml)
diff --git a/vdsm_hooks/faqemu/qemu b/vdsm_hooks/faqemu/qemu
new file mode 100644
index 0000000..b05ced0
--- /dev/null
+++ b/vdsm_hooks/faqemu/qemu
@@ -0,0 +1,13 @@
+#!/usr/bin/python
+
+import os
+import sys
+
+qemu_bin = "/usr/libexec/qemu-kvm"
+qemu_argv = [ qemu_bin ]
+
+if not "-no-kvm" in sys.argv:
+ qemu_argv += [ "-no-kvm" ]
+
+qemu_argv += filter(lambda x: x != "-enable-kvm", sys.argv[1:])
+os.execv(qemu_bin, qemu_argv)
diff --git a/vdsm_hooks/persist-vdsm-hooks b/vdsm_hooks/persist-vdsm-hooks
new file mode 100755
index 0000000..2ac677a
--- /dev/null
+++ b/vdsm_hooks/persist-vdsm-hooks
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# Description: Persist all VDSM hooks
+#
+
+HOOKS_DIR=/usr/libexec/vdsm/hooks
+
+if [[ -f /etc/rhev-hypervisor-release ]]
+then
+ . /usr/libexec/ovirt-functions
+ for hook in "$HOOKS_DIR"/*/*
+ do
+ if [[ -f "$hook" ]]
+ then
+ ovirt_store_config "$hook"
+ fi
+ done
+else
+ echo "Host is not RHEV-Hypervisor"
+ exit 1
+fi
diff --git a/vdsm_hooks/unpersist-vdsm-hook b/vdsm_hooks/unpersist-vdsm-hook
new file mode 100755
index 0000000..af5af27
--- /dev/null
+++ b/vdsm_hooks/unpersist-vdsm-hook
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# Copyright 2009-2010 Red Hat, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# Description: Unpersist VDSM Hook
+# Input: VDSM Hook file full path
+#
+
+HOOKS_DIR=/usr/libexec/vdsm/hooks
+HOOK_TO_UNPERSIST="$1"
+
+if [[ -z "$HOOK_TO_UNPERSIST" ]]; then
+ echo "usage: $0 hook_file"
+ exit 1
+fi
+
+if [[ -f /etc/rhev-hypervisor-release ]]
+then
+ . /usr/libexec/ovirt-functions
+ if [[ "$HOOK_TO_UNPERSIST" =~ ^"$HOOKS_DIR" ]]
+ then
+ # try to unpersist files only
+ if [[ -f "$HOOK_TO_UNPERSIST" ]]
+ then
+ ovirt_safe_delete_config "$HOOK_TO_UNPERSIST"
+ fi
+ fi
+else
+ echo "Host is not RHEV-Hypervisor"
+ exit 1
+fi
diff --git a/vdsm_hooks/vhostmd/Makefile b/vdsm_hooks/vhostmd/Makefile
new file mode 100644
index 0000000..6f13033
--- /dev/null
+++ b/vdsm_hooks/vhostmd/Makefile
@@ -0,0 +1,16 @@
+INSTALL=install
+LN_S=ln -s
+LIBEXECDIR=/usr/libexec/vdsm
+HOOKSDIR=$(LIBEXECDIR)/hooks
+
+all:
+
+install:
+ $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/50_vhostmd
+ $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_migrate_destination/50_vhostmd
+ $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_dehibernate/50_vhostmd
+ $(INSTALL) -Dm 755 after_vm_destroy.py $(DESTDIR)$(HOOKSDIR)/after_vm_destroy/50_vhostmd
+ $(INSTALL) -Dm 440 sudoers.vdsm_hook_vhostmd $(DESTDIR)/etc/sudoers.d/50_vdsm_hook_vhostmd
+
+clean:
+ $(RM) *~ *.pyc
diff --git a/vdsm_hooks/vhostmd/after_vm_destroy.py b/vdsm_hooks/vhostmd/after_vm_destroy.py
new file mode 100644
index 0000000..ae06ead
--- /dev/null
+++ b/vdsm_hooks/vhostmd/after_vm_destroy.py
@@ -0,0 +1,16 @@
+#!/usr/bin/python
+
+import os
+import subprocess
+import hooking
+import vdscli
+
+s = vdscli.connect()
+
+res = s.list(True)
+if res['status']['code'] == 0:
+ if not [ v for v in res['vmList']
+ if v.get('vmId') != os.environ.get('vmId') and
+ hooking.tobool(v.get('custom', {}).get('sap_agent', False)) ]:
+ subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd',
+ 'stop'])
diff --git a/vdsm_hooks/vhostmd/before_vm_start.py b/vdsm_hooks/vhostmd/before_vm_start.py
new file mode 100644
index 0000000..a76d19f
--- /dev/null
+++ b/vdsm_hooks/vhostmd/before_vm_start.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import os
+import subprocess
+import hooking
+
+
+if hooking.tobool(os.environ.get('sap_agent', False)):
+ domxml = hooking.read_domxml()
+
+ subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd',
+ 'start'])
+ devs = domxml.getElementsByTagName('devices')[0]
+ diskelem = domxml.createElement('disk')
+ diskelem.setAttribute('device', 'disk')
+
+ source = domxml.createElement('source')
+ diskelem.setAttribute('type', 'file')
+ source.setAttribute('file', '/dev/shm/vhostmd0')
+ diskelem.appendChild(source)
+
+ target = domxml.createElement('target')
+ target.setAttribute('dev', 'vdzz') # FIXME do not use a static location
+ target.setAttribute('bus', 'virtio')
+ diskelem.appendChild(target)
+
+ diskelem.appendChild(domxml.createElement('readonly'))
+
+ devs.appendChild(diskelem)
+
+ hooking.write_domxml(domxml)
diff --git a/vdsm_hooks/vhostmd/sudoers.vdsm_hook_vhostmd b/vdsm_hooks/vhostmd/sudoers.vdsm_hook_vhostmd
new file mode 100644
index 0000000..ea34057
--- /dev/null
+++ b/vdsm_hooks/vhostmd/sudoers.vdsm_hook_vhostmd
@@ -0,0 +1 @@
+vdsm ALL=(ALL) NOPASSWD: /sbin/service vhostmd *
12 years, 8 months
[NEW PATCH] [WIP] Replace 'cp' and 'mkdir' with $(INSTALL) (via gerrit-bot)
by Federico Simoncelli
New patch submitted by Federico Simoncelli (fsimonce(a)redhat.com)
You can review this change at: http://gerrit.usersys.redhat.com/703
commit fb6abc91130e3915453f265f83ef6921f4e15c40
Author: Federico Simoncelli <fsimonce(a)redhat.com>
Date: Wed Jul 13 14:14:09 2011 +0000
[WIP] Replace 'cp' and 'mkdir' with $(INSTALL)
Change-Id: Ib5e6215c30a3feb80e60e4feaff1d5280f7d1d08
diff --git a/vds_bootstrap/Makefile b/vds_bootstrap/Makefile
index 76bf525..6ba23bc 100644
--- a/vds_bootstrap/Makefile
+++ b/vds_bootstrap/Makefile
@@ -6,14 +6,16 @@
# LICENSE_GPL_v2 which accompany this distribution.
#
+INSTALL = install
TARGET = /usr/share/vdsm-bootstrap
-PYSRCS = vds_bootstrap.py deployUtil.py vds_bootstrap_complete.py
+PYSRCS = vds_bootstrap.py vds_bootstrap_complete.py
all: $(PYSRCS)
install:
- mkdir -p $(DESTDIR)/$(TARGET)
- cp $(PYSRCS) $(DESTDIR)/$(TARGET)
+ $(INSTALL) -Dd 755 $(DESTDIR)$(TARGET)
+ $(INSTALL) -Dm 755 $(PYSRCS) $(DESTDIR)$(TARGET)
+ $(INSTALL) -Dm 644 deployUtil.py $(DESTDIR)$(TARGET)
clean:
$(RM) *.pyc *.pyo *~
diff --git a/vdsm.spec.in b/vdsm.spec.in
index e6af2dc..e57ead5 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -64,7 +64,10 @@ make -C vdsm DESTDIR="%{buildroot}" \
VDSMLIBDIR=%{_localstatedir}/lib/%{vdsm_name} \
SOSPLUGINDIR=%{py_sitedir}/sos/plugins \
install
-mkdir -p "%{buildroot}"%{_localstatedir}/log/core
+
+# this is not commonplace, but we want /var/log/core to be a world-writable
+# dropbox for core dumps.
+install -dDm 1777 "%{buildroot}"%{_localstatedir}/log/core
# hook vhostmd
make -C vdsm/hooks/vhostmd DESTDIR="%{buildroot}" \
@@ -265,27 +268,27 @@ machines without running real guests.
%{_datadir}/%{vdsm_name}/hooks.py*
%{_datadir}/%{vdsm_name}/hooking.py*
%{_datadir}/%{vdsm_name}/libvirtev.py*
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/vdsm
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/vdsm-restore-net-config
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/vdsm-store-net-config
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/write-net-config
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/mk_sysprep_floppy
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/get-vm-pid
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/prepare-vmchannel
+%{_datadir}/%{vdsm_name}/vdsm
+%{_datadir}/%{vdsm_name}/vdsm-restore-net-config
+%{_datadir}/%{vdsm_name}/vdsm-store-net-config
+%{_datadir}/%{vdsm_name}/write-net-config
+%{_datadir}/%{vdsm_name}/mk_sysprep_floppy
+%{_datadir}/%{vdsm_name}/get-vm-pid
+%{_datadir}/%{vdsm_name}/prepare-vmchannel
%doc vdsm/vdsm.conf.sample
%config(noreplace) %{_sysconfdir}/%{vdsm_name}/logger.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/vdsm
%config(noreplace) %{_sysconfdir}/rwtab.d/vdsm
-%attr (440,root,root) %{_sysconfdir}/sudoers.d/50_vdsm
+%{_sysconfdir}/sudoers.d/50_vdsm
%{_sysconfdir}/cron.hourly/vdsm-logrotate
%{_datadir}/%{vdsm_name}/guestIF.py*
%{_datadir}/%{vdsm_name}/logUtils.py*
%{_datadir}/%{vdsm_name}/dsaversion.py*
%{_datadir}/%{vdsm_name}/pthread.py*
%{_datadir}/%{vdsm_name}/betterThreading.py*
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/logCollector.sh
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/persist-vdsm-hooks
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/unpersist-vdsm-hook
+%{_datadir}/%{vdsm_name}/logCollector.sh
+%{_libexecdir}/%{vdsm_name}/persist-vdsm-hooks
+%{_libexecdir}/%{vdsm_name}/unpersist-vdsm-hook
%{_datadir}/%{vdsm_name}/storage/__init__.py*
%{_datadir}/%{vdsm_name}/storage/dispatcher.py*
%{_datadir}/%{vdsm_name}/storage/storage_exception.py*
@@ -323,9 +326,9 @@ machines without running real guests.
%{_datadir}/%{vdsm_name}/storage/sdc.py*
%{_datadir}/%{vdsm_name}/storage/sdf.py*
%{_datadir}/%{vdsm_name}/storage/persistentDict.py*
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/safelease
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/spmprotect.sh
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/spmstop.sh
+%{_libexecdir}/%{vdsm_name}/safelease
+%{_libexecdir}/%{vdsm_name}/spmprotect.sh
+%{_libexecdir}/%{vdsm_name}/spmstop.sh
%dir %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start
%dir %{_libexecdir}/%{vdsm_name}/hooks/after_vm_start
%dir %{_libexecdir}/%{vdsm_name}/hooks/before_vm_cont
@@ -343,46 +346,49 @@ machines without running real guests.
%dir %{_libexecdir}/%{vdsm_name}/hooks/after_vm_destroy
%dir %{_libexecdir}/%{vdsm_name}/hooks/before_vdsm_start
%dir %{_libexecdir}/%{vdsm_name}/hooks/after_vdsm_stop
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/configNetwork.py*
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/addNetwork
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/delNetwork
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/respawn
+%{_datadir}/%{vdsm_name}/configNetwork.py*
+%{_datadir}/%{vdsm_name}/addNetwork
+%{_datadir}/%{vdsm_name}/delNetwork
+%{_datadir}/%{vdsm_name}/respawn
%{_datadir}/%{vdsm_name}/SecureXMLRPCServer.py*
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/get-conf-item
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/set-conf-item
+%{_datadir}/%{vdsm_name}/get-conf-item
+%{_datadir}/%{vdsm_name}/set-conf-item
%{_datadir}/%{vdsm_name}/kaxmlrpclib.py*
%{_datadir}/%{vdsm_name}/config.py*
%{_datadir}/%{vdsm_name}/ksm.py*
%{_datadir}/%{vdsm_name}/netinfo.py*
%{_datadir}/%{vdsm_name}/neterrors.py*
-%attr (755,root,root) %{_datadir}/%{vdsm_name}/img_verifier
+%{_datadir}/%{vdsm_name}/img_verifier
%{_sysconfdir}/udev/rules.d/12-vdsm-lvm.rules
-# this is not commonplace, but we want /var/log/core to be a world-writable
-# dropbox for core dumps.
-%dir %attr (1777,root,root) %{_localstatedir}/log/core
-%dir %attr (755,vdsm,kvm) %{_localstatedir}/lib/%{vdsm_name}
-%dir %attr (755,vdsm,kvm) %{_localstatedir}/lib/%{vdsm_name}/netconfback
-%dir %attr (755,vdsm,kvm) %{_localstatedir}/run/%{vdsm_name}
-%dir %attr (755,vdsm,kvm) %{_localstatedir}/run/%{vdsm_name}/pools
-%dir %attr (755,vdsm,kvm) %{_localstatedir}/log/%{vdsm_name}
-%dir %attr (755,vdsm,kvm) %{_localstatedir}/log/%{vdsm_name}/backup
-%dir %attr (755,vdsm,kvm) %{_sysconfdir}/pki/%{vdsm_name}
-%dir %attr (755,vdsm,kvm) %{_sysconfdir}/pki/%{vdsm_name}/keys
-%dir %attr (755,vdsm,kvm) %{_sysconfdir}/pki/%{vdsm_name}/certs
+%dir %{_localstatedir}/log/core
+
/etc/init.d/vdsmd
%doc LICENSE_GPL_v2 README
%{py_sitedir}/sos/plugins/vdsm.py*
-%dir %attr (775,vdsm,qemu) %{_localstatedir}/lib/libvirt/qemu/channels/
%{_mandir}/man8/vdsmd.8*
+%defattr(-, vdsm, qemu, -)
+%dir %{_localstatedir}/lib/libvirt/qemu/channels
+
+%defattr(-, vdsm, kvm, -)
+%dir %{_sysconfdir}/pki/%{vdsm_name}
+%dir %{_sysconfdir}/pki/%{vdsm_name}/keys
+%dir %{_sysconfdir}/pki/%{vdsm_name}/certs
+%dir %{_localstatedir}/lib/%{vdsm_name}
+%dir %{_localstatedir}/lib/%{vdsm_name}/netconfback
+%dir %{_localstatedir}/run/%{vdsm_name}
+%dir %{_localstatedir}/run/%{vdsm_name}/pools
+%dir %{_localstatedir}/log/%{vdsm_name}
+%dir %{_localstatedir}/log/%{vdsm_name}/backup
+
%files hook-vhostmd
%defattr(-,root,root,-)
%doc LICENSE_GPL_v2
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_vhostmd
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/hooks/before_vm_migrate_destination/50_vhostmd
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/hooks/before_vm_dehibernate/50_vhostmd
-%attr (755,root,root) %{_libexecdir}/%{vdsm_name}/hooks/after_vm_destroy/50_vhostmd
-%attr (440,root,root) %{_sysconfdir}/sudoers.d/50_vdsm_hook_vhostmd
+%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_vhostmd
+%{_libexecdir}/%{vdsm_name}/hooks/before_vm_migrate_destination/50_vhostmd
+%{_libexecdir}/%{vdsm_name}/hooks/before_vm_dehibernate/50_vhostmd
+%{_libexecdir}/%{vdsm_name}/hooks/after_vm_destroy/50_vhostmd
+%{_sysconfdir}/sudoers.d/50_vdsm_hook_vhostmd
%files debug-plugin
%defattr(-,root,root,-)
@@ -395,13 +401,12 @@ machines without running real guests.
%{_sysconfdir}/bash_completion.d/vdsClient
%{_datadir}/%{vdsm_name}/vdscli.py*
%{_datadir}/%{vdsm_name}/dumpStorageTable.py*
-%attr (755,root,root) %{_bindir}/vdsClient
+%{_bindir}/vdsClient
%{_mandir}/man1/vdsClient.1*
%files bootstrap
%defattr(-,root,root,-)
%doc LICENSE_GPL_v2
-%dir %{_datadir}/%{vdsm_bootstrap}
%{_datadir}/%{vdsm_bootstrap}/vds_bootstrap.py*
%{_datadir}/%{vdsm_bootstrap}/deployUtil.py*
%{_datadir}/%{vdsm_bootstrap}/vds_bootstrap_complete.py*
@@ -410,9 +415,8 @@ machines without running real guests.
%files reg
%defattr(-,root,root,-)
%doc LICENSE_GPL_v2
-%dir %{_sysconfdir}/%{vdsm_reg}
-%dir %{_datadir}/%{vdsm_reg}
-%dir %attr (755,vdsm,kvm) %{_var}/log/%{vdsm_reg}
+%dir %{_sysconfdir}/%{vdsm_reg}
+%dir %{_datadir}/%{vdsm_reg}
%config(noreplace) %{_sysconfdir}/%{vdsm_reg}/vdsm-reg.conf
%config(noreplace) %{_sysconfdir}/%{vdsm_reg}/logger.conf
%{_sysconfdir}/init.d/vdsm-reg
@@ -425,13 +429,15 @@ machines without running real guests.
%{_datadir}/%{vdsm_reg}/deployUtil.py*
%{_datadir}/%{vdsm_reg}/createDaemon.py*
%{py_sitedir}/ovirt_config_setup/rhevm.py*
-%attr (755,root,root) %{_datadir}/%{vdsm_reg}/config-rhev-manager
-%attr (755,root,root) %{_datadir}/%{vdsm_reg}/save-config
+%{_datadir}/%{vdsm_reg}/config-rhev-manager
+%{_datadir}/%{vdsm_reg}/save-config
%{_sysconfdir}/ovirt-config-setup.d
%{_sysconfdir}/ovirt-config-boot.d/vdsm-config
%config(noreplace) %{_sysconfdir}/logrotate.d/vdsm-reg
%{_sysconfdir}/cron.hourly/vdsm-reg-logrotate
%{_mandir}/man8/vdsm-reg.8*
+%defattr(-, vdsm, kvm,-)
+%dir %{_var}/log/%{vdsm_reg}
%files hook-faqemu
%defattr(-,root,root,-)
diff --git a/vdsm/Makefile b/vdsm/Makefile
index 71d6859..ef4137f 100644
--- a/vdsm/Makefile
+++ b/vdsm/Makefile
@@ -5,6 +5,9 @@
# (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 \
@@ -93,45 +96,37 @@ HOOKS=before_vm_start after_vm_start before_vm_cont after_vm_cont \
before_vdsm_start after_vdsm_stop
install: all sudoers.vdsm vdsm.conf.sample
- mkdir -p $(DESTDIR)$(VDSMDIR)
- mkdir -p $(DESTDIR)$(VDSMDIR)/storage
- mkdir -p $(DESTDIR)$(TRUSTSTORE)/{certs,keys}
- mkdir -p $(DESTDIR)$(VDSMLOGDIR)
- mkdir -p $(DESTDIR)$(VDSMRUNDIR)
- mkdir -p $(DESTDIR)$(VDSMLIBDIR)
- mkdir -p $(DESTDIR)$(VDSMLIBDIR)/netconfback
- mkdir -p $(DESTDIR)$(POOLSDATADIR)
- mkdir -p $(DESTDIR)$(BACKUPDIR)
- mkdir -p $(DESTDIR)$(BINDIR)
- mkdir -p $(DESTDIR)$(LIBEXECDIR)
- (for hook in $(HOOKS); do mkdir -p $(DESTDIR)$(LIBEXECDIR)/hooks/$$hook; done)
- mkdir -p $(DESTDIR)$(CONFDIR)
- mkdir -p $(DESTDIR)$(POOLDATADIR)
- mkdir -p $(DESTDIR)$(BACKUPDATADIR)
- mkdir -p $(DESTDIR)/etc/init.d/
- mkdir -p $(DESTDIR)/etc/udev/rules.d/
- mkdir -p $(DESTDIR)/var/lib/libvirt/qemu/channels/
- cp $(FILES) $(DESTDIR)$(VDSMDIR)
- cp $(SCRIPTFILES) $(DESTDIR)$(VDSMDIR)
- (cd storage; cp $(STORAGEFILES) $(DESTDIR)$(VDSMDIR)/storage)
- (cd storage; cp 12-vdsm-lvm.rules $(DESTDIR)$(UDEVDIR))
- cp logger.conf $(DESTDIR)$(CONFDIR)
- cp vdsmd $(DESTDIR)/etc/init.d/vdsmd
- (cd storage/protect; cp $(PROTECTFILES) $(DESTDIR)$(LIBEXECDIR))
- mkdir -p $(DESTDIR)/etc/sudoers.d/
- cp sudoers.vdsm $(DESTDIR)/etc/sudoers.d/50_vdsm
- mkdir -p $(DESTDIR)/etc/logrotate.d
- mkdir -p $(DESTDIR)/etc/cron.hourly
- mkdir -p $(DESTDIR)$(SOSPLUGINDIR)
- cp -p vdsm-logrotate.conf $(DESTDIR)/etc/logrotate.d/vdsm
- cp -p vdsm-logrotate $(DESTDIR)/etc/cron.hourly
- cp -p vdsm-sosplugin.py $(DESTDIR)$(SOSPLUGINDIR)/vdsm.py
- mkdir -p $(DESTDIR)$(MANDIR)/man8
- cp -p vdsmd.8 $(DESTDIR)$(MANDIR)/man8/
- mkdir -p $(DESTDIR)/etc/rwtab.d/
- cp -p vdsm.rwtab $(DESTDIR)/etc/rwtab.d/vdsm
- cp -p hooks/persist-vdsm-hooks $(DESTDIR)$(LIBEXECDIR)
- cp -p hooks/unpersist-vdsm-hook $(DESTDIR)$(LIBEXECDIR)
+ $(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)/etc/init.d
+ $(INSTALL) -Dd $(DESTDIR)/etc/udev/rules.d
+ $(INSTALL) -Dd -m 775 $(DESTDIR)/var/lib/libvirt/qemu/channels
+ (for hook in $(HOOKS); do \
+ $(INSTALL) -Dd $(DESTDIR)$(LIBEXECDIR)/hooks/$$hook; \
+ done)
+ $(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 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
+ $(INSTALL) -Dm 755 hooks/persist-vdsm-hooks $(DESTDIR)$(LIBEXECDIR)/persist-vdsm-hooks
+ $(INSTALL) -Dm 755 hooks/unpersist-vdsm-hook $(DESTDIR)$(LIBEXECDIR)/unpersist-vdsm-hook
clean:
$(RM) *~ *.pyc storage/protect/safelease vdsm.conf.sample
diff --git a/vdsm/hooks/faqemu/Makefile b/vdsm/hooks/faqemu/Makefile
index 00ee2f5..0ec2515 100644
--- a/vdsm/hooks/faqemu/Makefile
+++ b/vdsm/hooks/faqemu/Makefile
@@ -1,13 +1,13 @@
+INSTALL=install
+LN_S=ln -s
BINDIR=/usr/bin
LIBEXECDIR=/usr/libexec/vdsm
HOOKSDIR=$(LIBEXECDIR)/hooks
install:
- install -d $(DESTDIR)$(BINDIR)
- install -m 755 qemu $(DESTDIR)$(BINDIR)
- ln -sf qemu $(DESTDIR)$(BINDIR)/qemu-system-x86_64
- install -d $(DESTDIR)$(HOOKSDIR)/before_vm_start
- install -m 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/10_faqemu
+ $(INSTALL) -Dm 755 qemu $(DESTDIR)$(BINDIR)/qemu
+ $(LN_S) qemu $(DESTDIR)$(BINDIR)/qemu-system-x86_64
+ $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/10_faqemu
clean:
$(RM) *~ *.pyc
diff --git a/vdsm/hooks/vhostmd/Makefile b/vdsm/hooks/vhostmd/Makefile
index 2efc7ce..6f13033 100644
--- a/vdsm/hooks/vhostmd/Makefile
+++ b/vdsm/hooks/vhostmd/Makefile
@@ -1,16 +1,16 @@
+INSTALL=install
+LN_S=ln -s
LIBEXECDIR=/usr/libexec/vdsm
HOOKSDIR=$(LIBEXECDIR)/hooks
all:
install:
- mkdir -p $(DESTDIR)$(HOOKSDIR)/{before_vm_start,after_vm_destroy}
- cp before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/50_vhostmd
- ln -s ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_migrate_destination/50_vhostmd
- ln -s ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_dehibernate/50_vhostmd
- cp after_vm_destroy.py $(DESTDIR)$(HOOKSDIR)/after_vm_destroy/50_vhostmd
- mkdir -p $(DESTDIR)/etc/sudoers.d/
- cp sudoers.vdsm_hook_vhostmd $(DESTDIR)/etc/sudoers.d/50_vdsm_hook_vhostmd
+ $(INSTALL) -Dm 755 before_vm_start.py $(DESTDIR)$(HOOKSDIR)/before_vm_start/50_vhostmd
+ $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_migrate_destination/50_vhostmd
+ $(LN_S) ../before_vm_start/50_vhostmd $(DESTDIR)$(HOOKSDIR)/before_vm_dehibernate/50_vhostmd
+ $(INSTALL) -Dm 755 after_vm_destroy.py $(DESTDIR)$(HOOKSDIR)/after_vm_destroy/50_vhostmd
+ $(INSTALL) -Dm 440 sudoers.vdsm_hook_vhostmd $(DESTDIR)/etc/sudoers.d/50_vdsm_hook_vhostmd
clean:
$(RM) *~ *.pyc
diff --git a/vdsm_cli/Makefile b/vdsm_cli/Makefile
index 65b22cc..f135d27 100644
--- a/vdsm_cli/Makefile
+++ b/vdsm_cli/Makefile
@@ -5,6 +5,9 @@
# (at your option) any later version. See the files README and
# LICENSE_GPL_v2 which accompany this distribution.
#
+
+INSTALL = install
+
TARGET = /usr/share/vdsm
PYSRCS = vdsClient.py vdscli.py dumpStorageTable.py
CONFDIR = /etc/vdsm
@@ -21,14 +24,11 @@ fixpaths:
sed -i "s:@TRUSTSTORE@:$(TRUSTSTORE):" vdscli.py
install: fixpaths
- mkdir -p $(DESTDIR)/$(TARGET)
- cp $(PYSRCS) $(DESTDIR)/$(TARGET)
- mkdir -p $(DESTDIR)/$(BINDIR)
- cp vdsClient $(DESTDIR)/$(BINDIR)
- mkdir -p $(DESTDIR)/$(COMPDIR)
- cp vdsClient.completion $(DESTDIR)$(COMPDIR)/vdsClient
- mkdir -p $(DESTDIR)$(MANDIR)/man1
- cp vdsClient.1 $(DESTDIR)$(MANDIR)/man1/
+ $(INSTALL) -Dd $(DESTDIR)/$(TARGET)
+ $(INSTALL) -Dm 644 $(PYSRCS) $(DESTDIR)/$(TARGET)
+ $(INSTALL) -Dm 755 vdsClient $(DESTDIR)/$(BINDIR)/vdsClient
+ $(INSTALL) -Dm 644 vdsClient.completion $(DESTDIR)$(COMPDIR)/vdsClient
+ $(INSTALL) -Dm 644 vdsClient.1 $(DESTDIR)$(MANDIR)/man1/vdsClient.1
clean:
$(RM) *~ *.pyc
diff --git a/vdsm_reg/Makefile b/vdsm_reg/Makefile
index bf33db8..5e1cdc0 100644
--- a/vdsm_reg/Makefile
+++ b/vdsm_reg/Makefile
@@ -1,3 +1,5 @@
+INSTALL=install
+LN_S=ln -s
VDSMREGDIR=/usr/share/vdsm-reg
ETC=/etc
CONFDIR=$(ETC)/vdsm-reg
@@ -5,6 +7,8 @@ LOGDIR=/var/log/vdsm-reg
VDSMRUNDIR=/var/run/vdsm
MANDIR=/usr/share/man
+FILES=define.py config.py deployUtil.py createDaemon.py
+
all:
@echo only \"make install\" is available
@false
@@ -13,24 +17,25 @@ fixpaths:
sed -i "s:@VDSMRUNDIR@:$(VDSMRUNDIR):" vdsm-reg.conf
install: fixpaths
- mkdir -p $(DESTDIR)$(CONFDIR)
- mkdir -p $(DESTDIR)$(VDSMREGDIR)
- mkdir -p $(DESTDIR)$(ETC)/ovirt-config-setup.d/
- mkdir -p $(DESTDIR)$(ETC)/ovirt-config-boot.d/
- mkdir -p $(DESTDIR)$(LOGDIR)
- mkdir -p $(DESTDIR)$(OVIRT_CONFIG_SETUP)
-
- cp -p vdsm-reg $(DESTDIR)$(ETC)/init.d
- cp -p {logger.conf,vdsm-reg.conf} $(DESTDIR)$(CONFDIR)
- cp -p define.py config.py config-rhev-manager save-config deployUtil.py createDaemon.py $(DESTDIR)$(VDSMREGDIR)
- cp -p vdsm-reg-setup.py $(DESTDIR)$(VDSMREGDIR)/vdsm-reg-setup
- cp -p vdsm-gen-cert.py $(DESTDIR)$(VDSMREGDIR)/vdsm-gen-cert
- cp -p vdsm-complete.py $(DESTDIR)$(VDSMREGDIR)/vdsm-complete
- cp -p vdsm-upgrade.py $(DESTDIR)$(VDSMREGDIR)/vdsm-upgrade
- ln -s $(VDSMREGDIR)/config-rhev-manager $(DESTDIR)$(ETC)/ovirt-config-setup.d/"40_Configure the host for RHEV"
- cp -p vdsm-config $(DESTDIR)$(ETC)/ovirt-config-boot.d
- cp -p vdsm-reg-logrotate.conf $(DESTDIR)$(ETC)/logrotate.d/vdsm-reg
- cp -p vdsm-reg-logrotate $(DESTDIR)$(ETC)/cron.hourly
- mkdir -p $(DESTDIR)$(MANDIR)/man8
- cp -p vdsm-reg.8 $(DESTDIR)$(MANDIR)/man8/
- cp -p rhevm.py $(DESTDIR)$(OVIRT_CONFIG_SETUP)
+ $(INSTALL) -Dd $(DESTDIR)$(CONFDIR)
+ $(INSTALL) -Dd $(DESTDIR)$(VDSMREGDIR)
+ $(INSTALL) -Dd $(DESTDIR)$(LOGDIR)
+ $(INSTALL) -Dd $(DESTDIR)$(OVIRT_CONFIG_SETUP)
+ $(INSTALL) -Dm 755 vdsm-reg $(DESTDIR)$(ETC)/init.d/vdsm-reg
+ $(INSTALL) -Dm 644 logger.conf $(DESTDIR)$(CONFDIR)/logger.conf
+ $(INSTALL) -Dm 644 vdsm-reg.conf $(DESTDIR)$(CONFDIR)/vdsm-reg.conf
+ $(INSTALL) -Dm 644 $(FILES) $(DESTDIR)$(VDSMREGDIR)
+ $(INSTALL) -Dm 755 save-config $(DESTDIR)$(VDSMREGDIR)
+ $(INSTALL) -Dm 755 config-rhev-manager $(DESTDIR)$(VDSMREGDIR)
+ $(INSTALL) -Dm 755 vdsm-reg-setup.py $(DESTDIR)$(VDSMREGDIR)/vdsm-reg-setup
+ $(INSTALL) -Dm 755 vdsm-gen-cert.py $(DESTDIR)$(VDSMREGDIR)/vdsm-gen-cert
+ $(INSTALL) -Dm 755 vdsm-complete.py $(DESTDIR)$(VDSMREGDIR)/vdsm-complete
+ $(INSTALL) -Dm 755 vdsm-upgrade.py $(DESTDIR)$(VDSMREGDIR)/vdsm-upgrade
+ $(INSTALL) -Dd $(DESTDIR)$(ETC)/ovirt-config-setup.d
+ $(LN_S) $(VDSMREGDIR)/config-rhev-manager \
+ "$(DESTDIR)$(ETC)/ovirt-config-setup.d/40_Configure the host for RHEV"
+ $(INSTALL) -Dm 755 vdsm-config $(DESTDIR)$(ETC)/ovirt-config-boot.d/vdsm-config
+ $(INSTALL) -Dm 644 vdsm-reg-logrotate.conf $(DESTDIR)$(ETC)/logrotate.d/vdsm-reg
+ $(INSTALL) -Dm 755 vdsm-reg-logrotate $(DESTDIR)$(ETC)/cron.hourly
+ $(INSTALL) -Dm 644 vdsm-reg.8 $(DESTDIR)$(MANDIR)/man8/vdsm-reg.8
+ $(INSTALL) -Dm 644 rhevm.py $(DESTDIR)$(OVIRT_CONFIG_SETUP)
12 years, 8 months