summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Janczyk2010-03-29 22:56:08 +0200
committerMichael Janczyk2010-03-29 22:56:08 +0200
commit1f29892fec8d5a131dd5f9ff7971b7a902eabce6 (patch)
tree6ad47efdce7a0751bd453b5fc0de8a5e61d1a140
parentNAT TFTP boot with VBox. (diff)
downloadcore-1f29892fec8d5a131dd5f9ff7971b7a902eabce6.tar.gz
core-1f29892fec8d5a131dd5f9ff7971b7a902eabce6.tar.xz
core-1f29892fec8d5a131dd5f9ff7971b7a902eabce6.zip
vmgrid graphical mode ;)
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm1
-rw-r--r--os-plugins/plugins/virtualbox/files/run-virt.include2
-rw-r--r--os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm80
-rw-r--r--os-plugins/plugins/vmgrid/files/run-vmgrid.sh57
-rw-r--r--os-plugins/plugins/vmgrid/files/vmgrid11
5 files changed, 127 insertions, 24 deletions
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
index 900d08a9..5d8206cd 100644
--- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
+++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
@@ -200,7 +200,6 @@ sub checkStage3AttrValues
sub _writeRunlevelScript
{
my $self = shift;
-
my $initfile = newInitFile();
my $script = "";
diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include
index 6d300044..8543e376 100644
--- a/os-plugins/plugins/virtualbox/files/run-virt.include
+++ b/os-plugins/plugins/virtualbox/files/run-virt.include
@@ -125,7 +125,7 @@ if echo "${imgmode}" | grep -q rw; then
exit 1
# image rw?
elif ! [ -w ${vmpath} ]; then
- writelog "You defined mode rw, but image is not rw! \c"
+ writelog "You defined mode rw, but image ${vmpath} is not rw! \c"
writelog "Please correct, exiting!"
exit 1
fi
diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm
index 5ee52d0c..d73e0720 100644
--- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm
+++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm
@@ -20,6 +20,7 @@ use base qw(OpenSLX::OSPlugin::Base);
use OpenSLX::Basics;
use OpenSLX::Utils;
+use OpenSLX::DistroUtils;
sub new
{
@@ -221,6 +222,8 @@ sub installationPhase
my $pluginRepoPath = $info->{'plugin-repo-path'};
my $openslxBasePath = $info->{'openslx-base-path'};
+ $self->_writeRunlevelScript();
+
# copy all needed files now:
my $pluginName = $self->{'name'};
my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName/files";
@@ -240,5 +243,80 @@ sub removalPhase
return;
}
-1;
+# Write the runlevelscript
+sub _writeRunlevelScript
+{
+ my $self = shift;
+ my $initfile = newInitFile();
+
+ $initfile->setName("vmgrid-slx");
+ $initfile->setDesc("Setup environment for vmgrid. Part of OpenSLX vmgrid plugin.");
+
+ # todo: Function need to be formated proper... not important right now
+ #$initfile->addFunction(
+ # 'running',
+ # '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
+
+ # Kill all VMS!
+ my $killvms = 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
+ kill ${pid}
+ fi
+ done
+ fi
+ End-of-Here
+ # FORCE: Kill all VMS!
+ my $fkillvms = 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
+ kill -9 ${pid}
+ fi
+ done
+ fi
+ End-of-Here
+
+ $initfile->addFunction(
+ 'start',
+ ' vmgrid',
+ );
+ $initfile->addToCase(
+ 'kill',
+ 'killvms'
+ );
+ $initfile->addToCase(
+ 'force-kill',
+ 'fkillvms'
+ );
+ $initfile->addToCase(
+ 'status',
+ 'runningvms'
+ );
+ $initfile->addToCase(
+ 'restart',
+ 'stop && start'
+ );
+
+ # get distro version
+# my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0];
+# my $runlevelscript = getInitFileForDistro($initfile, $distro);
+#
+# spitFile("$self->{'pluginRepositoryPath'}/vmgrid-slx", $runlevelscript);
+}
+
+1;
diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
index c300e9ce..21d7cbf8 100644
--- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
+++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh
@@ -51,13 +51,28 @@ writelog () {
### Get XML file and dir
################################################################################
-# check if forcemem set
-if [ "$1" = "--forcemem" ]; then
- forcemem=$2
- xmlfile=$3
-else
- xmlfile=$1
-fi
+# check if forcemem or graphical mode set
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -h|--help)
+ echo -e "Usage: run-vmgrid.sh [-g] [--forcemem <memorysize in MB>] \c"
+ echo -e "[/path/]filename[.xml]"
+ exit
+ ;;
+ -g)
+ headless=0
+ ;;
+ --forcemem)
+ forcemem=$2
+ shift
+ ;;
+ *)
+ xmlfile=$@
+ break
+ ;;
+ esac
+ shift
+done
# absolute or relative path?
if ls ${xmlfile} 2>/dev/null | grep '/' >/dev/null 2>&1; then
@@ -75,8 +90,8 @@ xmlfile="${xmlpath}/${xmlfile%.xml}.xml"
# test if the xml file is valid
if ! [ -r "${xmlfile}" ]; then
- echo -e "Usage: run-vmgrid.sh [--forcemem <memorysize in MB>] \c"
- echo -e "[/path/]filename[.xml]"
+ writelog "${xmlfile} not a readable XML file!"
+ run-vmgrid.sh -h &
exit 1
fi
@@ -299,7 +314,7 @@ hddrv="ide"
# add rw share
sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}"
mkdir -p ${sharepath}
-chmod 1777 "${vmgrid_rwmnt}/folders"
+chmod -f 1777 "${vmgrid_rwmnt}/folders"
sharename="share"
# set hostname: using original hostname and adding string
@@ -326,22 +341,28 @@ else
exit 1
fi
+# start graphical mode
+if [ ${headless} -eq 0 2>/dev/null ]; then
+ if [ -z "${VIRTCMD}" ]; then
+ writelog "Grapical mode not available, exiting"
+ exit 1
+ fi
+ writelog "Starting ${vmgrid_virt} in graphical mode..."
+ ${VIRTCMD} ${VIRTCMDOPTS}
# start headless
-if [ -n "${VIRTCMDHL}" ]; then
- writelog "Starting ${vmgrid_virt} headless..."
- # TODO: for testing use VBox
- VirtualBox
- #${VIRTCMDHL} ${VIRTCMDOPTSHL}
+elif [ -n "${VIRTCMDHL}" ]; then
+ writelog "Starting ${vmgrid_virt} in headless mode..."
+ ${VIRTCMDHL} ${VIRTCMDOPTSHL}
else
writelog "${vmgrid_virt}: No headless mode defined, exiting!"
exit 1
fi
-writelog "${vmgrid_virt} exited. Cleanning up...\c"
if echo "${RMDIRS}" 2>/dev/null | grep ${vmgrid_virt} >/dev/null 2>&1; then
+ writelog "${vmgrid_virt} exited. Cleanning up...\c"
rm -rf ${RMDIRS} >/dev/null 2>&1
+ writelog "done"
fi
-writelog "done"
-writelog "Bye."
+echo -e "Bye."
exit 0
diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid
index b60d8902..d93f4fbd 100644
--- a/os-plugins/plugins/vmgrid/files/vmgrid
+++ b/os-plugins/plugins/vmgrid/files/vmgrid
@@ -24,11 +24,13 @@
if [ -n "$1" ]; then
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
- echo "Usage: vmgrid [[/path/]filename[.xml]]"
+ echo -e "Usage: vmgrid [[-g] [--forcemem <memorysize in MB>] \c"
+ echo -e "[/path/]filename[.xml]]"
exit 0
else
- run-vmgrid.sh $@ &
- exit 0
+ echo "Starting run-vmgrid.sh with options '$@'"
+ run-vmgrid.sh $@
+ exit
fi
fi
@@ -66,6 +68,8 @@ writelog () {
# start to log, create shrare 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
@@ -153,6 +157,7 @@ for i in {1..4}; do
else
writelog "Starting ${vm[$i]} via run-vmgrid.sh with ${vmmem[$i]} MB RAM"
run-vmgrid.sh --forcemem ${vmmem[$i]} ${vm[$i]} &
+ echo $! > /tmp/vmgrid/${USER}/vmgrid.pids
# wait 5 secs for the next vm to start
sleep 5
fi