summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/vmgrid/XX_vmgrid.sh
diff options
context:
space:
mode:
authorMichael Janczyk2010-04-06 20:03:28 +0200
committerMichael Janczyk2010-04-06 20:03:28 +0200
commit4661a054dca2bf0844c8bd283829b68328c7fed3 (patch)
treec9fb9c71fd5033f5b666b1deee432ea5d5f36126 /os-plugins/plugins/vmgrid/XX_vmgrid.sh
parentcumulative commit of local branch, many changes regarding virtualization (diff)
downloadcore-4661a054dca2bf0844c8bd283829b68328c7fed3.tar.gz
core-4661a054dca2bf0844c8bd283829b68328c7fed3.tar.xz
core-4661a054dca2bf0844c8bd283829b68328c7fed3.zip
cumulative commit of local branch, xen modifications and vmgrid plugin
Diffstat (limited to 'os-plugins/plugins/vmgrid/XX_vmgrid.sh')
-rw-r--r--os-plugins/plugins/vmgrid/XX_vmgrid.sh124
1 files changed, 124 insertions, 0 deletions
diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh
new file mode 100644
index 00000000..d9e35dfb
--- /dev/null
+++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh
@@ -0,0 +1,124 @@
+# Copyright (c) 2008..2010 - RZ Uni Freiburg
+# Copyright (c) 2008..2010 - OpenSLX GmbH
+#
+# This program/file is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# script is included from init via the "." load function - thus it has all
+# variables and functions available
+
+# include default directories
+. /etc/openslx.conf
+
+CONFFILE="/initramfs/plugin-conf/vmgrid.conf"
+PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/vmgrid
+VIRTUALIZATIONPLUGIN=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization
+#RWSHARE=/mnt/${OPENSLX_DEFAULT_VARDIR}/plugins/vmgrid/share
+RWSHARE=/mnt/var/opt/openslx/plugins/vmgrid/share
+RWSHAREMNT=/mnt/var/opt/openslx/mnt/vmgrid
+BINDIR=/mnt/${OPENSLX_DEFAULT_BINDIR}
+PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/vmgrid
+VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/vmgrid
+
+if [ -f $CONFFILE ]; then
+
+ # load needed variables
+ . $CONFFILE
+
+ if [ $vmgrid_active -ne 0 ] ; then
+ [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'vmgrid' os-plugin ..."
+
+ # load general configuration
+ . /etc/initramfs-setup
+ # include functions
+ . /etc/functions
+
+ testmkd ${PLUGINCONFDIR}
+ testmkd ${VIRTDIR}
+ cp $CONFFILE ${PLUGINCONFDIR}/vmgrid.conf
+ # create link to binpath
+ ln -fs ${PLUGINDIR}/vmgrid ${BINDIR}/vmgrid
+ ln -fs ${PLUGINDIR}/run-vmgrid.sh ${BINDIR}/run-vmgrid.sh
+
+ # mount nfs virt ro share
+ if strinstr "nfs://" "${vmgrid_roshare}"; then
+ virtsrcprot=$(uri_token ${vmgrid_roshare} prot)
+ virtsrcserv=$(uri_token ${vmgrid_roshare} server)
+ virtsrcpath="$(uri_token ${vmgrid_roshare} path)"
+ if [ -n "${virtsrcprot}" -a -n "${virtsrcserv}" -a -n "${virtsrcpath}" ];
+ then
+ virtsrctarget=${VIRTDIR}
+ # mount the vmgrid source ro
+ fsmount ${virtsrcprot} ${virtsrcserv} ${virtsrcpath} ${virtsrctarget} \
+ ro
+ fi
+ fi
+
+ # create rw share
+ testmkd ${RWSHARE}
+ # bind mount id 45 to ${RWSHARE}
+ if strinstr "id45" "${vmgrid_rwshare}" ; then
+ id45part=$(grep " 45 " /etc/disk.partition | awk '{print $1}' | \
+ cut -f 3,3 -d /)
+ if [ -n "${id45part}" ]; then
+ testmkd /mnt/media/${id45part}/vmgrid
+ mount --bind -n /mnt/media/${id45part}/vmgrid ${RWSHARE} \
+ >>/tmp/vmgrid.log 2>&1
+ fi
+ # mount nfs rw share
+ elif strinstr "nfs://" "${vmgrid_rwshare}" ; then
+ rwshareprot=$(uri_token ${vmgrid_rwshare} prot)
+ rwshareserv=$(uri_token ${vmgrid_rwshare} server)
+ rwsharepath="$(uri_token ${vmgrid_rwshare} path)"
+ if [ -n "${rwshareprot}" -a -n "${rwshareserv}" -a -n "${rwsharepath}" ];
+ then
+ # mount to a dir fist to create spec host dir, then bind mount
+ testmkd ${RWSHAREMNT}
+ rwtarget=${RWSHAREMNT}
+ # mount the vmgrid source rw
+ fsmount ${rwshareprot} ${rwshareserv} ${rwsharepath} ${rwtarget} rw
+ # hostname?
+ host_name=${host_name:=$clientip}
+ testmkd ${RWSHAREMNT}/${host_name}
+ mount --bind ${RWSHAREMNT}/${host_name} ${RWSHARE} \
+ >>/tmp/vmgrid.log 2>&1
+ fi
+ else
+ testmkd /mnt/tmp/vmgrid
+ mount --bind -n /mnt/tmp/vmgrid ${RWSHARE} >>/tmp/vmgrid.log 2>&1
+ fi
+ # chmod so that everybody can write
+ chmod 1777 ${RWSHARE}
+ echo "vmgrid_rwmnt=${RWSHARE#/mnt}" >> ${PLUGINCONFDIR}/vmgrid.conf
+
+ # virtual virtualization plugin
+ testmkd ${VIRTUALIZATIONPLUGIN}
+ totalmemtest=$(expr $(echo ${vmgrid_memratio} \
+ | awk -F ',' '{print $1" + "$2" + "$3" + "$4" + "$5" + "$6}'))
+ totalmem=$(expr $(grep -i "memtotal" /proc/meminfo \
+ | awk '{print $2}') / 1024)
+ if [ ${totalmemtest} -le 100 2>/dev/null ]; then
+ # get hostmem
+ freememper=$(expr 100 - $(echo ${vmgrid_memratio} \
+ | awk -F ',' '{print $1" - "$2" - "$3" - "$4}'))
+ freemem=$(expr ${totalmem} \* ${freememper} / 100)
+ echo "virt_freemem=${freemem}" \
+ >> ${VIRTUALIZATIONPLUGIN}/virtualization.conf
+ else
+ # more than 100% memory assigned stupid!
+ # vmgrid will get this as well and exit!
+ # so we have theoretically 100% free
+ echo "virt_freemem=${totalmem}" \
+ >> ${VIRTUALIZATIONPLUGIN}/virtualization.conf
+ fi
+
+ # finished ...
+ [ $DEBUGLEVEL -gt 0 ] && echo "done with 'vmgrid' os-plugin ..."
+ fi
+[ $DEBUGLEVEL -gt 0 ] && echo " * configuration of 'vmgrid' os-plugin failed"
+fi