[Ovirt-devel] [PATCH node] Add collectd and libvirt-qpid setup to ovirt-install-node

Perry Myers pmyers at redhat.com
Tue Oct 14 18:28:33 UTC 2008


This patch adds setup for libvirt-qpid and collectd to
the ovirt-install-node script so that they will both work
in stateful setup.

Signed-off-by: Ian Main <imain at redhat.com>
Signed-off-by: Perry Myers <pmyers at redhat.com>
---
 ovirt-listen-awake/ovirt-install-node   |   28 ++++++++++++++++++++++++----
 ovirt-listen-awake/ovirt-uninstall-node |    4 +++-
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/ovirt-listen-awake/ovirt-install-node b/ovirt-listen-awake/ovirt-install-node
index a4a4b6f..95ba4de 100644
--- a/ovirt-listen-awake/ovirt-install-node
+++ b/ovirt-listen-awake/ovirt-install-node
@@ -28,7 +28,7 @@ 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}"
+    test -f "$1" && cp -pf "$1" "$OVIRT_BACKUP_DIR/${dir:1}"
 }
 
 add_if_not_exist() {
@@ -103,12 +103,31 @@ elif [ "$1" = "stateful" ]; then
     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
 
     backup_file /etc/sysconfig/libvirtd
     backup_file /etc/libvirt/qemu.conf
@@ -125,9 +144,6 @@ elif [ "$1" = "stateful" ]; then
     # 49152-49216:tcp (libvirt migration)
     lokkit -t ovirtbr0
 
-    service collectd restart
-    service ovirt-listen-awake 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
@@ -139,6 +155,10 @@ elif [ "$1" = "stateful" ]; then
     else
         service libvirtd restart
     fi
+
+    service collectd restart
+    service ovirt-listen-awake restart
+    service libvirt-qpid restart
 else
     usage
     exit 1
diff --git a/ovirt-listen-awake/ovirt-uninstall-node b/ovirt-listen-awake/ovirt-uninstall-node
index 3e4d300..1046a37 100644
--- a/ovirt-listen-awake/ovirt-uninstall-node
+++ b/ovirt-listen-awake/ovirt-uninstall-node
@@ -25,7 +25,7 @@ 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"
+    test -f "$OVIRT_BACKUP_DIR$1" && cp -pf "$OVIRT_BACKUP_DIR$1" "$1"
 }
 
 chkconfig ovirt-listen-awake off
@@ -39,4 +39,6 @@ unbackup_file /etc/libvirt/libvirtd.conf
 unbackup_file /etc/sasl2/libvirt.conf
 unbackup_file /etc/sysconfig/iptables
 unbackup_file /etc/krb5.conf
+unbackup_file /etc/collectd.conf
+unbackup_file /etc/sysconfig/libvirt-qpid
 rm -Rf $OVIRT_BACKUP_DIR
-- 
1.5.5.1




More information about the ovirt-devel mailing list