diff options
Diffstat (limited to 'os-plugins/plugins/vmgrid/OpenSLX/OSPlugin')
| -rw-r--r-- | os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 80 |
1 files changed, 79 insertions, 1 deletions
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; |
