[Ovirt-devel] [PATCH node] Created stateful and stateless subpackages used for installing on bare metal Fedora hosts
Perry Myers
pmyers at redhat.com
Fri Dec 12 02:13:49 UTC 2008
ovirt-node-stateless is for use on the embedded oVirt Node.
ovirt-node-stateful is for use on already installed Fedora hosts to configure
that host to act as a Node. Presently it only works when run on the same
host as the oVirt Appliance.
ovirt-node RPM provides common binaries/scripts used by the subpackages
Splitting up the RPMs is required since ovirt-node RPM now packages up
gptsync which conflicts with anaconda.
Signed-off-by: Perry Myers <pmyers at redhat.com>
---
Makefile.am | 3 +
ovirt-listen-awake/Makefile.am | 2 +-
ovirt-listen-awake/ovirt-install-node | 177 --------------------
ovirt-node.spec.in | 73 +++++++--
scripts/ovirt-functions | 15 ++
scripts/ovirt-install-node-stateful | 113 +++++++++++++
scripts/ovirt-install-node-stateless | 52 ++++++
.../ovirt-uninstall-node-stateful | 0
8 files changed, 245 insertions(+), 190 deletions(-)
delete mode 100755 ovirt-listen-awake/ovirt-install-node
create mode 100755 scripts/ovirt-install-node-stateful
create mode 100755 scripts/ovirt-install-node-stateless
rename ovirt-listen-awake/ovirt-uninstall-node => scripts/ovirt-uninstall-node-stateful (100%)
diff --git a/Makefile.am b/Makefile.am
index 9b54ae6..a47beaa 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,8 +35,11 @@ EXTRA_DIST = \
scripts/ovirt-early \
scripts/ovirt-firstboot \
scripts/ovirt-functions \
+ scripts/ovirt-install-node-stateful \
+ scripts/ovirt-install-node-stateless \
scripts/ovirt-post \
scripts/ovirt-process-config \
+ scripts/ovirt-uninstall-node-stateful \
logrotate/ovirt-logrotate \
logrotate/ovirt-logrotate.conf
diff --git a/ovirt-listen-awake/Makefile.am b/ovirt-listen-awake/Makefile.am
index 05cb85b..783f15c 100644
--- a/ovirt-listen-awake/Makefile.am
+++ b/ovirt-listen-awake/Makefile.am
@@ -17,6 +17,6 @@
bin_PROGRAMS = ovirt-listen-awake
-EXTRA_DIST = ovirt-listen-awake.init ovirt-install-node ovirt-uninstall-node
+EXTRA_DIST = ovirt-listen-awake.init
ovirt_listen_awake_SOURCES = ovirt-listen-awake.c
diff --git a/ovirt-listen-awake/ovirt-install-node b/ovirt-listen-awake/ovirt-install-node
deleted file mode 100755
index d65816f..0000000
--- a/ovirt-listen-awake/ovirt-install-node
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/bash
-
-PHYS_HOST=physical.priv.ovirt.org
-MGMT_HOST=management.priv.ovirt.org
-
-. /etc/init.d/ovirt-functions
-
-PATH=$PATH:/sbin:/usr/sbin
-ME=$(basename "$0")
-warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
-die() { warn "$@"; exit 1; }
-
-usage() {
- echo "Usage: $ME <stateless|stateful>"
-}
-
-# first, check to see we are root
-if [ $( id -u ) -ne 0 ]; then
- die "Must run as root"
-fi
-
-if [ $# -ne 1 ]; then
- usage
- 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}"
- test -f "$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"
-}
-
-if [ "$1" = "stateless" ]; then
- chkconfig --level 3 ovirt-early on
- chkconfig --level 3 ovirt on
- chkconfig --level 3 ovirt-post on
- chkconfig --level 3 collectd on
-
- ovirt_setup_libvirtd
-
- # make sure we don't autostart virbr0 on libvirtd startup
- rm -f /etc/libvirt/qemu/networks/autostart/default.xml
-
- # remove the /etc/krb5.conf file; it will be fetched on bootup
- rm -f /etc/krb5.conf
-
- g=$(printf '\33[1m\33[32m') # similar to g=$(tput bold; tput setaf 2)
- n=$(printf '\33[m') # similar to n=$(tput sgr0)
- version=$(rpm -q --qf '%{version}' ovirt-node)
- release=$(rpm -q --qf '%{release}' ovirt-node)
- cat <<EOF > /etc/issue
-
- 888 888 ${g}d8b$n 888
- 888 888 ${g}Y8P$n 888
- 888 888 888
- .d88b. Y88b d88P 888 888d888 888888
- d88''88b Y88b d88P 888 888P' 888
- 888 888 Y88o88P 888 888 888
- Y88..88P Y888P 888 888 Y88b.
- 'Y88P' Y8P 888 888 'Y888
-
- oVirt Node release ${version}-${release}
-
- Virtualization just got the ${g}Green Light$n
-
-EOF
- cp -p /etc/issue /etc/issue.net
-elif [ "$1" = "stateful" ]; then
- echo "This script will make a number of changes to your system to enable it"
- echo "to work as an oVirt node. You can later undo these changes by"
- echo "running /usr/sbin/ovirt-uninstall-host. Do you want to proceed? [y/N]?"
- read yesno
-
- if [ "$yesno" != "y" -a "$yesno" != "Y" ]; then
- exit 2
- fi
-
- # Always try to uninstall first, that way the original pristine files are
- # in place before re-installing, this prevents OVIRT_BACKUP_DIR from
- # being overwritten with an older version of the node config files
- ovirt-uninstall-node > /dev/null 2>&1
-
- # Remove old keytab if it exists in case we have a new appliance to work with
- rm -f /etc/libvirt/krb5.tab
-
- rm -Rf $OVIRT_BACKUP_DIR
- mkdir -p $OVIRT_BACKUP_DIR
-
- backup_file /etc/sysconfig/network
- if grep "^HOSTNAME=" /etc/sysconfig/network > /dev/null 2>&1 ; then
- sed -i -e "s/^HOSTNAME=.*/HOSTNAME=$PHYS_HOST/" /etc/sysconfig/network
- else
- echo "HOSTNAME=$PHYS_HOST" >> /etc/sysconfig/network
- fi
- hostname $PHYS_HOST
-
- collectd_conf=/etc/collectd.conf
- backup_file $collectd_conf
- if [ -f $collectd_conf.in ]; then
- sed -e "s/@COLLECTD_SERVER@/$MGMT_HOST/" \
- -e "s/@COLLECTD_PORT@/25826/" $collectd_conf.in \
- > $collectd_conf
- fi
-
- libvirt_qpid_conf=/etc/sysconfig/libvirt-qpid
- backup_file $libvirt_qpid_conf
- if [ -f $libvirt_qpid_conf ]; then
- if grep "^LIBVIRT_QPID_ARGS=" $libvirt_qpid_conf > /dev/null 2>&1 ; then
- sed -i -e "s/^LIBVIRT_QPID_ARGS=.*/LIBVIRT_QPID_ARGS=\"--broker $MGMT_HOST --port 5672\"/" $libvirt_qpid_conf
- else
- echo "LIBVIRT_QPID_ARGS=\"--broker $MGMT_HOST --port 5672\"" >> $libvirt_qpid_conf
- fi
- fi
-
- backup_file /etc/hosts
- add_if_not_exist "192.168.50.1 $PHYS_HOST" /etc/hosts
- add_if_not_exist "192.168.50.2 $MGMT_HOST" /etc/hosts
-
- chkconfig ovirt-listen-awake on
- chkconfig ovirt-early off
- chkconfig ovirt off
- chkconfig ovirt-post off
- chkconfig ovirt-firstboot off
- chkconfig collectd on
- chkconfig libvirt-qpid on
- chkconfig iptables on
- chkconfig ntpdate on
- chkconfig ntpd on
-
- backup_file /etc/sysconfig/libvirtd
- backup_file /etc/libvirt/qemu.conf
- backup_file /etc/libvirt/libvirtd.conf
- backup_file /etc/sasl2/libvirt.conf
- backup_file /etc/krb5.conf
- ovirt_setup_libvirtd
-
- backup_file /etc/sysconfig/iptables
- # We open up anything coming from ovirtbr0 to this node, since it
- # is only intended for demo purposes. For reference, here are the
- # ports that need to be opened:
- # 7777:tcp (ovirt-listen-awake), 16509:tcp (libvirtd), 5900-6000:tcp (vnc),
- # 49152-49216:tcp (libvirt migration)
- lokkit -q -t ovirtbr0
-
- service iptables restart
-
- # Check if any domains are active before restarting libvirtd, since it will
- # kill them. Header information from virsh list is 2 lines, and 1 line for
- # footer. So > 3 lines means domains are running
- running_domains=$(( $(virsh -c qemu:///system list 2> /dev/null | wc -l) - 3 ))
- if [ $running_domains -gt 0 ]; then
- echo "Cannot restart libvirtd because domains are active."
- echo "Please shutdown all domains and restart libvirtd with:"
- echo "service libvirtd restart"
- else
- service libvirtd restart
- fi
-
- service collectd restart
- service ovirt-listen-awake restart
- service libvirt-qpid restart
- service ntpd stop
- service ntpdate start
- service ntpd start
-else
- usage
- exit 1
-fi
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index ef65bf0..59d9939 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -42,7 +42,29 @@ ExclusiveArch: %{ix86} x86_64
%description
Provides a series of daemons and support utilities to allow an
-oVirt Node to interact with the oVirt server.
+oVirt Node to interact with the oVirt Server.
+
+%package stateless
+Summary: oVirt Node for running as embedded hypervisor
+Group: Applications/System
+Requires: %{name} = %{version}-%{release}
+ExclusiveArch: %{ix86} x86_64
+
+%description stateless
+Provides the oVirt Node functionality needed as part of the
+ovirt-node-image creation. This provides a stateless oVirt Node
+that runs as a livecd.
+
+%package stateful
+Summary: oVirt Node for running on Fedora Hosts
+Group: Applications/System
+Requires: %{name} = %{version}-%{release}
+ExclusiveArch: %{ix86} x86_64
+
+%description stateful
+Provides the oVirt Node functionality needed to convert an existing
+host into a Node in a stateful manner. Presently intended for use on
+the host running the oVirt Appliance.
%package selinux
Summary: SELinux policy module supporting ovirt-node
@@ -93,11 +115,12 @@ cd -
%{__install} -p -m0755 scripts/ovirt-config-setup %{buildroot}%{_sbindir}
%{__install} -p -m0755 scripts/ovirt-config-storage %{buildroot}%{_sbindir}
%{__install} -p -m0755 scripts/ovirt-process-config %{buildroot}%{_sbindir}
+%{__install} -D -m0755 scripts/ovirt-install-node-stateful %{buildroot}%{_sbindir}
+%{__install} -D -m0755 scripts/ovirt-install-node-stateless %{buildroot}%{_sbindir}
+%{__install} -D -m0755 scripts/ovirt-uninstall-node-stateful %{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-install-node %{buildroot}%{_sbindir}
-%{__install} -Dp -m0755 ovirt-listen-awake/ovirt-uninstall-node %{buildroot}%{_sbindir}
# gptsync
%{__install} -p -m0755 gptsync/gptsync %{buildroot}%{_sbindir}
@@ -131,7 +154,7 @@ cd -
%clean
%{__rm} -rf %{buildroot}
-%post
+%post stateless
/sbin/chkconfig --add ovirt-early
/sbin/chkconfig --add ovirt-firstboot
/sbin/chkconfig --add ovirt
@@ -140,14 +163,29 @@ cd -
# /etc/chkconfig.d/collectd file, and then have to re-define collectd here
/sbin/chkconfig --add collectd
/sbin/chkconfig --add ovirt-listen-awake
+/bin/ln -sf %{_sbindir}/ovirt-install-node-stateless %{_sbindir}/ovirt-install-node
-%preun
+%preun stateless
if [ "$1" = 0 ] ; then
/sbin/chkconfig --del ovirt-early
/sbin/chkconfig --del ovirt-firstboot
/sbin/chkconfig --del ovirt
/sbin/chkconfig --del ovirt-post
/sbin/chkconfig --del ovirt-listen-awake
+ rm -f %{_sbindir}/ovirt-install-node
+fi
+
+%post stateful
+/sbin/chkconfig --add collectd
+/sbin/chkconfig --add ovirt-listen-awake
+/bin/ln -sf %{_sbindir}/ovirt-install-node-stateful %{_sbindir}/ovirt-install-node
+/bin/ln -sf %{_sbindir}/ovirt-uninstall-node-stateful %{_sbindir}/ovirt-uninstall-node
+
+%preun stateful
+if [ "$1" = 0 ] ; then
+ /sbin/chkconfig --del ovirt-listen-awake
+ rm -f %{_sbindir}/ovirt-install-node
+ rm -f %{_sbindir}/ovirt-uninstall-node
fi
%post selinux
@@ -168,28 +206,35 @@ fi
%doc SELinux/*
%{_datadir}/selinux/*/%{modulename}.pp
-%files
+%files stateless
%defattr(-,root,root,0755)
-%{_sbindir}/ovirt-awake
%{_sbindir}/ovirt-config-logging
%{_sbindir}/ovirt-config-networking
%{_sbindir}/ovirt-config-password
%{_sbindir}/ovirt-config-setup
%{_sbindir}/ovirt-config-storage
%{_sbindir}/ovirt-process-config
-%{_sbindir}/ovirt-identify-node
-%{_sbindir}/ovirt-listen-awake
-%{_sbindir}/ovirt-install-node
-%{_sbindir}/ovirt-uninstall-node
+%{_sbindir}/ovirt-install-node-stateless
%{_sbindir}/gptsync
%{_sbindir}/showpart
%{_initrddir}/ovirt-early
%{_initrddir}/ovirt-firstboot
%{_initrddir}/ovirt
%{_initrddir}/ovirt-post
-%{_initrddir}/ovirt-listen-awake
%config %{_sysconfdir}/logrotate.d/ovirt-logrotate.conf
%config %{_sysconfdir}/cron.hourly/ovirt-logrotate
+
+%files stateful
+%defattr(-,root,root,0755)
+%{_sbindir}/ovirt-listen-awake
+%{_sbindir}/ovirt-install-node-stateful
+%{_sbindir}/ovirt-uninstall-node-stateful
+%{_initrddir}/ovirt-listen-awake
+
+%files
+%defattr(-,root,root,0755)
+%{_sbindir}/ovirt-awake
+%{_sbindir}/ovirt-identify-node
%defattr(-,root,root,0644)
%{_initrddir}/ovirt-functions
%{_sysconfdir}/collectd.conf.in
@@ -200,6 +245,10 @@ fi
%doc ovirt-identify-node/COPYING
%changelog
+* Thu Dec 11 2008 Perry Myers <pmyers at redhat.com> - 0.96
+- Subpackage stateful/stateless to separate out functionality for
+ embedded Node and Node running as part of already installed OS
+
* Thu Sep 11 2008 Chris Lalancette <clalance at redhat.com> - 0.92 0.7
- Add the ovirt-install- and ovirt-uninstall-node scripts, and refactor
post to accomodate
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index c6a8504..271e173 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -131,3 +131,18 @@ ovirt_store_config() {
echo
umount $ovirt && rmdir $ovirt
}
+
+backup_file() {
+ dir=$(dirname "$1")
+ case $dir in /*);; *) die "unexpected non-absolute dir: $dir";; esac
+ mkdir -p "$OVIRT_BACKUP_DIR/${dir:1}"
+ test -f "$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"
+}
diff --git a/scripts/ovirt-install-node-stateful b/scripts/ovirt-install-node-stateful
new file mode 100755
index 0000000..3ec1c29
--- /dev/null
+++ b/scripts/ovirt-install-node-stateful
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+PHYS_HOST=physical.priv.ovirt.org
+MGMT_HOST=management.priv.ovirt.org
+
+. /etc/init.d/ovirt-functions
+
+PATH=$PATH:/sbin:/usr/sbin
+ME=$(basename "$0")
+warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
+die() { warn "$@"; exit 1; }
+
+usage() {
+ echo "Usage: $ME"
+}
+
+# first, check to see we are root
+if [ $( id -u ) -ne 0 ]; then
+ die "Must run as root"
+fi
+
+echo "This script will make a number of changes to your system to enable it"
+echo "to work as an oVirt node. You can later undo these changes by"
+echo "running /usr/sbin/ovirt-uninstall-host. Do you want to proceed? [y/N]?"
+read yesno
+
+if [ "$yesno" != "y" -a "$yesno" != "Y" ]; then
+ exit 2
+fi
+
+# Always try to uninstall first, that way the original pristine files are
+# in place before re-installing, this prevents OVIRT_BACKUP_DIR from
+# being overwritten with an older version of the node config files
+ovirt-uninstall-node > /dev/null 2>&1
+
+# Remove old keytab if it exists in case we have a new appliance to work with
+rm -f /etc/libvirt/krb5.tab
+
+rm -Rf $OVIRT_BACKUP_DIR
+mkdir -p $OVIRT_BACKUP_DIR
+
+backup_file /etc/sysconfig/network
+if grep "^HOSTNAME=" /etc/sysconfig/network > /dev/null 2>&1 ; then
+ sed -i -e "s/^HOSTNAME=.*/HOSTNAME=$PHYS_HOST/" /etc/sysconfig/network
+else
+ echo "HOSTNAME=$PHYS_HOST" >> /etc/sysconfig/network
+fi
+hostname $PHYS_HOST
+
+collectd_conf=/etc/collectd.conf
+backup_file $collectd_conf
+if [ -f $collectd_conf.in ]; then
+ sed -e "s/@COLLECTD_SERVER@/$MGMT_HOST/" \
+ -e "s/@COLLECTD_PORT@/25826/" $collectd_conf.in \
+ > $collectd_conf
+fi
+
+libvirt_qpid_conf=/etc/sysconfig/libvirt-qpid
+backup_file $libvirt_qpid_conf
+if [ -f $libvirt_qpid_conf ]; then
+ if grep "^LIBVIRT_QPID_ARGS=" $libvirt_qpid_conf > /dev/null 2>&1 ; then
+ sed -i -e "s/^LIBVIRT_QPID_ARGS=.*/LIBVIRT_QPID_ARGS=\"--broker $MGMT_HOST --port 5672\"/" $libvirt_qpid_conf
+ else
+ echo "LIBVIRT_QPID_ARGS=\"--broker $MGMT_HOST --port 5672\"" >> $libvirt_qpid_conf
+ fi
+fi
+
+backup_file /etc/hosts
+add_if_not_exist "192.168.50.1 $PHYS_HOST" /etc/hosts
+add_if_not_exist "192.168.50.2 $MGMT_HOST" /etc/hosts
+
+chkconfig ovirt-listen-awake on
+chkconfig collectd on
+chkconfig libvirt-qpid on
+chkconfig iptables on
+chkconfig ntpdate on
+chkconfig ntpd on
+
+backup_file /etc/sysconfig/libvirtd
+backup_file /etc/libvirt/qemu.conf
+backup_file /etc/libvirt/libvirtd.conf
+backup_file /etc/sasl2/libvirt.conf
+backup_file /etc/krb5.conf
+ovirt_setup_libvirtd
+
+backup_file /etc/sysconfig/iptables
+# We open up anything coming from ovirtbr0 to this node, since it
+# is only intended for demo purposes. For reference, here are the
+# ports that need to be opened:
+# 7777:tcp (ovirt-listen-awake), 16509:tcp (libvirtd), 5900-6000:tcp (vnc),
+# 49152-49216:tcp (libvirt migration)
+lokkit -q -t ovirtbr0
+
+service iptables restart
+
+# Check if any domains are active before restarting libvirtd, since it will
+# kill them. Header information from virsh list is 2 lines, and 1 line for
+# footer. So > 3 lines means domains are running
+running_domains=$(( $(virsh -c qemu:///system list 2> /dev/null | wc -l) - 3 ))
+if [ $running_domains -gt 0 ]; then
+ echo "Cannot restart libvirtd because domains are active."
+ echo "Please shutdown all domains and restart libvirtd with:"
+ echo "service libvirtd restart"
+else
+ service libvirtd restart
+fi
+
+service collectd restart
+service ovirt-listen-awake restart
+service libvirt-qpid restart
+service ntpd stop
+service ntpdate start
+service ntpd start
diff --git a/scripts/ovirt-install-node-stateless b/scripts/ovirt-install-node-stateless
new file mode 100755
index 0000000..e7b36d4
--- /dev/null
+++ b/scripts/ovirt-install-node-stateless
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+. /etc/init.d/ovirt-functions
+
+PATH=$PATH:/sbin:/usr/sbin
+ME=$(basename "$0")
+warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
+die() { warn "$@"; exit 1; }
+
+usage() {
+ echo "Usage: $ME"
+}
+
+# first, check to see we are root
+if [ $( id -u ) -ne 0 ]; then
+ die "Must run as root"
+fi
+
+chkconfig --level 3 ovirt-early on
+chkconfig --level 3 ovirt on
+chkconfig --level 3 ovirt-post on
+chkconfig --level 3 collectd on
+
+ovirt_setup_libvirtd
+
+# make sure we don't autostart virbr0 on libvirtd startup
+rm -f /etc/libvirt/qemu/networks/autostart/default.xml
+
+# remove the /etc/krb5.conf file; it will be fetched on bootup
+rm -f /etc/krb5.conf
+
+g=$(printf '\33[1m\33[32m') # similar to g=$(tput bold; tput setaf 2)
+n=$(printf '\33[m') # similar to n=$(tput sgr0)
+version=$(rpm -q --qf '%{version}' ovirt-node)
+release=$(rpm -q --qf '%{release}' ovirt-node)
+cat <<EOF > /etc/issue
+
+ 888 888 ${g}d8b$n 888
+ 888 888 ${g}Y8P$n 888
+ 888 888 888
+ .d88b. Y88b d88P 888 888d888 888888
+ d88''88b Y88b d88P 888 888P' 888
+ 888 888 Y88o88P 888 888 888
+ Y88..88P Y888P 888 888 Y88b.
+ 'Y88P' Y8P 888 888 'Y888
+
+ oVirt Node release ${version}-${release}
+
+ Virtualization just got the ${g}Green Light$n
+
+EOF
+cp -p /etc/issue /etc/issue.net
diff --git a/ovirt-listen-awake/ovirt-uninstall-node b/scripts/ovirt-uninstall-node-stateful
similarity index 100%
rename from ovirt-listen-awake/ovirt-uninstall-node
rename to scripts/ovirt-uninstall-node-stateful
--
1.6.0.4
More information about the ovirt-devel
mailing list