summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/vmgrid/files
diff options
context:
space:
mode:
authorMichael Janczyk2010-03-26 22:09:31 +0100
committerMichael Janczyk2010-03-26 22:09:31 +0100
commit3e8723555bb0a1be3e27330275c4d6b2da9945df (patch)
treebd85d3e02dda631f32f2c69ff3fae27836c13a71 /os-plugins/plugins/vmgrid/files
parentadded support for rw disks and netboot (diff)
downloadcore-3e8723555bb0a1be3e27330275c4d6b2da9945df.tar.gz
core-3e8723555bb0a1be3e27330275c4d6b2da9945df.tar.xz
core-3e8723555bb0a1be3e27330275c4d6b2da9945df.zip
NAT TFTP boot with VBox.
rwimg support added
Diffstat (limited to 'os-plugins/plugins/vmgrid/files')
-rw-r--r--os-plugins/plugins/vmgrid/files/run-vmgrid.sh54
-rw-r--r--os-plugins/plugins/vmgrid/files/vmgrid10
2 files changed, 40 insertions, 24 deletions
diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
index ac1dd8fd..c300e9ce 100644
--- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
+++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
@@ -38,14 +38,13 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share
################################################################################
# function to write to stdout and logfile
-mkdir -m 1777 -p ${RWSHARE}/var/log/openslx 2>/dev/null
writelog () {
# write to stdout
echo -e "$1"
# log into file
echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log
# log into share dir, so that log is available in vm as well
- echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log
+ echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log
}
################################################################################
@@ -81,6 +80,11 @@ if ! [ -r "${xmlfile}" ]; then
exit 1
fi
+# start to log, create shrare log dir
+mkdir -m 1777 -p ${vmgrid_rwmnt}/logs
+echo "Starting to log at $(date)" \
+ >${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log
+
# test how many instances running
runningvms=$(ps aux | grep "run-vmgrid.sh " | grep -v grep | wc -l)
runningvms=$(expr ${runningvms} - 1)
@@ -131,8 +135,7 @@ writelog "Starting configuration..."
writelog "\tVM-ID:\t\t\t${VM_ID}"
writelog "\tLogfile:\t\t${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log"
writelog "\t/tmp info:\t\t$(df -h | grep " /tmp$" | awk '{print $2}') \c"
-writelog " $(grep "/tmp " /proc/mounts) $(df -h | \
- grep " /tmp$" | awk '{print $2}')"
+writelog "$(grep "/tmp " /proc/mounts | awk '{print $1" "$2" "$3" "$4}')"
writelog "\tVM XML dir:\t\t${vmgrid_xmlpath}"
writelog "\tVM Image dir:\t\t${vmgrid_imgpath}"
@@ -149,42 +152,47 @@ writelog "VM config:"
imgname=$(grep -io '<image_name param=.*"' ${xmlfile} | \
sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')
+# name of the virt machine, sed because of Windows formatting
+vm_name=$(grep -o 'short_description param=.*"' ${xmlfile} | \
+ sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}')
+# if ${vm_name} not defined use ${imgname}
+vm_name=${vm_name:-"${imgname%.*}"}
+# define vm_shortname since vm_name can be very long
+vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g")
+# vm_name = displayname, define for old scripts
+displayname=${vm_name}
+
# image mode
imgmode=$(grep -io '<image_mode param=.*"' ${xmlfile} | \
sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')
if [ "${imgmode}" = "rwimg" ]; then
# maybe you want to support the users /w an ampty rw imgae?
- imgname="rwimg"
+ imgname="{special rw image}"
+ # define only for writelog, will be set in the plugin include again!
+ vmpath=${imgname}
+ vm_shortname=$(echo ${vm_name} | awk '{print $1" "$2" "$3}' \
+ | sed -e "s, ,-,g")
# add new path for rwimg
- imgpath=${vmgrid_rwdir}
+ imgpath=${vmgrid_rwmnt}/specialrwimages
+ mkdir -m 1777 -p ${imgpath}
elif echo ${imgname} 2>/dev/null | grep '/' >/dev/null 2>&1; then
imgpath=$(dirname ${imgname})
imgname=$(basename ${imgname})
+ vmpath=${imgpath}/${imgname}
else
imgpath=${vmgrid_imgpath}
+ vmpath=${imgpath}/${imgname}
fi
-# set default v path
-vmpath=${imgpath}/${imgname}
# check if virtual machine container file exists, only if not rwimg
-if ! [ -e $vmpath ] && ! [ "${imgmode}" = "rwimg" ]; then
+if ! [ -e "${vmpath}" ] && [ "${imgmode}" != "rwimg" ]; then
writelog "\tVirtual machine image or directory ${vmpath} not found!"
exit 1
fi
writelog "\tVM file/dir:\t\t$vmpath"
-# name of the virt machine, sed because of Windows formatting
-vm_name=$(grep -o 'short_description param=.*"' ${xmlfile} | \
- sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}')
-# if ${vm_name} not defined use ${imgname}
-vm_name=${vm_name:-"${imgname%.*}"}
-# define vm_shortname since vm_name can be very long
-vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g")
-# vm_name = displayname, define for old scripts
-displayname=${vm_name}
-
# is there an additional configuration provided?
additional_config=$(grep -o 'additional_config param=.*"' ${xmlfile} | \
sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}')
@@ -289,7 +297,9 @@ scsi="FALSE"
hddrv="ide"
# add rw share
-sharepath="${vmgrid_rwdir}/rwdir"
+sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}"
+mkdir -p ${sharepath}
+chmod 1777 "${vmgrid_rwmnt}/folders"
sharename="share"
# set hostname: using original hostname and adding string
@@ -319,7 +329,9 @@ fi
# start headless
if [ -n "${VIRTCMDHL}" ]; then
writelog "Starting ${vmgrid_virt} headless..."
- ${VIRTCMDHL} ${VIRTCMDOPTSHL}
+ # TODO: for testing use VBox
+ VirtualBox
+ #${VIRTCMDHL} ${VIRTCMDOPTSHL}
else
writelog "${vmgrid_virt}: No headless mode defined, exiting!"
exit 1
diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid
index b8806ab3..b60d8902 100644
--- a/os-plugins/plugins/vmgrid/files/vmgrid
+++ b/os-plugins/plugins/vmgrid/files/vmgrid
@@ -51,20 +51,24 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share
################################################################################
# function to write to stdout and logfile
-mkdir -m 1777 -p ${RWSHARE}/var/log/openslx 2>/dev/null
writelog () {
# write to stdout
echo -e "$1"
# log into file
echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log
# log into share dir, so that log is available in vm as well
- echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log
+ echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log
}
################################################################################
### Configure VMs for autostart and set RAM
################################################################################
+# start to log, create shrare log dir
+mkdir -m 1777 -p ${vmgrid_rwmnt}/logs
+echo "Starting to log at $(date)" \
+ >${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log
+
# remove blanks
vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s, *,,g")
vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s, *,,g")
@@ -109,7 +113,7 @@ vmsumratios=0
for i in {1..4}; do
vm[$i]=$(echo ${vmgrid_startvms} | awk -F ',' '{print $1}')
# remove ${vm[$i]} from list because of '{print $1}'
- vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s/${vm[$i]},*//")
+ vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s,${vm[$i]}\,*,,")
vmratio[$i]=$(echo ${vmgrid_memratio} | awk -F ',' '{print $1}')
# remove ${vmratio[$i]} from list because of '{print $1}'
vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s/${vmratio[$i]},*//")