summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/vmgrid/files/vmgrid
diff options
context:
space:
mode:
authorMichael Janczyk2010-04-11 23:08:47 +0200
committerMichael Janczyk2010-04-11 23:08:47 +0200
commiteec193967f7aca562f7d99eaf5d6177f08e9a99e (patch)
tree34bd6d650c2edc705f67769939a58c646492d017 /os-plugins/plugins/vmgrid/files/vmgrid
parentqemukvm network configuration (diff)
downloadcore-eec193967f7aca562f7d99eaf5d6177f08e9a99e.tar.gz
core-eec193967f7aca562f7d99eaf5d6177f08e9a99e.tar.xz
core-eec193967f7aca562f7d99eaf5d6177f08e9a99e.zip
virtualization plugin, now with calculation of mem, run-vmgrid and run-virt uses it
Diffstat (limited to 'os-plugins/plugins/vmgrid/files/vmgrid')
-rw-r--r--os-plugins/plugins/vmgrid/files/vmgrid55
1 files changed, 16 insertions, 39 deletions
diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid
index ef86cb5a..d8ccd938 100644
--- a/os-plugins/plugins/vmgrid/files/vmgrid
+++ b/os-plugins/plugins/vmgrid/files/vmgrid
@@ -24,7 +24,7 @@
if [ -n "$1" ]; then
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
- echo -e "Usage: vmgrid [[-g] [--forcemem <memorysize in MB>] \c"
+ echo -e "Usage: vmgrid [[-g] [--mem <memorysize in MB>] \c"
echo -e "[/path/]filename[.xml]]"
exit 0
else
@@ -47,9 +47,6 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share
# load general virtualization information
[ -f ${PLUGINCONFROOT}/virtualization/virtualization.conf ] && \
. ${PLUGINCONFROOT}/virtualization/virtualization.conf
-# get the vmchooser_active var
-[ -f ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ] && \
- . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf
################################################################################
### Functions used throughout the script
@@ -69,48 +66,35 @@ writelog () {
### Configure VMs for autostart and set RAM
################################################################################
-# start to log, create shrare log dir
+# start to log, create share log dir
mkdir -m 1777 -p ${vmgrid_rwmnt}/logs
mkdir -m 1777 -p /tmp/vmgrid
mkdir -p /tmp/vmgrid/${USER}
echo "Starting to log at $(date)" \
>${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log
+if [ -z "${hostratio}" ]; then
+ writelog "There has been an error in the memory configuration in stage 3"
+ writelog "Please check your memory ratio settings, exiting!"
+ exit 1
+fi
+
# remove blanks
-vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s, *,,g")
vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s, *,,g")
+vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s, *,,g")
-# get hostmem, totalmem from stage 3
-hostratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $6}')
-hostmem=$(expr ${totalmem} \* ${hostratio} / 100 2>/dev/null)
-if [ ${hostmem} -lt 256 2>/dev/null ]; then
- hostmem=256
- writelog "${hostmem} MB RAM reserved for host"
-fi
-
-# get other vm mem
-if [ -n "${vmchooser_active}" ]; then
- othervmratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $5}')
- othervmmem=$(expr ${totalmem} \* ${othervmratio} / 100 2>/dev/null)
- if [ ${othervmmem} -lt 512 2>/dev/null ]; then
- othervmmem=512
- writelog "${othervmmem} MB RAM reserved for other virtualization solutions"
- fi
-else
- othervmratio=0
- othervmmem=0
-fi
+# hostmem, mainvirt from virtualization plugin
+# ratio minus other vms and host
+restratio=$(expr 100 - ${hostratio} - ${mainvirtratio})
+# hostmem, totalmem, mainvirtmem from virtualization plugin
# calculate freemem
-freemem=$(expr ${totalmem} - ${hostmem} - ${othervmmem} 2>/dev/null)
+freemem=$(expr ${totalmem} - ${hostmem} - ${mainvirtmem} 2>/dev/null)
if [ ${freemem} -lt 512 2>/dev/null ]; then
writelog "Not enough free RAM for this plugin, free: ${freemem} MB"
exit 1
fi
-# ratio minus other vms and host
-restratio=$(expr 100 - ${hostratio} - ${othervmratio})
-
# get clients mem ratio
vmsumratios=0
for i in {1..4}; do
@@ -123,15 +107,8 @@ for i in {1..4}; do
vmsumratios=$(expr ${vmsumratios} + ${vmratio[$i]} 2>/dev/null)
done
-# ratio test: 100 - host - other vm + grid ratios
-ratiotest=$(expr 100 - ${restratio} + ${vmsumratios} 2>/dev/null)
-if [ ${ratiotest} -gt 100 ]; then
- #writelog "you managed to get over 100% in ratio Einstein: ${ratiotest}%"
- exit 1
-fi
-
for i in {1..4}; do
- # calculate vms mem: mem = $freemem * $vmratio/100 * 100/$restratio
+ # calculate VMs mem: mem = $freemem * $vmratio/100 * 100/$restratio
# multiple of 4
vmmem[$i]=$(expr ${freemem} \* ${vmratio[$i]} / ${restratio} / 4 \* 4 \
2>/dev/null)
@@ -155,7 +132,7 @@ for i in {1..4}; do
writelog "${vm[$i]} already running, skipping!"
else
writelog "Starting ${vm[$i]} via run-vmgrid.sh with ${vmmem[$i]} MB RAM"
- run-vmgrid.sh --forcemem ${vmmem[$i]} ${vm[$i]} 2>/dev/null &
+ run-vmgrid.sh --mem ${vmmem[$i]} ${vm[$i]} 2>/dev/null &
echo $! > /tmp/vmgrid/${USER}/vmgrid.pids
# wait 5 secs for the next vm to start
sleep 10