diff options
author | root | 2010-04-28 20:53:56 +0200 |
---|---|---|
committer | root | 2010-04-28 20:53:56 +0200 |
commit | 494bf3051361f1d6a5c100509fe632b283c66353 (patch) | |
tree | d1d42a484a0b166ecb4cf00f12142fcbb3bb583b | |
parent | minor fixes (diff) | |
parent | clean exit added + port redirects now via xml file (diff) | |
download | core-494bf3051361f1d6a5c100509fe632b283c66353.tar.gz core-494bf3051361f1d6a5c100509fe632b283c66353.tar.xz core-494bf3051361f1d6a5c100509fe632b283c66353.zip |
Merge branch 'master' of git@openslx.org:openslx/core
5 files changed, 69 insertions, 35 deletions
diff --git a/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh b/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh index 400075cd..a1da2e63 100644 --- a/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh +++ b/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh @@ -30,7 +30,7 @@ active=0 [ ${vmgrid_active} -ne 0 ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ - && echo -e "Executing the virtual 'virtualization' plugin ... \c" + && echo -e "Executing the 'virtualization' plugin ... \c" if [ ${active} -ne 0 ] ; then diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index d73e0720..c3542274 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -72,9 +72,9 @@ sub getAttrInfo description => unshiftHereDoc(<<' End-of-Here'), which virtualization technique schould be used? End-of-Here - content_regex => qr{^(vmware|virtualbox|qemukvm|xen)$}, + content_regex => qr{^(virtualbox|qemukvm|xen)$}, #openvz|vserver - content_descr => 'vmware, virtualbox, qemukvm, xen', + content_descr => 'virtualbox, qemukvm, xen', #openvz, vserver default => undef, }, @@ -133,7 +133,7 @@ sub getAttrInfo content_descr => 'name of xml file e.g. scilin-5.4-wn(.xml)', default => undef, }, - 'vmgrid::hvm' => { + 'vmgrid::vt' => { applies_to_systems => 1, applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), @@ -249,7 +249,7 @@ sub _writeRunlevelScript my $self = shift; my $initfile = newInitFile(); - $initfile->setName("vmgrid-slx"); + $initfile->setName("vmgrid"); $initfile->setDesc("Setup environment for vmgrid. Part of OpenSLX vmgrid plugin."); # todo: Function need to be formated proper... not important right now @@ -258,16 +258,16 @@ sub _writeRunlevelScript # 'lsmod | grep -q "$1[^_-]"' #); - # Is a VM running? - my $runningvms = unshiftHereDoc(<<' End-of-Here'); - if [ -e /tmp/vmgrid/vmgrid.pids ]; then - for pid in $(cat /tmp/vmgrid/vmgrid.pids); do - if ps aux | grep " ${pid} " | grep vmgrid; then - echo "Running: ${pid}" - fi - done - fi - End-of-Here +# # Is a VM running? +# my $runningvms = unshiftHereDoc(<<' End-of-Here'); +# if [ -e /tmp/vmgrid/vmgrid.pids ]; then +# for pid in $(cat /tmp/vmgrid/vmgrid.pids); do +# if ps aux | grep " ${pid} " | grep vmgrid; then +# echo "Running: ${pid}" +# fi +# done +# fi +# End-of-Here # Kill all VMS! my $killvms = unshiftHereDoc(<<' End-of-Here'); @@ -312,7 +312,7 @@ sub _writeRunlevelScript 'stop && start' ); - # get distro version +# # get distro version # my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0]; # my $runlevelscript = getInitFileForDistro($initfile, $distro); # diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 1501749e..9b9adb44 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -49,6 +49,17 @@ writelog () { echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log } +# remove config dirs when exit +cleanexit () { + if echo "${RMDIRS}" 2>/dev/null | grep -q ${vmgrid_virt}; then + writelog "${vmgrid_virt} exited. Cleanning up... \c" + rm -rf ${RMDIRS} >/dev/null 2>&1 + writelog "done" + fi + + exit "$1" +} + ################################################################################ ### Get XML file and dir ################################################################################ @@ -289,11 +300,28 @@ vmostype=$(grep -io '<os param=.*"' ${xmlfile} | awk -F '"' '{ print $2 }' \ | tr [A-Z] [a-z]) # definition of the networking the client system is connected to -network_kind=$(grep -io 'network param=.*"' ${xmlfile} \ +network_kind=$(grep -io '<network param=.*"' ${xmlfile} \ | awk -F '"' '{ print $2 }' | tr [A-Z] [a-z]) -network_card=$(grep -io 'netcard param=.*"' ${xmlfile} \ +network_card=$(grep -io '<netcard param=.*"' ${xmlfile} \ | awk -F '"' '{ print $2 }'| tr [A-Z] [a-z]) +# define redirects +redirects=$(grep -ic '<redirect name=.*"' ${xmlfile}) +[ -z "${redirects}" ] && redirects=0 +(( i=1 )) +while [ ${i} -le ${redirects} ]; do + # get only the $i-th line + redirect_name[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \ + | grep -o "name=\".*" | awk -F '"' '{ print $2 }') + redirect_proto[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \ + | grep -o "proto=\".*" | awk -F '"' '{ print $2 }') + redirect_hport[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \ + | grep -o "hostport=\".*" | awk -F '"' '{ print $2 }') + redirect_gport[$i]=$(grep -m ${i} -io '<redirect.*' ${xmlfile} | tail -n 1 \ + | grep -o "guestport=\".*" | awk -F '"' '{ print $2 }') + (( i=$i+1 )) +done + writelog "\tVirtualization:\t\t$xmlvirt" writelog "\tVM name:\t\t$vm_name" writelog "\tVM short name:\t\t$vm_shortname" @@ -331,6 +359,8 @@ macaddr=$(echo "${macguestpart}:${machostpart}" | tr [a-z] [A-Z]) ide="TRUE" scsi="FALSE" hddrv="ide" +audio="false" +remotedesktopport="590${VM_ID}" # add rw share sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}" @@ -366,7 +396,7 @@ fi if [ ${headless} -eq 0 ]; then if [ -z "${VIRTCMD}" ]; then writelog "Grapical mode not available, exiting!" - exit 1 + cleanexit 1 fi writelog "Starting ${vmgrid_virt} in graphical mode..." ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null @@ -376,7 +406,7 @@ elif [ -n "${VIRTCMDHL}" ]; then ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null else writelog "${vmgrid_virt}: No headless mode defined, exiting!" - exit 1 + cleanexit 1 fi # postrun for scripts after virtualization finishes @@ -384,12 +414,5 @@ if [ -n "${POSTRUN}" ]; then eval ${POSTRUN} >/dev/null 2>&1 fi -# remove config dirs when finished -if echo "${RMDIRS}" 2>/dev/null | grep -q ${vmgrid_virt}; then - writelog "${vmgrid_virt} exited. Cleanning up... \c" - rm -rf ${RMDIRS} >/dev/null 2>&1 - writelog "done" -fi - -echo -e "Bye." +cleanexit 0 exit 0 diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index d8ccd938..3b6713b8 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -57,9 +57,9 @@ writelog () { # write to stdout echo -e "$1" # log into file - echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/vmgrid.${USER}.$$.log # log into share dir, so that log is available in vm as well - echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log + echo -e "$1" >> ${vmgrid_rwmnt}/logs/vmgrid.${USER}.$$.log } ################################################################################ @@ -71,7 +71,13 @@ 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 + >${vmgrid_rwmnt}/logs/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 if [ -z "${hostratio}" ]; then writelog "There has been an error in the memory configuration in stage 3" @@ -111,7 +117,7 @@ for i in {1..4}; do # calculate VMs mem: mem = $freemem * $vmratio/100 * 100/$restratio # multiple of 4 vmmem[$i]=$(expr ${freemem} \* ${vmratio[$i]} / ${restratio} / 4 \* 4 \ - 2>/dev/null) + 2>/dev/null) if [ -n "${vm[$i]}" ] && [ ${vmmem[$i]} -lt 512 2>/dev/null ]; then writelog "Not enough free RAM for ${vm[$i]} (min. 512 MB), \c" writelog "free: ${vmmem[$i]} MB" @@ -126,8 +132,13 @@ done # start vms for i in {1..4}; do if [ -n "${vm[$i]}" ]; then - alreadyrunning=$(ps aux | grep run-vmgrid.sh | grep -v grep | \ - grep "${vm[$i]}" | wc -l) + alreadyrunning=$(ps aux | grep run-vmgrid.sh | grep -v grep \ + | grep "${vm[$i]}" | wc -l) + # if Xen use different method + if [ "${vmgrid_virt}" = "xen" ]; then + alreadyrunning=$(xm list 2>/dev/null | grep -vE "Domain-0|Name.*ID" \ + | grep "${vm[$i]}-0.$" | wc -l) + fi if [ ${alreadyrunning} -gt 0 2>/dev/null ]; then writelog "${vm[$i]} already running, skipping!" else diff --git a/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh b/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh index 400075cd..a1da2e63 100644 --- a/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh +++ b/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh @@ -30,7 +30,7 @@ active=0 [ ${vmgrid_active} -ne 0 ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ - && echo -e "Executing the virtual 'virtualization' plugin ... \c" + && echo -e "Executing the 'virtualization' plugin ... \c" if [ ${active} -ne 0 ] ; then |