[Ovirt-devel] [PATCH-node 2/2] A rather large re-write of the ovirt-node.spec file. The reason

Chris Lalancette clalance at redhat.com
Wed Sep 10 06:42:13 UTC 2008


Signed-off-by: Chris Lalancette <clalance at redhat.com>
---
:000000 100644 0000000... 584291a... A	ovirt-listen-awake/ovirt-convert-host
:000000 100644 0000000... a6bb78a... A	ovirt-listen-awake/ovirt-listen-awake.init
:000000 100644 0000000... 4f0b02d... A	ovirt-listen-awake/ovirt-unconvert-host
:100644 100644 736338d... 3274a3f... M	ovirt-node.spec
:100644 100644 083e13d... 6ea034a... M	scripts/ovirt-functions
 ovirt-listen-awake/ovirt-convert-host      |   58 +++++++++++++++++++
 ovirt-listen-awake/ovirt-listen-awake.init |   49 ++++++++++++++++
 ovirt-listen-awake/ovirt-unconvert-host    |   32 ++++++++++
 ovirt-node.spec                            |   86 ++++++++++++++++-----------
 scripts/ovirt-functions                    |   26 ++++++++
 5 files changed, 216 insertions(+), 35 deletions(-)

diff --git a/ovirt-listen-awake/ovirt-convert-host b/ovirt-listen-awake/ovirt-convert-host
new file mode 100644
index 0000000..584291a
--- /dev/null
+++ b/ovirt-listen-awake/ovirt-convert-host
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+. /etc/init.d/ovirt-functions
+
+PATH=$PATH:/sbin:/usr/sbin
+
+if [ $# -ne 0 ]; then
+    echo "Usage: ovirt-convert-host"
+    exit 1
+fi
+
+backup_file() {
+    dir=$(dirname "$1")
+    case $dir in /*);; *) die "unexpected non-absolute dir: $dir";; esac
+    mkdir -p "$OVIRT_BACKUP_DIR/${dir:1}"
+    cp -pf "$1" "$OVIRT_BACKUP_DIR/${dir:1}"
+}
+
+add_if_not_exist() {
+    string="$1"
+    file="$2"
+
+    grep -qE "^[[:space:]]*$string($|#|[[:space:]])" "$file" \
+	|| echo "$string" >> "$file"
+}
+
+echo "This script will make a number of changes to your system to enable it to"
+echo "work as an oVirt node.  You can later undo these changes by"
+echo "running /usr/sbin/ovirt-unconvert-host.  Do you want to proceed? [y/N]?"
+read yesno
+
+if [ "$yesno" != "y" -a "$yesno" != "Y" ]; then
+    exit 2
+fi
+
+mkdir -p $OVIRT_BACKUP_DIR
+
+backup_file /etc/sysconfig/network
+sed -i -e 's/^HOSTNAME=.*/HOSTNAME=physical.priv.ovirt.org/' /etc/sysconfig/network
+
+backup_file /etc/hosts
+add_if_not_exist "192.168.50.1 physical.priv.ovirt.org" /etc/hosts
+add_if_not_exist "192.168.50.2 management.priv.ovirt.org" /etc/hosts
+
+chkconfig ovirt-listen-awake on
+chkconfig collectd on
+
+backup_file /etc/sysconfig/libvirtd
+backup_file /etc/libvirt/qemu.conf
+backup_file /etc/libvirt/libvirtd.conf
+backup_file /etc/sasl2/libvirt.conf
+ovirt_setup_libvirtd
+
+backup_file /etc/sysconfig/iptables
+lokkit -n -t ovirtbr0
+
+echo "Setup complete.  To make the changes take effect, shut down any running
+guests and reboot the host"
diff --git a/ovirt-listen-awake/ovirt-listen-awake.init b/ovirt-listen-awake/ovirt-listen-awake.init
new file mode 100644
index 0000000..a6bb78a
--- /dev/null
+++ b/ovirt-listen-awake/ovirt-listen-awake.init
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+#
+# ovirt-listen-awake       startup script for ovirt-listen-awake
+#
+# chkconfig: - 97 03
+# description: ovirt-listen-awake is a daemon to listen for requests from
+#    the ovirt VM manager.  When it receives one, it contacts the machine
+#    back with details so that it is added to the ovirt host pool.
+
+DAEMON=/usr/sbin/ovirt-listen-awake
+
+. /etc/init.d/functions
+
+start() {
+    echo -n "Starting ovirt-listen-awake: "
+    daemon $DAEMON
+    RETVAL=$?
+    echo
+}
+
+stop() {
+    echo -n "Shutting down ovirt-listen-awake: "
+    killproc ovirt-listen-awake
+    RETVAL=$?
+    echo
+}
+
+case "$1" in
+    start)
+	start
+	;;
+    stop)
+	stop
+	;;
+    restart)
+	stop
+	start
+	;;
+    status)
+	status $DAEMON
+	RETVAL=$?
+	;;
+    *)
+      echo "Usage: ovirt-listen-awake {start|stop|restart|status}"
+      exit 1
+  ;;
+esac
+exit $RETVAL
diff --git a/ovirt-listen-awake/ovirt-unconvert-host b/ovirt-listen-awake/ovirt-unconvert-host
new file mode 100644
index 0000000..4f0b02d
--- /dev/null
+++ b/ovirt-listen-awake/ovirt-unconvert-host
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+. /etc/init.d/ovirt-functions
+
+PATH=$PATH:/sbin:/usr/sbin
+
+if [ $# -ne 0 ]; then
+    echo "Usage: ovirt-unconvert-host"
+    exit 1
+fi
+
+if [ ! -d $OVIRT_BACKUP_DIR ]; then
+    echo "The oVirt backup directory $OVIRT_BACKUP_DIR doesn't exist; can't"
+    echo "unconvert the host"
+    exit 2
+fi
+
+unbackup_file() {
+    # note that $1 will have a / on the front, so we don't need to add our own
+    cp -pf "$OVIRT_BACKUP_DIR$1" "$1"
+}
+
+chkconfig ovirt-listen-awake off
+chkconfig collectd off
+
+unbackup_file /etc/sysconfig/network
+unbackup_file /etc/hosts
+unbackup_file /etc/sysconfig/libvirtd
+unbackup_file /etc/libvirt/qemu.conf
+unbackup_file /etc/libvirt/libvirtd.conf
+unbackup_file /etc/sasl2/libvirt.conf
+unbackup_file /etc/sysconfig/iptables
diff --git a/ovirt-node.spec b/ovirt-node.spec
index 736338d..3274a3f 100644
--- a/ovirt-node.spec
+++ b/ovirt-node.spec
@@ -15,6 +15,8 @@ BuildRequires:  libvirt-devel
 BuildRequires:  dbus-devel hal-devel
 Requires:       libvirt
 Requires:       hal
+Requires:       collectd
+Requires:       cyrus-sasl-gssapi
 ExclusiveArch:  %{ix86} x86_64
 
 %define app_root %{_datadir}/%{name}
@@ -23,6 +25,20 @@ ExclusiveArch:  %{ix86} x86_64
 Provides a series of daemons and support utilities to allow an
 oVirt Node to interact with the oVirt server.
 
+%package stateless
+Summary:  The oVirt Node scripts for stateless
+Group:    Applications/System
+Requires: %{name} = %{version}-%{release}
+%description stateless
+This package does configuration for a stateless oVirt Node.
+
+%package stateful
+Summary:  The oVirt node scripts for existing machines
+Group:    Applications/System
+Requires: %{name} = %{version}-%{release}
+%description stateful
+This package does configuration for a stateful oVirt node.
+
 %prep
 
 %setup -q
@@ -44,6 +60,9 @@ make
 %{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_sbindir}
 %{__install} -p -m0755 ovirt-identify-node/ovirt-identify-node %{buildroot}%{_sbindir}
 %{__install} -p -m0755 ovirt-listen-awake/ovirt-listen-awake %{buildroot}%{_sbindir}
+%{__install} -Dp -m0755 ovirt-listen-awake/ovirt-listen-awake.init %{buildroot}%{_initrddir}/ovirt-listen-awake
+%{__install} -Dp -m0755 ovirt-listen-awake/ovirt-convert-host %{buildroot}%{_sbindir}
+%{__install} -Dp -m0755 ovirt-listen-awake/ovirt-unconvert-host %{buildroot}%{_sbindir}
 
 %{__install} -p -m0644 scripts/ovirt-functions %{buildroot}%{_initrddir}
 %{__install} -p -m0755 scripts/ovirt-early %{buildroot}%{_initrddir}
@@ -52,8 +71,6 @@ make
 
 %{__install} -p -m0644 scripts/collectd %{buildroot}%{_sysconfdir}/chkconfig.d
 %{__install} -p -m0644 scripts/collectd.conf.in %{buildroot}%{_sysconfdir}
-%{__install} -p -m0755 scripts/kvm-ifup %{buildroot}%{_sysconfdir}
-%{__install} -p -m0755 scripts/dhclient-exit-hooks %{buildroot}%{_sysconfdir}
 
 %{__install} -p -m0755 logrotate/ovirt-logrotate %{buildroot}%{_sysconfdir}/cron.hourly
 %{__install} -p -m0644 logrotate/ovirt-logrotate.conf %{buildroot}%{_sysconfdir}/logrotate.d
@@ -63,40 +80,26 @@ echo "oVirt Node release %{version}-%{release}" > %{buildroot}%{_sysconfdir}/ovi
 %clean
 %{__rm} -rf %{buildroot}
 
-%post
+%post stateful
+/sbin/chkconfig --add ovirt-listen-awake
+# this is ugly; we need collectd to start *after* libvirtd, so we own the
+# /etc/chkconfig.d/collectd file, and then have to re-define collectd here
+/sbin/chkconfig --add collectd
+
+%post stateless
 /sbin/chkconfig --add ovirt-early
 /sbin/chkconfig ovirt-early on
 /sbin/chkconfig --add ovirt
 /sbin/chkconfig ovirt on
 /sbin/chkconfig --add ovirt-post
 /sbin/chkconfig ovirt-post on
-/sbin/chkconfig --add collectd
-/sbin/chkconfig collectd on
-
-# just to get a boot warning to shut up
-touch /etc/resolv.conf
-
-# make libvirtd listen on the external interfaces
-sed -i -e "s/^#\(LIBVIRTD_ARGS=\"--listen\"\).*/\1/" /etc/sysconfig/libvirtd
 
-# set up qemu daemon to allow outside VNC connections
-sed -i -e "s/^[[:space:]]*#[[:space:]]*\(vnc_listen = \"0.0.0.0\"\).*/\1/" \
-    /etc/libvirt/qemu.conf
-
-# set up libvirtd to listen on TCP (for kerberos)
-sed -i -e "s/^[[:space:]]*#[[:space:]]*\(listen_tcp\)\>.*/\1 = 1/" \
-    -e "s/^[[:space:]]*#[[:space:]]*\(listen_tls\)\>.*/\1 = 0/" \
-    /etc/libvirt/libvirtd.conf
+. /etc/init.d/ovirt-functions
+ovirt_setup_libvirtd
 
 # make sure we don't autostart virbr0 on libvirtd startup
 rm -f /etc/libvirt/qemu/networks/autostart/default.xml
 
-# with the new libvirt (0.4.0), make sure we we setup gssapi in the mech_list
-if [ `egrep -c "^mech_list: gssapi" /etc/sasl2/libvirt.conf` -eq 0 ]; then
-    sed -i -e "s/^\([[:space:]]*mech_list.*\)/#\1/" /etc/sasl2/libvirt.conf
-    echo "mech_list: gssapi" >> /etc/sasl2/libvirt.conf
-fi
-
 # remove the /etc/krb5.conf file; it will be fetched on bootup
 rm -f /etc/krb5.conf
 
@@ -120,25 +123,22 @@ cat <<EOF > /etc/issue
 EOF
 cp -p /etc/issue /etc/issue.net
 
-%preun
+%preun stateless
 if [ "$1" = 0 ] ; then
   /sbin/chkconfig --del ovirt-early
   /sbin/chkconfig --del ovirt
   /sbin/chkconfig --del ovirt-post
 fi
 
+%preun stateful
+if [ "$1" = 0 ] ; then
+   /sbin/chkconfig --del ovirt-listen-awake
+fi
+
 %files
 %defattr(-,root,root,0755)
 %{_sbindir}/ovirt-awake
 %{_sbindir}/ovirt-identify-node
-%{_sbindir}/ovirt-listen-awake
-%{_initrddir}/ovirt-early
-%{_initrddir}/ovirt
-%{_initrddir}/ovirt-post
-%{_sysconfdir}/kvm-ifup
-%{_sysconfdir}/dhclient-exit-hooks
-%config %{_sysconfdir}/logrotate.d/ovirt-logrotate.conf
-%config %{_sysconfdir}/cron.hourly/ovirt-logrotate
 %defattr(-,root,root,0644)
 %{_initrddir}/ovirt-functions
 %{_sysconfdir}/collectd.conf.in
@@ -148,10 +148,26 @@ fi
 %doc ovirt-identify-node/AUTHOR ovirt-identify-node/ChangeLog
 %doc ovirt-identify-node/COPYING
 
+%files stateful
+%{_initrddir}/ovirt-listen-awake
+%{_sbindir}/ovirt-listen-awake
+%{_sbindir}/ovirt-convert-host
+%{_sbindir}/ovirt-unconvert-host
+
+%files stateless
+%config %{_sysconfdir}/logrotate.d/ovirt-logrotate.conf
+%config %{_sysconfdir}/cron.hourly/ovirt-logrotate
+%{_initrddir}/ovirt-early
+%{_initrddir}/ovirt
+%{_initrddir}/ovirt-post
+
 %changelog
-* Mon Sep  8 2008 Jim Meyering <meyering at redhat.com> - 0.92 0.6
+* Mon Sep  8 2008 Jim Meyering <meyering at redhat.com> - 0.92 0.7
 - Update ovirt-identify-node's build rule.
 
+* Thu Aug 28 2008 Chris Lalancette <clalance at redhat.com> - 0.92 0.6
+- Rewrite the whole spec to make sub-packages for stateless vs. stateful
+
 * Fri Aug 22 2008 Chris Lalancette <clalance at redhat.com> - 0.92 0.5
 - Add the ovirt-listen-awake daemon to the RPM
 
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index 083e13d..6ea034a 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -5,6 +5,8 @@ OVIRT_LOGFILE=/var/log/ovirt.log
 # label of the oVirt partition
 OVIRT_LABEL=OVIRT
 
+OVIRT_BACKUP_DIR=/var/lib/ovirt-backup
+
 find_srv()
 {
     local dnsreply
@@ -21,3 +23,27 @@ die()
 {
     echo "$@" 1>&2; failure; echo 1>&2; exit 1
 }
+
+ovirt_setup_libvirtd() {
+    # just to get a boot warning to shut up
+    touch /etc/resolv.conf
+
+    # make libvirtd listen on the external interfaces
+    sed -i -e 's/^#\(LIBVIRTD_ARGS="--listen"\).*/\1/' \
+	/etc/sysconfig/libvirtd
+
+    # set up qemu daemon to allow outside VNC connections
+    sed -i -e 's/^[[:space:]]*#[[:space:]]*\(vnc_listen = "0.0.0.0"\).*/\1/' \
+	/etc/libvirt/qemu.conf
+    # set up libvirtd to listen on TCP (for kerberos)
+    sed -i -e "s/^[[:space:]]*#[[:space:]]*\(listen_tcp\)\>.*/\1 = 1/" \
+	-e "s/^[[:space:]]*#[[:space:]]*\(listen_tls\)\>.*/\1 = 0/" \
+	/etc/libvirt/libvirtd.conf
+
+    # with libvirt (0.4.0), make sure we we setup gssapi in the mech_list
+    sasl_conf=/etc/sasl2/libvirt.conf
+    if ! grep -qE "^mech_list: gssapi" $sasl_conf ; then
+	sed -i -e "s/^\([[:space:]]*mech_list.*\)/#\1/" $sasl_conf
+	echo "mech_list: gssapi" >> $sasl_conf
+    fi
+}
-- 
1.5.4.1




More information about the ovirt-devel mailing list