summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk von Suchodoletz2010-02-11 00:45:43 +0100
committerDirk von Suchodoletz2010-02-11 00:45:43 +0100
commit8366523dedf9197d58c2c7030d98f2b7d470d06c (patch)
tree70639e415c177152a320251bb1b0ede772665028
parentsame improvement as rf00b265a but for pbs (diff)
downloadcore-8366523dedf9197d58c2c7030d98f2b7d470d06c.tar.gz
core-8366523dedf9197d58c2c7030d98f2b7d470d06c.tar.xz
core-8366523dedf9197d58c2c7030d98f2b7d470d06c.zip
Cleaning up the runlevel mess of vmware plugin ... Not finished yet.
-rw-r--r--lib/OpenSLX/DistroUtils/InitFile.pm8
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm1
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm17
-rw-r--r--os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm185
-rw-r--r--os-plugins/plugins/vmware/OpenSLX/Distro/Fedora.pm3
-rw-r--r--os-plugins/plugins/vmware/OpenSLX/Distro/Gentoo.pm174
-rw-r--r--os-plugins/plugins/vmware/OpenSLX/Distro/Suse.pm207
-rw-r--r--os-plugins/plugins/vmware/OpenSLX/Distro/Ubuntu.pm2
-rw-r--r--os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm136
9 files changed, 137 insertions, 596 deletions
diff --git a/lib/OpenSLX/DistroUtils/InitFile.pm b/lib/OpenSLX/DistroUtils/InitFile.pm
index a7e5da5d..ab729959 100644
--- a/lib/OpenSLX/DistroUtils/InitFile.pm
+++ b/lib/OpenSLX/DistroUtils/InitFile.pm
@@ -144,10 +144,10 @@ sub setDesc {
}
sub addFunction {
- my $self = shift;
- my $name = shift;
- my $script = shift;
- my $flags = shift || {};
+ my $self = shift;
+ my $name = shift;
+ my $script = shift;
+ my $flags = shift || {};
my $priority = $flags->{priority} || 5;
push(@{$self->{'configHash'}->{'highlevelConfig'}},
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm
index fad96ea1..9af3191e 100644
--- a/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm
+++ b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm
@@ -31,6 +31,7 @@ sub installVbox
my $self = shift;
my $engine = $self->{'engine'};
+ # should be replaced by proper function
my $release = `lsb_release -rs`;
chomp($release);
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
index e936590e..fd1424f1 100644
--- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
+++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
@@ -1,4 +1,4 @@
-# Copyright (c) 2009 - OpenSLX GmbH
+# Copyright (c) 2009..2010 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
@@ -9,7 +9,7 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# virtualbox.pm
-# - Declares necessary information for the virtualbox plugin
+# - declares necessary information for the virtualbox plugin
# -----------------------------------------------------------------------------
package OpenSLX::OSPlugin::virtualbox;
@@ -168,7 +168,7 @@ sub _writeRunlevelScript
);
$initfile->addFunction(
'vmstatus',
- ' if running vboxdrv; then
+ 'if running vboxdrv; then
if running vboxnetflt; then
echo "VirtualBox kernel modules (vboxdrv and vboxnetflt) are loaded."
else
@@ -188,7 +188,7 @@ sub _writeRunlevelScript
' modprobe vboxdrv && modprobe vboxnetflt',
);
$initfile->addFunction(
- 'stop',
+ 'stop',
' rmmod vboxnetflt && rmmod vboxdrv',
);
$initfile->addToCase(
@@ -208,12 +208,9 @@ sub _writeRunlevelScript
'stop && start'
);
- # get distro version (does not work and makes no sense to call an external
- # function which is not available in all distros)
- # my $workaround_distro = qx(lsb_release -si);
- # alternative from bootsplash.pm
- my $workaround_distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0];
- my $runlevelscript = getInitFileForDistro($initfile, $workaround_distro);
+ # get distro version
+ my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0];
+ my $runlevelscript = getInitFileForDistro($initfile, $distro);
# todo: because we dont have distribution or version dependend
# init scripts we could put it directly into /etc/init.d...
diff --git a/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm b/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm
index 51361f31..faa41b97 100644
--- a/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm
+++ b/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm
@@ -44,190 +44,5 @@ sub initialize
return 1;
}
-sub fillRunlevelScript
-{
- my $self = shift;
- my $location = shift;
- my $kind = shift;
-
-# my $initfile = newInitFile();
-# $initfile->addFunction(
-# 'load_modules',
-# '
-# # to be filled in via the stage1 configuration script
-# insmod /lib/modules/\$(uname -r)/misc/vmmon.ko || return 1
-# insmod /lib/modules/\$(uname -r)/misc/vmnet.ko || return 1
-# insmod /lib/modules/\$(uname -r)/misc/vmblock.ko 2>/dev/null || return 0
-# '
-# {param => "value"}
-# );
-#
-# $initfile->addFunctionCall(
-# 'functionName',
-# 'start', # name of block
-# {priority => 5, }
-# );
-#
-# $initfile->addDaemon("/bin/mydaemon");
-#
-# my $runlevelscript = getInitFileForDistro($initfile, "ubuntu");
-
- my $script = unshiftHereDoc(<<" End-of-Here");
- #!/bin/sh
- # completely generic start/stop script, generated via stage1 'vmware' plugin
- # install
- # inspiration taken from vmware start script:
- # Copyright 1998-2007 VMware, Inc. All rights reserved.
- #
- # This script manages the services needed to run VMware software
-
- # Basic support for the Linux Standard Base Specification 1.3
- ### BEGIN INIT INFO
- # Provides: VMware
- # Required-Start: \$syslog
- # Required-Stop:
- # Default-Start: 2 3 5
- # Default-Stop: 0 6
- # Short-Description: Manages the services needed to run VMware software
- # Description: Manages the services needed to run VMware software
- ### END INIT INFO
- load_modules() {
- End-of-Here
-
- # Load modules
- if ($kind eq 'local' || $kind eq 'local25') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- # to be filled in via the stage1 configuration script
- insmod /lib/modules/\$(uname -r)/misc/vmmon.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmnet.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmblock.ko 2>/dev/null || return 0
- End-of-Here
- } elsif ($kind eq 'vmpl1.0') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- End-of-Here
- } elsif ($kind eq "vmpl2.0") {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- End-of-Here
- } elsif ($kind eq 'vmpl2.5') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- End-of-Here
- }
-
- # unload modules
- $script .= unshiftHereDoc(<<" End-of-Here");
- }
-
- unload_modules() {
- # to be filled with the proper list within via the stage1
- # configuration script
- rmmod vmmon vmblock vmnet vmmon 2>/dev/null
-
- }
- End-of-Here
-
-
- # setup vmnet0 and vmnet8
- # depends on specific stage3 setting. I let this if in the code
- # because else this whole if-reducing process will become more
- # complicated and the code will get less understandable
- $script .= unshiftHereDoc(<<" End-of-Here");
- # the bridged interface
- setup_vmnet0() {
- if [ -n "\$vmnet0" ] ; then
- # the path might be directly point to the plugin dir
- End-of-Here
- if ($kind eq 'vmpl2.5' || $kind eq 'local25') {
- $script .= " $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0\n";
- } else {
- $script .= " $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vmnet0 eth0\n";
- }
- $script .= unshiftHereDoc(<<" End-of-Here");
- fi
- }
- # we definately prefer the hostonly interface for NATed operation too
- # distinction is made via enabled forwarding
- setup_vmnet1() {
- if [ -n "\$vmnet1" ] ; then
- # the path might be directly point to the plugin dir
- $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \\
- /dev/vmnet1 vmnet1
- dhcpif="\$dhcpif vmnet1"
- ip addr add \$vmnet1 dev vmnet1
- ip link set vmnet1 up
- if [ -n "\$vmnet1nat" ] ; then
- # needs refinement interface name for eth0 is known in stage3 already
- echo "1" > /proc/sys/net/ipv4/conf/vmnet1/forwarding 2>/dev/null
- echo "1" > /proc/sys/net/ipv4/conf/eth0/forwarding 2>/dev/null
- #iptables -A -s vmnet1 -d eth0
- fi
- $location/vmnet-dhcpd -cf /etc/vmware/dhcpd-vmnet1.conf -lf \\
- /var/run/vmware/dhcpd-vmnet1.leases \\
- -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1 2>/dev/null # or logfile
- fi
- }
- # incomplete ...
- setup_vmnet8() {
- if [ -n "\$vmnet8" ] ; then
- #test -c /dev/vmnet8 || mknod c 119 8 /dev/vmnet8
- $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid \\
- /dev/vmnet8 vmnet8
- ip addr add \$vmnet8 dev vmnet8
- ip link set vmnet8 up
- # /etc/vmware/vmnet-natd-8.mac simply contains a mac like 00:50:56:F1:30:50
- $location/vmnet-natd -d /var/run/vmnet-natd-8.pid \\
- -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf 2>/dev/null # or logfile
- $location/vmnet-dhcpd -cf /etc/vmware/dhcpd-vmnet8.conf -lf \\
- /var/run/vmware/dhcpd-vmnet8.leases \\
- -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8 2>/dev/null # or logfile
- fi
- }
- case \$1 in
- start)
- echo "Starting vmware background services ..."
- # include default directories
- . /etc/opt/openslx/openslx.conf
- # load the configuration file
- . \${OPENSLX_DEFAULT_CONFDIR}/plugins/vmware/vmware.conf
- load_modules
- setup_vmnet0
- setup_vmnet1
- setup_vmnet8
- ;;
- stop)
- # message output should match the given vendor-os
- echo "Stopping vmware background services ..."
- killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \\
- vmware-tray vmnet-dhcpd 2>/dev/null
- # wait for shutting down of interfaces... vmnet needs kinda
- # long
- sleep 1
- unload_modules
- ;;
- #status)
- # echo "Say something useful here ..."
- #;;
- restart)
- "\$0" stop
- "\$0" start
- ;;
- esac
- exit 0
- End-of-Here
- return $script;
-}
1;
diff --git a/os-plugins/plugins/vmware/OpenSLX/Distro/Fedora.pm b/os-plugins/plugins/vmware/OpenSLX/Distro/Fedora.pm
index 1c03540f..912bdfa0 100644
--- a/os-plugins/plugins/vmware/OpenSLX/Distro/Fedora.pm
+++ b/os-plugins/plugins/vmware/OpenSLX/Distro/Fedora.pm
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2007 - OpenSLX GmbH
+# Copyright (c) 2007..2010 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
@@ -25,6 +25,5 @@ use OpenSLX::Basics;
### interface methods
################################################################################
-# TODO: implement!
1;
diff --git a/os-plugins/plugins/vmware/OpenSLX/Distro/Gentoo.pm b/os-plugins/plugins/vmware/OpenSLX/Distro/Gentoo.pm
index a57e5c8e..2e1197d8 100644
--- a/os-plugins/plugins/vmware/OpenSLX/Distro/Gentoo.pm
+++ b/os-plugins/plugins/vmware/OpenSLX/Distro/Gentoo.pm
@@ -25,178 +25,4 @@ use OpenSLX::Basics;
### interface methods
################################################################################
-sub fillRunlevelScript
-{
- my $self = shift;
- my $location = shift;
- my $kind = shift;
-
- my $script = unshiftHereDoc(<<" End-of-Here");
- #!/sbin/runscript
- # Gentoo compatible (hopefully) start/stop script, generated via stage1 'vmware'
- # plugin installation
- #
- # inspiration taken from vmware start script:
- # Copyright 1998-2007 VMware, Inc. All rights reserved.
- #
- # This script manages the services needed to run VMware software
-
- # dependency definitions
- depend() {
- # use syslog
- # need ...
- }
-
- # helper functions
- load_modules() {
- End-of-Here
-
- # load modules
- if ($kind eq 'local' || $kind eq 'local25' || $kind eq 'local30') {
- if ($kind eq 'local30') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- # vmplayer 3.0 specific stuff
- insmod /lib/modules/\$(uname -r)/misc/vsock.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmci.ko || return 1
- End-of-Here
- }
- $script .= unshiftHereDoc(<<" End-of-Here");
- # to be filled in via the stage1 configuration script
- insmod /lib/modules/\$(uname -r)/misc/vmmon.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmnet.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmblock.ko 2>/dev/null || return 0
- End-of-Here
- } elsif ($kind eq 'vmpl1.0') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- End-of-Here
- } elsif ($kind eq "vmpl2.0") {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- End-of-Here
- } elsif ($kind eq 'vmpl2.5') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- End-of-Here
- } elsif ($kind eq 'vmpl3.0') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- insmod \${module_src_path}/vsock.ko
- insmod \${module_src_path}/vmci.ko
- End-of-Here
- }
-
- # unload modules
- $script .= unshiftHereDoc(<<" End-of-Here");
- }
-
- unload_modules() {
- # to be filled with the proper list within via the stage1
- # configuration script
- rmmod vmmon vmblock vmnet vmmon vmci vsock 2>/dev/null
- }
- End-of-Here
-
-
-
- # setup vmnet0 and vmnet8
- # depends on specific stage3 setting. I let this if in the code
- # because else this whole if-reducing process will become more
- # complicated and the code will get less understandable
- $script .= unshiftHereDoc(<<" End-of-Here");
- # the bridged interface
- setup_vmnet0() {
- if [ -n "\$vmnet0" ] ; then
- # the path might be directly point to the plugin dir
- End-of-Here
- if ($kind eq 'vmpl2.5' || $kind eq 'vmpl3.0' || $kind eq 'local25' || $kind eq 'local30') {
- $script .= " $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0\n";
- } else {
- $script .= " $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vmnet0 eth0\n";
- }
- $script .= unshiftHereDoc(<<" End-of-Here");
- fi
- }
- # we definately prefer the hostonly interface for NATed operation too
- # distinction is made via enabled forwarding
- setup_vmnet1() {
- if [ -n "\$vmnet1" ] ; then
- #test -c /dev/vmnet1 || mknod c 119 1 /dev/vmnet1
- # the path might be directly point to the plugin dir
- $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \\
- /dev/vmnet1 vmnet1
- dhcpif="\$dhcpif vmnet1"
- ip addr add \$vmnet1 dev vmnet1
- ip link set vmnet1 up
- if [ -n "\$vmnet1nat" ] ; then
- # needs refinement interface name for eth0 is known in stage3 already
- echo "1" > /proc/sys/net/ipv4/conf/vmnet1/forwarding 2>/dev/null
- echo "1" > /proc/sys/net/ipv4/conf/eth0/forwarding 2>/dev/null
- #iptables -A -s vmnet1 -d eth0
- fi
- $location/vmnet-dhcpd -cf /etc/vmware/dhcpd-vmnet8.conf \\
- -lf /var/run/vmware/dhcpd-vmnet1.leases \\
- -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1 2>/dev/null # or logfile
- fi
- }
- # incomplete ...
- setup_vmnet8() {
- if [ -n "\$vmnet8" ] ; then
- $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid \\
- /dev/vmnet8 vmnet8
- ip addr add \$vmnet8 dev vmnet8
- ip link set vmnet8 up
- # /etc/vmware/vmnet-natd-8.mac simply contains a mac like 00:50:56:F1:30:50
- $location/vmnet-natd -d /var/run/vmnet-natd-8.pid \\
- -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf 2>/dev/null # or logfile
- $location/vmnet-dhcpd -cf /etc/vmware/dhcpd-vmnet8.conf \\
- -lf /var/run/vmware/dhcpd-vmnet8.leases \\
- -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8 2>/dev/null # or logfile
- fi
- }
-
- # start/stop functions
- start() {
- ebegin "Starting vmware background services ..."
- # include default directories
- . /etc/opt/openslx/openslx.conf
- # load the configuration file
- . \${OPENSLX_DEFAULT_CONFDIR}/plugins/vmware/vmware.conf
- load_modules || eerror "The loading of vmware modules failed"
- setup_vmnet0 || eerror "Problems setting up vmnet0 interface"
- setup_vmnet1 || eerror "Problems setting up vmnet1 interface"
- setup_vmnet8 || eerror "Problems setting up vmnet8 interface"
- eend $?
- }
-
- stop() {
- # message output should match the given vendor-os
- ebegin "Stopping vmware background services ..."
- killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \\
- vmware-tray vmnet-dhcpd 2>/dev/null
- # wait for shutting down of interfaces. vmnet needs kinda
- # long
- sleep 1
- unload_modules
- eend $?
- }
- End-of-Here
- return $script;
-}
-
1;
diff --git a/os-plugins/plugins/vmware/OpenSLX/Distro/Suse.pm b/os-plugins/plugins/vmware/OpenSLX/Distro/Suse.pm
index 7d22c70d..c1b2ecf4 100644
--- a/os-plugins/plugins/vmware/OpenSLX/Distro/Suse.pm
+++ b/os-plugins/plugins/vmware/OpenSLX/Distro/Suse.pm
@@ -1,4 +1,4 @@
-# Copyright (c) 2008 - OpenSLX GmbH
+# Copyright (c) 2008..2010 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
@@ -25,209 +25,4 @@ use OpenSLX::Utils;
### interface methods
################################################################################
-sub fillRunlevelScript
-{
- my $self = shift;
- my $location = shift;
- my $kind = shift;
-
- my $script = unshiftHereDoc(<<" End-of-Here");
- #!/bin/sh
- # SuSE compatible start/stop script, generated via stage1 'vmware' plugin
- # installation
- #
- # inspiration taken from vmware start script:
- # Copyright 1998-2007 VMware, Inc. All rights reserved.
- #
- # This script manages the services needed to run VMware software
-
- # Basic support for the Linux Standard Base Specification 1.3
- ### BEGIN INIT INFO
- # Provides: VMware
- # Required-Start: \$syslog
- # Required-Stop:
- # Default-Start: 2 3 5
- # Default-Stop: 0 6
- # Short-Description: Manages the services needed to run VMware software
- # Description: Manages the services needed to run VMware software
- ### END INIT INFO
-
- # helper functions
- load_modules() {
- End-of-Here
-
- # Load modules
- if ($kind eq 'local' || $kind eq 'local25' || $kind eq 'local30') {
- if ($kind eq 'local30') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- # vmplayer 3.0 specific stuff
- insmod /lib/modules/\$(uname -r)/misc/vsock.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmci.ko || return 1
- End-of-Here
- }
- $script .= unshiftHereDoc(<<" End-of-Here");
- # to be filled in via the stage1 configuration script
- insmod /lib/modules/\$(uname -r)/misc/vmmon.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmnet.ko || return 1
- insmod /lib/modules/\$(uname -r)/misc/vmblock.ko 2>/dev/null || return 0
- End-of-Here
- } elsif ($kind eq 'vmpl1.0') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- End-of-Here
- } elsif ($kind eq "vmpl2.0") {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- End-of-Here
- } elsif ($kind eq 'vmpl2.5') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- End-of-Here
- } elsif ($kind eq 'vmpl3.0') {
- $script .= unshiftHereDoc(<<" End-of-Here");
- vmware_kind_path=/opt/openslx/plugin-repo/vmware/${kind}/
- module_src_path=\${vmware_kind_path}/vmroot/modules
- insmod \${module_src_path}/vmmon.ko
- insmod \${module_src_path}/vmnet.ko
- insmod \${module_src_path}/vmblock.ko
- insmod \${module_src_path}/vsock.ko
- insmod \${module_src_path}/vmci.ko
- End-of-Here
- }
-
- # unload modules
- $script .= unshiftHereDoc(<<" End-of-Here");
- }
-
- unload_modules() {
- # to be filled with the proper list within via the stage1
- # configuration script
- rmmod vmmon vmblock vmnet vmmon vmci vsock 2>/dev/null
- }
- End-of-Here
-
- # setup vmnet0 and vmnet8
- # depends on specific stage3 setting. A complete rewrite would be
- # needed (generation of proper runlevel scripts depending on distro
- # and VMware version, see tickets #211, 290)
- $script .= unshiftHereDoc(<<" End-of-Here");
- # the bridged interface
- setup_vmnet0() {
- if [ -n "\$vmnet0" ] ; then
- # the path might be directly point to the plugin dir
- End-of-Here
- if ($kind eq 'vmpl2.5' || $kind eq 'vmpl3.0' || $kind eq 'local25' || $kind eq 'local30') {
- $script .= " $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0\n";
- } else {
- $script .= " $location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vmnet0 eth0\n";
- }
- $script .= unshiftHereDoc(<<" End-of-Here");
- fi
- }
- # we definately prefer the hostonly interface for NATed operation too
- # distinction is made via enabled forwarding
- setup_vmnet1() {
- if [ -n "\$vmnet1" ] ; then
- # the path might be directly point to the plugin dir
- $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \\
- /dev/vmnet1 vmnet1
- dhcpif="\$dhcpif vmnet1"
- ip addr add \$vmnet1 dev vmnet1
- ip link set vmnet1 up
- if [ -n "\$vmnet1nat" ] ; then
- # needs refinement interface name for eth0 is known in stage3 already
- # available from \$nwif
- echo "1" > /proc/sys/net/ipv4/conf/vmnet1/forwarding 2>/dev/null
- echo "1" > /proc/sys/net/ipv4/conf/eth0/forwarding 2>/dev/null
- #iptables -A -s vmnet1 -d eth0
- fi
- $location/vmnet-dhcpd -cf /etc/vmware/dhcpd-vmnet1.conf \\
- -lf /var/run/vmware/dhcpd-vmnet1.leases \\
- -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1 2>/dev/null # or logfile
- fi
- }
- # incomplete ...
- setup_vmnet8() {
- if [ -n "\$vmnet8" ] ; then
- # we don't need the following test. It's handled by
- # XX_vmware.sh
- #test -c /dev/vmnet8 || mknod c 119 8 /dev/vmnet8
- $location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid \\
- /dev/vmnet8 vmnet8
- ip addr add \$vmnet8 dev vmnet8
- ip link set vmnet8 up
- # /etc/vmware/vmnet-natd-8.mac simply contains a mac like 00:50:56:F1:30:50
- $location/vmnet-natd -d /var/run/vmnet-natd-8.pid \\
- -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf 2>/dev/null # or logfile
- $location/vmnet-dhcpd -cf /etc/vmware/dhcpd-vmnet8.conf \\
- -lf /var/run/vmware/dhcpd-vmnet8.leases \\
- -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8 2>/dev/null # or logfile
- fi
- }
- # load the helper stuff
- . /etc/rc.status
- # reset the script status
- rc_reset
-
- case \$1 in
- start)
- echo -n "Starting vmware background services ..."
- # include default directories
- . /etc/opt/openslx/openslx.conf
- # load the configuration file
- . \${OPENSLX_DEFAULT_CONFDIR}/plugins/vmware/vmware.conf
- # hack to access the first serial/parallel port
- chmod a+rw /dev/ttyS0
- chmod a+rw /dev/parport0
- load_modules
- setup_vmnet0
- setup_vmnet1
- setup_vmnet8
- rc_status -v
- ;;
- stop)
- # message output should match the given vendor-os
- echo -n "Stopping vmware background services ..."
- killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \\
- vmware-tray vmnet-dhcpd 2>/dev/null
- # wait for shutting down of interfaces. vmnet needs kinda
- # long
- sleep 1
- unload_modules
- # workaround, because we can kill and unload more as we have
- # started
- rc_reset
- rc_status -v
- ;;
- # we don't need a status yet... at least as long as it is
- # unclear in which path the corresponding binary (see original
- # /etc/init.d/vmware) is in our case
- #status)
- # echo -n "Say something useful here ..."
- #;;
- restart)
- "\$0" stop
- "\$0" start
- ;;
- *)
- echo "Usage: `basename "\$0"` {start|stop|restart}"
- exit 1
- ;;
- esac
- exit 0
- End-of-Here
- return $script;
-}
-
1;
diff --git a/os-plugins/plugins/vmware/OpenSLX/Distro/Ubuntu.pm b/os-plugins/plugins/vmware/OpenSLX/Distro/Ubuntu.pm
index d7ffc2e5..922fb34f 100644
--- a/os-plugins/plugins/vmware/OpenSLX/Distro/Ubuntu.pm
+++ b/os-plugins/plugins/vmware/OpenSLX/Distro/Ubuntu.pm
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2007 - OpenSLX GmbH
+# Copyright (c) 2007..2010 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
diff --git a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm
index 1a4540f0..8cf1c7ab 100644
--- a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm
+++ b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm
@@ -1,4 +1,4 @@
-# Copyright (c) 2008, 2009 - OpenSLX GmbH
+# Copyright (c) 2008..2010 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
@@ -23,6 +23,7 @@ use File::Path;
use OpenSLX::Basics;
use OpenSLX::Utils;
+use OpenSLX::DistroUtils;
sub new
{
@@ -131,12 +132,12 @@ sub getAttrInfo
applies_to_clients => 1,
description => unshiftHereDoc(<<' End-of-Here'),
Which set of VMware binaries to use: installed (local) or provided by the
- plugin itself (vmpl1.0, vmpl2.0, vmpl2.5)?
+ plugin itself (vmpl1.0, vmpl2.0, vmpl2.5, vmpl3.0)?
End-of-Here
# only allow the supported once...
# TODO: modify if we know which of them work
#content_regex => qr{^(local|vmws(5\.5|6.0)|vmpl(1\.0|2\.0))$},
- content_regex => qr{^(local|vmpl2\.0|vmpl1\.0|vmpl2\.5)$},
+ content_regex => qr{^(local|vmpl3\.0||vmpl2\.0|vmpl1\.0|vmpl2\.5)$},
content_descr => 'Allowed values: local, vmpl2.0',
#TODO: what if we don't have a local installation. default
# is still local. Someone has a clue how to test
@@ -300,6 +301,8 @@ sub installationPhase
if (-e "/usr/bin/vmware" && ! -e "/usr/bin/vmware.slx-bak") {
rename("/usr/bin/vmware", "/usr/bin/vmware.slx-bak");
}
+ # write the runlevel script
+ $self->_writeRunlevelScript();
}
sub removalPhase
@@ -374,21 +377,126 @@ sub checkStage3AttrValues
## local, non-general OpenSLX functions
#######################################
-# write the runlevelscript depending on the version
+# Write the runlevelscript
sub _writeRunlevelScript
{
my $self = shift;
- my $location = shift;
- my $file = shift;
- my $kind = shift;
-
- # $location points to the path where vmware helpers are installed
- # call the distrospecific fillup
- # should use the abstract write runlevel script way, see
- # http://lab.openslx.org/repositories/revision/openslx/2405 ff.
- my $runlevelScript = $self->{distro}->fillRunlevelScript($location, $kind);
+ my $kind = $self->{attrs}->{'vmware::kind'} || 'local';
+ my $initfile = newInitFile();
+ my %versionhash = (vmversion => "", vmbuildversion => "");
+ my $vmversion = "";
- spitFile($file, $runlevelScript);
+ my $script = "";
+ my $vmpath = "";
+ my $modpath = "";
+ my $modlist = "";
+ if ($kind =~ /local*/) {
+ $vmpath = "/";
+ $modpath = "/lib/modules/\$(uname -r)/misc";
+ } elsif ($kind =~ /vmpl*/) {
+ $vmpath = "/opt/openslx/plugin-repo/vmware/${kind}";
+ $modpath = "${vmpath}/vmroot/modules";
+ }
+
+ %versionhash = _getVersion("${vmpath}/usr/bin");
+ $vmversion = $versionhash{vmversion};
+ $initfile->setName("vmware-slx");
+ $initfile->setDesc("Setup environment for VMware Workstation or Player ($vmversion).");
+
+ # functions ...
+ $modlist = "vmnet vmmon";
+ $script = unshiftHereDoc(<<" End-of-Here");
+ # VMplayer common stuff
+ insmod ${modpath}/vmmon.ko || return 1
+ insmod ${modpath}/vmnet.ko || return 1
+ End-of-Here
+ if ($kind eq 'local30' || $kind eq 'vmpl3.0') {
+ $script .= unshiftHereDoc(<<" End-of-Here");
+ # VMplayer 3.0 specific stuff
+ insmod ${modpath}/vsock.ko || return 1
+ insmod ${modpath}/vmci.ko || return 1
+ insmod ${modpath}/vmblock.ko || return 1
+ End-of-Here
+ $modlist .= "vsock vmci vmblock";
+ } elsif ($kind eq 'local20' || $kind eq 'vmpl2.0' || $kind eq 'vmpl2.5') {
+ $script .= unshiftHereDoc(<<" End-of-Here");
+ # VMplayer 2.X specific stuff
+ insmod ${modpath}/vmblock.ko
+ End-of-Here
+ $modlist .= "vmblock";
+ }
+ $initfile->addFunction(
+ "load_modules",
+ "$script"
+ );
+ $initfile->addFunction(
+ "unload_modules",
+ "rmmod $modlist 2>/dev/null"
+ );
+ # vmnet interface definition
+ $script = unshiftHereDoc(<<" End-of-Here");
+ if [ -n "\$vmnet1" ] ; then
+ # the path might be directly point to the plugin dir
+ location=$vmpath
+ \$location/usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \\
+ /dev/vmnet1 vmnet1
+ dhcpif="\$dhcpif vmnet1"
+ ip addr add \$vmnet1 dev vmnet1
+ ip link set vmnet1 up
+ if [ -n "\$vmnet1nat" ] ; then
+ echo "1" > /proc/sys/net/ipv4/conf/vmnet1/forwarding 2>/dev/null
+ echo "1" > /proc/sys/net/ipv4/conf/br0/forwarding 2>/dev/null
+ #iptables -A -s vmnet1 -d br0
+ fi
+ \$location/vmnet-dhcpd -cf /etc/vmware/dhcpd-vmnet1.conf \\
+ -lf /var/run/vmware/dhcpd-vmnet1.leases \\
+ -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1 2>/dev/null # or logfile
+ fi
+ End-of-Here
+ $initfile->addFunction(
+ "vmnetif",
+ "$script"
+ );
+ $script = unshiftHereDoc(<<" End-of-Here");
+ # include default directories
+ . /etc/opt/openslx/openslx.conf
+ # load the configuration file
+ . \${OPENSLX_DEFAULT_CONFDIR}/plugins/vmware/vmware.conf
+ # hack to access the first serial/parallel port
+ chmod a+rw /dev/ttyS0
+ chmod a+rw /dev/parport0
+ load_modules
+ vmnetif
+ End-of-Here
+ $initfile->addToCase(
+ "start",
+ "$script"
+ );
+ $script = unshiftHereDoc(<<" End-of-Here");
+ killall vmnet-netifup vmnet-natd vmnet-bridge vmware vmplayer \\
+ vmware-tray vmnet-dhcpd 2>/dev/null
+ # might take a while until all services are shut down
+ sleep 1
+ unload_modules
+ End-of-Here
+ $initfile->addToCase(
+ "stop",
+ "$script"
+ );
+ $initfile->addToCase(
+ 'status',
+ 'vmstatus'
+ );
+ $initfile->addToCase(
+ 'restart',
+ 'stop && start'
+ );
+
+ my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0];
+ my $runlevelscript = getInitFileForDistro($initfile, $distro);
+ # todo: because we dont have distribution or version dependend
+ # init scripts we could put it directly into /etc/init.d...
+ spitFile("$self->{'pluginRepositoryPath'}/vmware-slx", $runlevelscript);
}