Hi,

here is the patch to build rhn-virtualization on openSUSE.

0010-build-rhn-virtualization-on-SUSE.patch:
- modify the specfile
- add SUSE init script

-- 
Regards,

        Michael Calmer

--------------------------------------------------------------------------
Michael Calmer
SUSE LINUX Products GmbH, Maxfeldstr. 5, D-90409 Nuernberg
T: +49 (0) 911 74053 0
F: +49 (0) 911 74053575  - e-mail: michael.cal...@suse.com
--------------------------------------------------------------------------
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG N├╝rnberg)
From 2546d27a7edbf2c4ae2235e2c64220db60bdb95a Mon Sep 17 00:00:00 2001
From: Michael Calmer <m...@suse.de>
Date: Mon, 4 Apr 2011 17:09:19 +0200
Subject: [PATCH 10/17] build rhn-virtualization on SUSE

- modify the specfile
- add SUSE init script
---
 .../rhn-virtualization/rhn-virtualization.spec     |   28 +++++-
 .../scripts/rhn-virtualization-host.SUSE           |  113 ++++++++++++++++++++
 2 files changed, 138 insertions(+), 3 deletions(-)
 create mode 100755 client/tools/rhn-virtualization/scripts/rhn-virtualization-host.SUSE

diff --git a/client/tools/rhn-virtualization/rhn-virtualization.spec b/client/tools/rhn-virtualization/rhn-virtualization.spec
index e9b7bf6..fab0e8b 100644
--- a/client/tools/rhn-virtualization/rhn-virtualization.spec
+++ b/client/tools/rhn-virtualization/rhn-virtualization.spec
@@ -15,6 +15,9 @@ Release:        1%{?dist}
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:      noarch
 BuildRequires:  python
+%if 0%{?suse_version}
+BuildRequires: sysconfig syslog
+%endif
 
 %description
 rhn-virtualization provides various RHN/Spacewalk actions for manipulation 
@@ -24,7 +27,9 @@ virtual machine guest images.
 Summary: Files needed by rhn-virtualization-host
 Group: System Environment/Base
 Requires: rhn-client-tools
+%if !0%{?suse_version}
 Requires: chkconfig
+%endif
 
 %description common
 This package contains files that are needed by the rhn-virtualization-host
@@ -35,7 +40,11 @@ Summary: RHN/Spacewalk Virtualization support specific to the Host system
 Group: System Environment/Base
 Requires: libvirt-python
 Requires: rhn-virtualization-common = %{version}-%{release}
+%if 0%{?suse_version}
+Requires: cron
+%else
 Requires: /usr/sbin/crond
+%endif
 %if 0%{?rhel} && 0%{?rhel} < 6
 # in RHEL5 we need libvirt, but in RHEV@RHEL5 there should not be libvirt
 # as there is vdsm and bunch of other packages, but we have no clue how to
@@ -51,7 +60,9 @@ that is specific to the Host system (a.k.a. Dom0).
 
 %prep
 %setup -q
-
+%if 0%{?suse_version}
+cp scripts/rhn-virtualization-host.SUSE scripts/rhn-virtualization-host
+%endif
 
 %build
 make -f Makefile.rhn-virtualization
@@ -59,25 +70,35 @@ make -f Makefile.rhn-virtualization
 
 %install
 rm -rf $RPM_BUILD_ROOT
-make -f Makefile.rhn-virtualization DESTDIR=$RPM_BUILD_ROOT install
+make -f Makefile.rhn-virtualization DESTDIR=$RPM_BUILD_ROOT PKGDIR0=%{_initrddir} install
+
 
- 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 
 %post host
 /sbin/chkconfig --add rhn-virtualization-host
+%if 0%{?suse_version}
+/sbin/service cron try-restart ||:
+%else
 /sbin/service crond condrestart
+%endif
 
 %preun host
 /sbin/chkconfig --del rhn-virtualization-host
 
 %postun host
+%if 0%{?suse_version}
+/sbin/service cron try-restart ||:
+%else
 /sbin/service crond condrestart
+%endif
 
 %files common
 %defattr(-,root,root,-)
+%dir %{rhn_dir}
+%dir %{rhn_dir}/actions
 %dir %{rhn_dir}/virtualization
 %{rhn_dir}/virtualization/__init__.py
 %{rhn_dir}/virtualization/__init__.pyc
@@ -101,6 +122,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %files host
 %defattr(-,root,root,-)
+%dir %{rhn_conf_dir}
 %dir %{rhn_conf_dir}/virt
 %dir %{rhn_conf_dir}/virt/auto
 %{_initrddir}/rhn-virtualization-host
diff --git a/client/tools/rhn-virtualization/scripts/rhn-virtualization-host.SUSE b/client/tools/rhn-virtualization/scripts/rhn-virtualization-host.SUSE
new file mode 100755
index 0000000..da66d86
--- /dev/null
+++ b/client/tools/rhn-virtualization/scripts/rhn-virtualization-host.SUSE
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides:       rhn-virtualization-host
+# Required-Start: $network $syslog $remote_fs
+# Required-Stop:  $network $syslog $remote_fs
+# Default-Start:  3 5
+# Default-Stop: 0 1 6
+# Short-Description: Starts up xen domains when the host boots.
+# Description:    Starts up xen domains when the host boots.
+### END INIT INFO
+
+# chkconfig: 2345 99 99
+# description: Starts up xen domains when the host boots.
+
+. /etc/rc.status
+
+auto_dir="/etc/sysconfig/rhn/virt/auto"
+py_path="/usr/share/rhn:/usr/share/rhn/virtualization"
+script_path="/usr/share/rhn/virtualization"
+get_config_value="PYTHONPATH=$py_path python $script_path/get_config_value.py"
+get_uuid="$get_config_value uuid"
+get_name="$get_config_value name"
+init_action="PYTHONPATH=$py_path python $script_path/init_action.py"
+start_action="$init_action start"
+stop_action="$init_action shutdown"
+
+if [ -d $auto_dir ]; then
+    list_of_files=$(ls $auto_dir)
+else
+    list_of_files=
+fi
+
+start() {
+   echo -n "Starting Managed Xen Domains:"
+   for NAME in $list_of_files; do
+        dom_uuid=$(eval $get_uuid $auto_dir/$NAME)
+        eval $start_action $dom_uuid > /dev/null 2>&1
+        if [ $? -ne 0 ]; then
+            rc_check
+        fi
+    done
+
+    touch /var/lock/subsys/rhn-virtualization
+    rc_status -v
+}
+
+stop() {
+    echo -n "Stopping Managed Xen Domains:"
+    for NAME in $list_of_files; do
+        dom_uuid=$(eval $get_uuid $auto_dir/$NAME)
+        eval $stop_action $dom_uuid > /dev/null 2>&1
+        if [ $? -ne 0 ]; then
+            rc_check
+        fi
+    done
+
+    rm -f /var/lock/subsys/rhn-virtualization
+    rc_status -v
+}
+
+status() {
+    found_guests=0
+
+    for NAME in $list_of_files; do
+        found_guests=1
+        dom_name=$(eval $get_name $auto_dir/$NAME)
+        dom_state=$(virsh domstate $dom_name 2> /dev/null)
+
+        if [ $? -eq 0 ]; then
+            echo "$dom_name: $dom_state"
+        else
+            echo "Error getting the status for $dom_name."
+            rc_check
+        fi
+    done
+
+    if [ $found_guests -eq 0 ]; then
+        echo "No guest configurations symlinked in $auto_dir."
+    fi
+
+    rc_status -v
+}
+
+
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    restart)
+        stop
+        start
+        ;;
+    reload)
+        stop
+        start
+        ;;
+    condrestart|try-restart)
+        if [ -f /var/lock/subsys/rhn-virtualization ]; then
+            stop
+	    start
+	fi
+        ;;
+    status)
+        status
+        ;;
+    *)
+        echo "Usage: service rhn-virtualization [start|stop|restart|condrestart|try-restart|reload|status]"
+        ;;
+esac
-- 
1.7.3.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to