summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2015-11-16 18:54:23 +0100
committerDominique Martinet <asmadeus@codewreck.org>2016-01-19 18:05:53 +0100
commit58bbe76f26e9fdb1ceccb5d5ce12c502dd9ca12e (patch)
tree2d55487c3b1042afe5efa4eed0d4ff1760397b29
parent9086ab023019c2667c390cf09db491346e10d5f5 (diff)
CEA stuff - fix better later (sorry..)
-rwxr-xr-xbootstrap/cobbler/bootstrap.sh5
-rw-r--r--kvm-cluster.conf14
-rwxr-xr-xkvm-wrapper.sh32
-rwxr-xr-xstartup/kvm-wrapper-startup-rhel.sh85
-rwxr-xr-xstartup/kvm-wrapper-startup.sh12
5 files changed, 125 insertions, 23 deletions
diff --git a/bootstrap/cobbler/bootstrap.sh b/bootstrap/cobbler/bootstrap.sh
index 0f50a9b..a51cd49 100755
--- a/bootstrap/cobbler/bootstrap.sh
+++ b/bootstrap/cobbler/bootstrap.sh
@@ -22,7 +22,7 @@ function bootstrap_fs()
;;
esac
- local COBBLER_OPTS="--name $VM_NAME --netboot-enabled 1 --hostname $VM_NAME.$BOOTSTRAP_DOMAIN --interface eth0 --dns-name $VM_NAME.$BOOTSTRAP_DOMAIN --ip-address $BOOTSTRAP_NET_ADDR --netmask $BOOTSTRAP_NET_MASK --gateway $BOOTSTRAP_NET_GW --mac-address=${KVM_MACADDR[0]} --mtu $BOOTSTRAP_MTU --profile $BOOTSTRAP_FLAVOR --kopts=modprobe.blacklist=cirrus,drm,ttm,drm_kms_helper"
+ local COBBLER_OPTS="--name $VM_NAME --netboot-enabled 1 --hostname $VM_NAME.$BOOTSTRAP_DOMAIN --interface eth0 --dns-name $VM_NAME.$BOOTSTRAP_DOMAIN --ip-address $BOOTSTRAP_NET_ADDR --netmask $BOOTSTRAP_NET_MASK --gateway $BOOTSTRAP_NET_GW --mac-address=${KVM_MACADDR[0]} --mtu $BOOTSTRAP_MTU --profile $BOOTSTRAP_FLAVOR --kopts=modprobe.blacklist=cirrus,drm,ttm,drm_kms_helper --ksmeta='disk=vda'"
[[ -n "$BOOTSTRAP_KICKSTART" ]] && COBBLER_OPTS+=" -kickstart $BOOTSTRAP_KICKSTART"
if cobbler system list | grep -q -E '^ *'"$VM_NAME"'$'; then
@@ -35,8 +35,7 @@ function bootstrap_fs()
# Start VM to bootstrap
desc_update_setting "KVM_IF[0]" "virtio-net-pci"
desc_update_setting "KVM_NET_OPT[0]" ",vhost=on"
- test_blockdev "${KVM_DISK[0]}" \
- && desc_update_setting "KVM_DISK_IF[0]" "virtio-blk-pci,scsi=off"
+ desc_update_setting "KVM_DISK_IF[0]" "virtio-blk-pci,scsi=off"
desc_update_setting "KVM_BOOTDEVICE" "-boot order=n"
diff --git a/kvm-cluster.conf b/kvm-cluster.conf
index bab6791..cac4de7 100644
--- a/kvm-cluster.conf
+++ b/kvm-cluster.conf
@@ -1,6 +1,16 @@
#set_cluster_host `hostname -s` "ip or fqdn"
-set_cluster_host `hostname -s` "localhost"
+set_cluster_host fleury0 fleury0
+set_cluster_host fleury1 fleury1
+set_cluster_host fleury2 fleury2
+set_cluster_host fleury5 fleury5
+set_cluster_host fleury6 fleury6
+set_cluster_host fleury7 fleury7
+set_cluster_host fleury8 fleury8
+set_cluster_host fleury9 fleury9
+set_cluster_host fleury17 fleury17
+set_cluster_host fleury19 fleury19
+set_cluster_host fleury21 fleury21
SSH_OPTS="-t"
-KVM_CLUSTER_IDENT="$ROOTDIR/host_config/cluster-id_dsa"
+KVM_CLUSTER_IDENT="/root/.ssh/id_rsa"
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 20a458c..7f089e3 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -537,6 +537,11 @@ function monitor_send_cmd ()
echo "$1" | socat STDIN unix:"$MONITOR_FILE"
}
+function monitor_send_cmd_read ()
+{
+ echo "$1" | socat - unix:"$MONITOR_FILE"
+}
+
function monitor_send_sysrq ()
{
local SYSRQ="$1"
@@ -1003,18 +1008,18 @@ function kvm_bootstrap_vm ()
prepare_disks
CLEANUP+=("unprepare_disks")
- if ! test_blockdev "${KVM_DISK[0]}"
- then
- require_exec "$KVM_NBD_BIN"
- test_file "${KVM_DISK[0]}" || fail_exit "\"${KVM_DISK[0]}\" appears to be neither a blockdev nor a regular file."
- echo "Attempting to connect the disk image to an nbd device."
- kvm_nbd_connect "${KVM_DISK[0]}"
- CLEANUP+=("kvm_nbd_disconnect \"${KVM_DISK[0]}\"")
- local BOOTSTRAP_DEVICE=$(nbd_img_link "${KVM_DISK[0]}")
- sleep 1 #needed to give time to the nbd to really connect
- else
+# if ! test_blockdev "${KVM_DISK[0]}"
+# then
+# require_exec "$KVM_NBD_BIN"
+# test_file "${KVM_DISK[0]}" || fail_exit "\"${KVM_DISK[0]}\" appears to be neither a blockdev nor a regular file."
+# echo "Attempting to connect the disk image to an nbd device."
+# kvm_nbd_connect "${KVM_DISK[0]}"
+# CLEANUP+=("kvm_nbd_disconnect \"${KVM_DISK[0]}\"")
+# local BOOTSTRAP_DEVICE=$(nbd_img_link "${KVM_DISK[0]}")
+# sleep 1 #needed to give time to the nbd to really connect
+# else
local BOOTSTRAP_DEVICE="${KVM_DISK[0]}"
- fi
+# fi
echo "Starting to bootstrap $VM_NAME as $BOOTSTRAP_DISTRIB on disk $BOOTSTRAP_DEVICE"
bootstrap_fs "$BOOTSTRAP_DEVICE"
@@ -1188,10 +1193,13 @@ function kvm_build_vm ()
lvm_create_disk "$VM_NAME"
fi
if [[ -z "$DISABLE_BOOTSTRAP" ]]; then
+ # PREBOOTSTRAP_SCRIPT="$BOOTSTRAP_DIR/$BOOTSTRAP_DISTRIB/prebootstrap.sh"
+ # test_file "$PREBOOTSTRAP_SCRIPT" && source "$PREBOOTSTRAP_SCRIPT" && prebootstrap
+
kvm_bootstrap_vm "$VM_NAME"
echo "Will now start VM $VM_NAME"
- kvm_start_screen "$VM_NAME"
+ "$SCRIPT_PATH" start "$VM_NAME"
else
echo "VM created."
fi
diff --git a/startup/kvm-wrapper-startup-rhel.sh b/startup/kvm-wrapper-startup-rhel.sh
new file mode 100755
index 0000000..06cb143
--- /dev/null
+++ b/startup/kvm-wrapper-startup-rhel.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides: kvm-wrapper
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: kcm-wrapper init script
+# Description: This script starts a list of VMs and stops the running
+# ones when asked to
+### END INIT INFO
+
+# -- bencoh, 2009/08/11
+# -- Asmadeus, 2011/06
+
+SCRIPTNAME=/etc/init.d/kvm-wrapper
+
+. /etc/init.d/functions
+
+KVM_WRAPPER_DIR=/ccc/admin/vm/kvm-wrapper
+KVM_WRAPPER="$KVM_WRAPPER_DIR"/kvm-wrapper.sh
+KVM_VM_LIST="$KVM_WRAPPER_DIR"/startup/startup-list
+
+start_vm()
+{
+ VM_NAME="$1"
+ action $KVM_WRAPPER screen "$VM_NAME"
+}
+
+stop_vm ()
+{
+ VM_NAME="$1"
+ action "$KVM_WRAPPER" stop "$VM_NAME"
+}
+
+do_start()
+{
+if [[ ! -f $KVM_WRAPPER ]]; then
+ echo "Mounting $KVM_WRAPPER_DIR since it doesn't seem here"
+ echo
+ mount $KVM_WRAPPER
+ sleep 3
+fi
+
+echo "cleaning old pid files for `hostname -s`"
+rm -vf $KVM_WRAPPER_DIR/run/`hostname -s`*
+
+grep -E -v '^#' "$KVM_VM_LIST" |
+while read line
+do
+ grep -E "^KVM_CLUSTER_NODE=\"?`hostname -s`" $KVM_WRAPPER_DIR/vm/$line-vm >&/dev/null && \
+ start_vm "$line"
+done
+}
+
+do_stop()
+{
+"$KVM_WRAPPER" list|grep -E "Running\ton (`hostname -s`|local)"|awk '{print $1}'|
+while read line
+do
+ stop_vm "$line"
+done
+}
+
+case "$1" in
+ start)
+ echo "Autostarting VMs (kvm-wrapper) ..."
+ do_start
+ ;;
+ stop)
+ echo "Shutting down autostarted VMs (kvm-wrapper) ..."
+ do_stop
+ ;;
+ restart|force-reload)
+ ;;
+ start-vm)
+ start_vm "$2"
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop}" >&2
+ echo " $SCRIPTNAME start-vm xxxxx" >&2
+ exit 3
+ ;;
+esac
+
diff --git a/startup/kvm-wrapper-startup.sh b/startup/kvm-wrapper-startup.sh
index 92be7e1..8a80c7f 100755
--- a/startup/kvm-wrapper-startup.sh
+++ b/startup/kvm-wrapper-startup.sh
@@ -45,27 +45,27 @@ stop_vm ()
do_start()
{
-if [[ ! -f /usr/share/kvm-wrapper/kvm-wrapper.sh ]]; then
- log_begin_msg "Mounting /usr/share/kvm-wrapper since it doesn't seem here"
+if [[ ! -f $KVM_WRAPPER ]]; then
+ log_begin_msg "Mounting $KVM_WRAPPER_DIR since it doesn't seem here"
echo
- mount /usr/share/kvm-wrapper
+ mount $KVM_WRAPPER
sleep 3
fi
echo cleaning old pid files for `hostname -s`
-rm -vf /usr/share/kvm-wrapper/run/`hostname -s`*
+rm -vf $KVM_WRAPPER_DIR/run/`hostname -s`*
grep -E -v '^#' "$KVM_VM_LIST" |
while read line
do
- pcregrep "^KVM_CLUSTER_NODE=\"?`hostname -s`" $KVM_WRAPPER_DIR/vm/$line-vm >&/dev/null && \
+ grep -E "^KVM_CLUSTER_NODE=\"?`hostname -s`" $KVM_WRAPPER_DIR/vm/$line-vm >&/dev/null && \
start_vm "$line"
done
}
do_stop()
{
-"$KVM_WRAPPER" list|pcregrep "Running\ton (`hostname -s`|local)"|awk '{print $1}'|
+"$KVM_WRAPPER" list|grep -E "Running\ton (`hostname -s`|local)"|awk '{print $1}'|
while read line
do
stop_vm "$line"