diff options
Diffstat (limited to 'os-plugins/plugins/vmware')
| -rw-r--r-- | os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm | 186 | ||||
| -rw-r--r-- | os-plugins/plugins/vmware/OpenSLX/Distro/Fedora.pm | 3 | ||||
| -rw-r--r-- | os-plugins/plugins/vmware/OpenSLX/Distro/Gentoo.pm | 174 | ||||
| -rw-r--r-- | os-plugins/plugins/vmware/OpenSLX/Distro/Suse.pm | 207 | ||||
| -rw-r--r-- | os-plugins/plugins/vmware/OpenSLX/Distro/Ubuntu.pm | 2 | ||||
| -rw-r--r-- | os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm | 233 | ||||
| -rw-r--r-- | os-plugins/plugins/vmware/XX_vmware.sh | 82 | ||||
| -rw-r--r-- | os-plugins/plugins/vmware/files/run-virt.include | 76 | ||||
| -rwxr-xr-x | os-plugins/plugins/vmware/init-hooks/20-nw-bridge-config/bridge.sh | 2 | ||||
| -rwxr-xr-x | os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh | 56 |
10 files changed, 307 insertions, 714 deletions
diff --git a/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm b/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm index 51361f31..d59227ad 100644 --- a/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm +++ b/os-plugins/plugins/vmware/OpenSLX/Distro/Base.pm @@ -44,190 +44,4 @@ 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..4ebaa2b6 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 @@ -255,7 +256,6 @@ sub preInstallationPhase() } } - sub installationPhase { my $self = shift; @@ -300,6 +300,7 @@ sub installationPhase if (-e "/usr/bin/vmware" && ! -e "/usr/bin/vmware.slx-bak") { rename("/usr/bin/vmware", "/usr/bin/vmware.slx-bak"); } + } sub removalPhase @@ -325,9 +326,7 @@ sub checkStage3AttrValues my $vendorOSAttrs = shift; my @problems; - my $vm_kind = $stage3Attrs->{'vmware::kind'} || ''; - - + my $vm_kind = $stage3Attrs->{'vmware::kind'} || ''; my $vmimg = $stage3Attrs->{'vmware::imagesrc'} || ''; if ($vm_kind eq 'local' && ! -x "/usr/lib/vmware/bin/vmplayer") { @@ -343,6 +342,13 @@ sub checkStage3AttrValues ); } + if ($vm_kind eq 'vmpl1.0' && + ! -d "/opt/openslx/plugin-repo/vmware/vmpl1.0/vmroot") { + push @problems, _tr( + "No OpenSLX installation of VMware Player 1 found or installation failed. Using it as virtual machine wouldn't work!" + ); + } + if ($vm_kind eq 'vmpl2.0' && ! -d "/opt/openslx/plugin-repo/vmware/vmpl2.0/vmroot") { push @problems, _tr( @@ -357,10 +363,10 @@ sub checkStage3AttrValues ); } - if ($vm_kind eq 'vmpl1.0' && - ! -d "/opt/openslx/plugin-repo/vmware/vmpl1.0/vmroot") { + if ($vm_kind eq 'vmpl3.0' && + ! -d "/opt/openslx/plugin-repo/vmware/vmpl3.0/vmroot") { push @problems, _tr( - "No OpenSLX installation of VMware Player 1 found or installation failed. Using it as virtual machine wouldn't work!" + "No OpenSLX installation of VMware Player 3 found or installation failed. Using it as virtual machine wouldn't work!" ); } @@ -374,21 +380,143 @@ sub checkStage3AttrValues ## local, non-general OpenSLX functions ####################################### -# write the runlevelscript depending on the version +# Write the runlevelscript +# usage: _writeRunlevelScript("$vmpath", "$kind") sub _writeRunlevelScript { my $self = shift; - my $location = shift; - my $file = shift; + my $vmpath = 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 $initfile = newInitFile(); + + my $script = ""; + my $modpath = ""; + my $modlist = ""; + # vmpath is to be redefined here ... + if ($kind =~ /local*/) { + $vmpath = ""; + $modpath = "/lib/modules/\$(uname -r)/misc"; + } elsif ($kind =~ /vmpl*/) { + $vmpath = "/opt/openslx/plugin-repo/vmware/${kind}"; + $modpath = "${vmpath}/vmroot/modules"; + } - spitFile($file, $runlevelScript); + $initfile->setName("vmware-slx"); + $initfile->setDesc("Setup environment for VMware Workstation or Player ($kind)."); + + # 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}/vmci.ko + insmod ${modpath}/vmblock.ko + insmod ${modpath}/vsock.ko + End-of-Here + $modlist .= "vsock vmci vmblock"; + } elsif ($kind eq 'local20' || $kind eq 'local25' || $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" + ); + # vmnet0,1,8 (bridge, nat, host-only) interface definition + $script = unshiftHereDoc(<<" End-of-Here"); + # let point the path directly to the directory where the binary lives + location="$vmpath/usr/bin" + if [ -n "\$vmnet0" ] ; then + # the path might be directly point to the plugin dir + End-of-Here + if ($kind eq 'vmpl1.0' || $kind eq 'vmpl2.0' || $kind eq 'local10' || $kind eq 'local20') { + $script .= " \$location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vmnet0 eth0\n"; + } else { + $script .= " \$location/vmnet-bridge -d /var/run/vmnet-bridge-0.pid -n 0\n"; + } + $script .= unshiftHereDoc(<<" End-of-Here"); + fi + if [ -n "\$vmnet1" ] ; then + \$location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \\ + /dev/vmnet1 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 + /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \\ + -S /etc/vmware/udhcpd/udhcpd-vmnet1.conf + fi + 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 + echo "1" >/proc/sys/net/ipv4/conf/vmnet8/forwarding 2>/dev/null + echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding 2>/dev/null + iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE + /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \\ + -S /etc/vmware/udhcpd/udhcpd-vmnet8.conf + 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", + "\$0 stop && \$0 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); } @@ -523,12 +651,6 @@ sub _localInstallation my $vmversion = ""; my $vmbuildversion = ""; - my $pluginFilesPath - = "$self->{'openslxBasePath'}/lib/plugins/$self->{'name'}/files"; - my $installationPath = "$self->{'pluginRepositoryPath'}/$kind"; - - mkpath($installationPath); - # if vmware ws is installed, vmplayer is installed, too. # we will only use vmplayer if (-e "/usr/lib/vmware/bin/vmplayer") { @@ -538,37 +660,43 @@ sub _localInstallation $vmversion = $versionhash{vmversion}; $vmbuildversion = $versionhash{vmbuildversion}; - ## Copy needed files - my @files = qw(nvram); - foreach my $file (@files) { - copyFile("$pluginFilesPath/$file", "$installationPath"); + # set version information + # VMplayer 2.0 + if ($vmversion eq "2.0" || $vmversion eq "6.0") { + $kind="local20"; + # VMplayer 2.5 + } elsif ($vmversion eq "2.5" || $vmversion eq "6.5") { + $kind="local25"; + # VMplayer 3.0, Workstation 7.0 + } elsif ($vmversion eq "3.0" || $vmversion eq "7.0") { + $kind="local30"; } + # Create runlevel script depending on detected version + $self->_writeRunlevelScript("$vmpath", "$kind"); - # Create runlevel script -> to be fixed!! - my $runlevelScript = "$self->{'pluginRepositoryPath'}/$kind/vmware.init"; - if ($vmversion eq "2.5") { - $self->_writeRunlevelScript($vmbin, $runlevelScript, "local25"); - } elsif ($vmversion eq "3.0") { - $self->_writeRunlevelScript($vmbin, $runlevelScript, "local30"); - } else { - $self->_writeRunlevelScript($vmbin, $runlevelScript, $kind); + # Create wrapper scripts, kind of localNN is set to local + if ( $kind =~ /local*/ ) { $kind = "local"; } + if (-e "/usr/lib/vmware/bin/vmware") { + $self->_writeWrapperScript("$vmpath", "$kind", "ws"); + } + if (-e "/usr/lib/vmware/bin/vmplayer") { + $self->_writeWrapperScript("$vmpath", "$kind", "player"); } - # Create wrapper scripts - if (-e "/usr/bin/vmware") { - $self->_writeWrapperScript("$vmpath", "$kind", "ws") - } else { - $self->_writeWrapperScript("$vmpath", "$kind", "player") + # copy nvram file + my $pluginFilesPath + = "$self->{'openslxBasePath'}/lib/plugins/$self->{'name'}/files"; + my @files = qw(nvram); + foreach my $file (@files) { + copyFile("$pluginFilesPath/$file", "$self->{'pluginRepositoryPath'}/$kind"); } - } - # else { TODO: errorhandling } - - ## Creating needed config /etc/vmware/config + } # else { TODO: errorhandling if file or string doesn't exist } + + ## creating needed config /etc/vmware/config $self->_writeVmwareConfigs("$kind", "$vmpath"); } - sub _vmpl2Installation { my $self = shift; @@ -595,8 +723,7 @@ sub _vmpl2Installation { system("/bin/sh /opt/openslx/plugin-repo/$self->{'name'}/$kind/install-vmpl.sh $kind"); # Create runlevel script - my $runlevelScript = "$self->{'pluginRepositoryPath'}/$kind/vmware.init"; - $self->_writeRunlevelScript($vmbin, $runlevelScript, $kind); + $self->_writeRunlevelScript($vmpath, $kind); # Create wrapperscripts $self->_writeWrapperScript("$vmpath", "$kind", "player"); @@ -631,8 +758,7 @@ sub _vmpl25Installation { system("/bin/sh /opt/openslx/plugin-repo/$self->{'name'}/$kind/install-vmpl.sh $kind"); # Create runlevel script - my $runlevelScript = "$self->{'pluginRepositoryPath'}/$kind/vmware.init"; - $self->_writeRunlevelScript($vmbin, $runlevelScript, $kind); + $self->_writeRunlevelScript($vmpath, $kind); # Create wrapperscripts $self->_writeWrapperScript("$vmpath", "$kind", "player"); @@ -667,8 +793,7 @@ sub _vmpl1Installation { system("/bin/sh /opt/openslx/plugin-repo/$self->{'name'}/$kind/install-vmpl.sh $kind"); # Create runlevel script - my $runlevelScript = "$self->{'pluginRepositoryPath'}/$kind/vmware.init"; - $self->_writeRunlevelScript($vmbin, $runlevelScript, $kind); + $self->_writeRunlevelScript($vmpath, $kind); # create wrapper scripts $self->_writeWrapperScript("$vmpath", "$kind", "player"); diff --git a/os-plugins/plugins/vmware/XX_vmware.sh b/os-plugins/plugins/vmware/XX_vmware.sh index b31df648..116561f6 100644 --- a/os-plugins/plugins/vmware/XX_vmware.sh +++ b/os-plugins/plugins/vmware/XX_vmware.sh @@ -12,6 +12,10 @@ # script is included from init via the "." load function - thus it has all # variables and functions available +# TODO: +# configs nach /etc/opt/openslx/plugins/vmware +# cp nach run-virt.include + # TODO: nvram,functions # write /etc/vmware/config (if a non-standard location of vmware basedir is # to be configured), /etc/init.d/vmware @@ -43,6 +47,7 @@ if [ -e /initramfs/plugin-conf/vmware.conf ]; then testmkd /dev/shm/vmware 1777 testmkd /mnt/var/run/vmware 1777 testmkd ${PLUGINCONFDIR} + testmkd /mnt/etc/vmware/udhcpd # write the ${PLUGINCONFDIR}/vmware.conf file # check for the several variables and write the several files: @@ -55,27 +60,9 @@ stage3 setup" > ${PLUGINCONFDIR}/vmware.conf if [ "$vmware_bridge" = 1 ] ; then echo "vmnet0=true" >> ${PLUGINCONFDIR}/vmware.conf fi - # write the common dhcpd.conf header for vmnet1,8 - if [ -n "$vmware_vmnet1" -o -n "$vmware_vmnet8" ] ; then - # use the dns servers known to the vmware host - local dnslist=$(echo "$domain_name_servers"|sed "s/ /,/g") - echo "# Common dhcpd.conf header written in stage3 ..." \ - > /mnt/etc/vmware/dhcpd-head.conf - echo "allow unknown-clients;" \ - >> /mnt/etc/vmware/dhcpd-head.conf - echo "default-lease-time 1800;" \ - >> /mnt/etc/vmware/dhcpd-head.conf - echo "max-lease-time 7200;" \ - >> /mnt/etc/vmware/dhcpd-head.conf - echo "option domain-name-servers $dnslist;" \ - >> /mnt/etc/vmware/dhcpd-head.conf - echo "option domain-name \"vm.local\";" \ - >> /mnt/etc/vmware/dhcpd-head.conf - fi # variable might contain ",NAT" which is to be taken off if [ -n "$vmware_vmnet1" ] ; then - cp /mnt/etc/vmware/dhcpd-head.conf /mnt/etc/vmware/dhcpd-vmnet1.conf local vmnet1=${vmware_vmnet1%,*} # x.x.x.x/yy,NAT => 'x.x.x.x/yy' local vmnat=${vmware_vmnet1#$vmnet1*} # x.x.x.x/yy,NAT => ',NAT' local vmip=${vmnet1%/*} # x.x.x.x/yy => 'x.x.x.x'"> @@ -83,26 +70,15 @@ stage3 setup" > ${PLUGINCONFDIR}/vmware.conf local vmsub=$(echo $vmip |sed 's,\(.*\)\..*,\1,') # x.x.x.x => x.x.x echo -e "vmnet1=$vmnet1" >> ${PLUGINCONFDIR}/vmware.conf [ -n "$vmnat" ] && echo "vmnet1nat=true" >> ${PLUGINCONFDIR}/vmware.conf - echo -e "\n# definition for virtual vmnet1 interface" \ - >> /mnt/etc/vmware/dhcpd-vmnet1.conf - echo -e "subnet $(ipcalc -n $vmnet1|sed s/.*=//) netmask \ -$(ipcalc -m $vmnet1|sed s/.*=//) {" \ - >> /mnt/etc/vmware/dhcpd-vmnet1.conf - echo -e "\trange ${vmsub}.10 ${vmsub}.20;" \ - >> /mnt/etc/vmware/dhcpd-vmnet1.conf - echo -e "\toption broadcast-address $(ipcalc -b $vmnet1|sed s/.*=//);" \ - >> /mnt/etc/vmware/dhcpd-vmnet1.conf - # Maybe a different ip is needed s. nat: vmnet="${vmsub}.2" - echo -e "\toption routers $vmip;" \ - >> /mnt/etc/vmware/dhcpd-vmnet1.conf - echo -e "}" \ - >> /mnt/etc/vmware/dhcpd-vmnet1.conf - mknod /dev/vmnet1 c 119 1 + # setting up the udhcpd configuration + sed -e "s,NWIF,vmnet1,;s,/misc/,/vmware/," \ + -e "s,CNETWORK,$vmsub,;s,PIDFILE,/var/run/vmware/udhcpd-vmnet1.pid," \ + -e "s,LEASEFILE,/var/run/vmware/udhcpd-vmnet1.leases," \ + /mnt/etc/opt/openslx/udhcpd.conf >/mnt/etc/vmware/udhcpd/udhcpd-vmnet1.conf fi # vmware nat interface configuration if [ -n "$vmware_vmnet8" ] ; then - cp /mnt/etc/vmware/dhcpd-head.conf /mnt/etc/vmware/dhcpd-vmnet8.conf local vmnet8ip=${vmware_vmnet8%/*} local vmpx=${vmware_vmnet8#*/} local vmsub=$(echo $vmnet8ip |sed 's,\(.*\)\..*,\1,') # x.x.x.x => x.x.x"> @@ -111,19 +87,12 @@ $(ipcalc -m $vmnet1|sed s/.*=//) {" \ local vmip="${vmsub}.1" local vmnet="${vmsub}.2" echo -e "vmnet8=$vmip/$vmpx" >>${PLUGINCONFDIR}/vmware.conf - echo -e "\n# definition for virtual vmnet8 interface" \ - >> /mnt/etc/vmware/dhcpd-vmnet8.conf - echo -e "subnet $(ipcalc -n $vmip/$vmpx|sed s/.*=//) netmask \ -$(ipcalc -m $vmip/$vmpx|sed s/.*=//) {" \ - >> /mnt/etc/vmware/dhcpd-vmnet8.conf - echo -e "\trange ${vmsub}.10 ${vmsub}.20;" \ - >> /mnt/etc/vmware/dhcpd-vmnet8.conf - echo -e "\toption broadcast-address $(ipcalc -b $vmip/$vmpx|sed s/.*=//);" \ - >> /mnt/etc/vmware/dhcpd-vmnet8.conf - echo -e "\toption routers $vmnet;" \ - >> /mnt/etc/vmware/dhcpd-vmnet8.conf - echo -e "}" \ - >> /mnt/etc/vmware/dhcpd-vmnet8.conf + # setting up the udhcpd configuration + sed -e "s,NWIF,vmnet8,;s,/misc/,/vmware/," \ + -e "s,CNETWORK,$vmsub,;s,PIDFILE,/var/run/vmware/udhcpd-vmnet8.pid," \ + -e "s,LEASEFILE,/var/run/vmware/udhcpd-vmnet8.leases," \ + /mnt/etc/opt/openslx/udhcpd.conf >/mnt/etc/vmware/udhcpd/udhcpd-vmnet8.conf + # might be not needed any more ... echo -e "# Linux NAT configuration file" \ > /mnt/etc/vmware/nat.conf echo -e "[host]" \ @@ -143,11 +112,9 @@ $(ipcalc -m $vmip/$vmpx|sed s/.*=//) {" \ echo -e "[incomingudp]" \ >> /mnt/etc/vmware/nat.conf echo "00:50:56:F1:30:50" > /mnt/etc/vmware/vmnet-natd-8.mac - mknod /dev/vmnet8 c 119 8 fi # copy the runlevel script to the proper place and activate it - sed "s/eth0/$nwif/g" ${PLUGINDIR}/${vmware_kind}/vmware.init \ - > /mnt/etc/init.d/vmware-env \ + sed "s/eth0/$nwif/g" ${PLUGINDIR}/vmware-slx > /mnt/etc/init.d/vmware-env \ || echo " * Error copying runlevel script. Shouldn't happen." chmod a+x /mnt/etc/init.d/vmware-env rllinker "vmware-env" 20 2 @@ -174,16 +141,16 @@ ${vmware_imagesrc}." nonfatal ############################################################################ # vmware stuff second part: setting up the environment - # make vmware dhcpd more silent - touch /mnt/var/run/vmware/dhcpd-vmnet1.leases \ - /mnt/var/run/vmware/dhcpd-vmnet8.leases + # make udhcpd more silent + touch /mnt/var/run/vmware/udhcpd-vmnet1.leases \ + /mnt/var/run/vmware/udhcpd-vmnet8.leases # create the needed devices which effects all vmware options # they are not created automatically via module load - for i in "/dev/vmnet0 c 119 0" "/dev/vmmon c 10 165"; do + for i in "/dev/vmnet0 c 119 0" "/dev/vmnet1 c 119 1" \ + "/dev/vmnet8 c 119 8" "/dev/vmmon c 10 165"; do mknod $i done - chmod 0700 /dev/vmnet* echo -e "usbfs\t\t/proc/bus/usb\tusbfs\t\tauto\t\t 0 0" >> /mnt/etc/fstab @@ -196,9 +163,8 @@ ${vmware_imagesrc}." nonfatal prefvmx.useRecommendedLockedMemSize = "TRUE"' | sed -e "s/^ *//" \ >/mnt/etc/vmware/config - # copy version depending files - the vmchooser expects for every virtua- - # lization plugin a file named after it (here run-vmware.include) - cp ${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR}/run-vmware.include + # copy virtualization include files to config dir + cp ${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} # copy version depending files cp ${PLUGINDIR}/${vmware_kind}/vmplayer ${BINDIR}/vmplayer if [ -e ${PLUGINDIR}/${vmware_kind}/vmware ]; then diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include index 6641d491..8b91275a 100644 --- a/os-plugins/plugins/vmware/files/run-virt.include +++ b/os-plugins/plugins/vmware/files/run-virt.include @@ -1,7 +1,7 @@ # run-virt.include # ----------------------------------------------------------------------------- -# Copyright (c) 2009 - RZ Uni Freiburg -# Copyright (c) 2009 - OpenSLX GmbH +# Copyright (c) 2009..2010 - RZ Uni Freiburg +# Copyright (c) 2009..2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -13,7 +13,7 @@ # ----------------------------------------------------------------------------- # run-virt.include # - component for vmware/player of the vmchooser plugin run-virt.sh -# ----------------------------------------------------------------------------- +################################################################################ # configuration writer functions ################################################################################ @@ -42,7 +42,7 @@ sharedFolder.option = \"alwaysEnabled\"" >>${conffile} esac case "$vmversion" in 2.5|3.*|6.5|7.*) - if [ "${cpu_cores}" -ge "2" 2>/dev/null]; then + if [ "${cpu_cores}" -ge "2" 2>/dev/null ]; then numvcpus="2" fi cap3d="TRUE" # helper var for loging output @@ -140,8 +140,8 @@ usb.generic.autoconnect = \"TRUE\" sharedFolder0.present = \"TRUE\" sharedFolder0.enabled = \"${shared_folder}\" sharedFolder0.expiration = \"never\" -sharedFolder0.guestName = \"Home\" -sharedFolder0.hostPath = \"${HOME}\" +sharedFolder0.guestName = \"${sharename}\" +sharedFolder0.hostPath = \"${sharepath}\" sharedFolder0.readAccess = \"TRUE\" sharedFolder0.writeAccess = \"TRUE\" sharedFolder.maxNum = \"1\" @@ -300,30 +300,41 @@ case "$parallel" in ;; esac -# percentage of memory to use for vmwares in standard case -permem=30 -if [ "${totalmem}" -ge "1600" ]; then - permem=40 -fi -# check if /tmp is on harddisk -if grep -qe "/dev/.* /tmp " /proc/mounts ; then - permem=60 - id44="1" - # Hack, if more than 2,5G RAM use 40% of Ram and write vmem into Ram as well - # (40% vmware | 40% confdir(vmem...) | 20% host - # VMplayer 2+ issue +# adjust memory available for vmware guests +if [ -n "${forcemem}" ]; then + mem="${forcemem}" +else + case "$vmversion" in + 2.*) + permem=30 + ;; + 3.*) + permem=25 + ;; + esac if [ "${totalmem}" -ge "2500" ]; then permem=40 - confdir=/dev/shm/vmware/$USER - conffile=${confdir}/run-vmware.conf - mkdir -p /dev/shm/vmware/$USER fi -fi -mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) -if [ "${id44}" = "1" ]; then - memhost=$(expr ${totalmem} - ${mem}) -else - memhost=$(expr ${totalmem} - ${mem} - ${mem}) + # check if /tmp is on harddisk + if grep -qe "/dev/.* /tmp " /proc/mounts ; then + permem=60 + id44="1" + # Hack, if more than 2,5G RAM use 40% of Ram and write vmem into Ram as well + # (40% vmware | 40% confdir(vmem...) | 20% host + # VMplayer 2+ issue + if [ "${totalmem}" -ge "2500" ]; then + permem=40 + confdir=/dev/shm/vmware/$USER + conffile=${confdir}/run-vmware.conf + mkdir -p /dev/shm/vmware/$USER + fi + fi + mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) + if [ "${id44}" = "1" ]; then + hostmem=$(expr ${totalmem} - ${mem}) + else + hostmem=$(expr ${totalmem} - ${mem} - ${mem}) + fi fi # check if ide/scsi and hwver of image @@ -390,8 +401,8 @@ writelog "# File created by $0 (VMversion ${vmversion})\n# on $(date)\n" writelog "Starting with non-persistent mode ...\n" # check memory range -if [ "${mem}" -lt "256" ] || [ "${memhost}" -lt "256" ]; then - writelog "\tMemory out of range: ${mem} MB (guest) / ${memhost} MB (host)!" +if [ "${mem}" -lt "256" ] || [ "${hostmem}" -lt "256" ]; then + writelog "\tMemory out of range: ${mem} MB (guest) / ${hostmem} MB (host)!" writelog "\tMin. 256 MB for host and guest!" exit 1 fi @@ -413,7 +424,8 @@ if [ -n "${network_card}" ]; then writelog "\tNet Adaptor:\t${network_card}" fi writelog "\tMem:\t\t${mem} MB" -writelog "\tHostmem:\t${memhost} MB" +# echo nur wenn hostmem gesetzt +[ -n "${hostmem}" ] && writelog "\tHostmem:\t${hostmem} MB" writelog "\tMax. res.:\t${xres}x${yres}" writelog "\tCD-ROM1:\t${cdrom0}" writelog "\tCD-ROM2:\t${cdrom1}" @@ -443,6 +455,6 @@ writelog "" # finally set env for run-virt.sh ################################################################################ -VIRTCMD=vmplayer +# using the modified version of the wrapper script +VIRTCMD="${OPENSLX_DEFAULT_BINDIR}/vmplayer" VIRTCMDOPTS="${vmopt} ${conffile}" - diff --git a/os-plugins/plugins/vmware/init-hooks/20-nw-bridge-config/bridge.sh b/os-plugins/plugins/vmware/init-hooks/20-nw-bridge-config/bridge.sh index 6aabe8ad..07113867 100755 --- a/os-plugins/plugins/vmware/init-hooks/20-nw-bridge-config/bridge.sh +++ b/os-plugins/plugins/vmware/init-hooks/20-nw-bridge-config/bridge.sh @@ -1,5 +1,5 @@ #!/bin/ash -# 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 diff --git a/os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh b/os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh new file mode 100755 index 00000000..6bdfb8f1 --- /dev/null +++ b/os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh @@ -0,0 +1,56 @@ +#!/bin/ash +# Copyright (c) 2010 - OpenSLX GmbH +# +# This program 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 +# +# Init hook to create a bridge on the active network interface +# (should be kept identical to the files of virtualbox and qemukvm plugins) +############################################################################# + +# configuring dhcpd stub for virtual networks +testmkd /mnt/etc/opt/openslx +echo " +# general udhcpd configuration file for virtual machines written by +# $0 during OpenSLX stage3 configuration + +# start and end of the IP lease block +start CNETWORK.20 +end CNETWORK.100 + +# interface that udhcpd will use +interface NWIF + +# how long an offered address is reserved (leased) in seconds +offer_time 6000 + +# location of the leases file +lease_file LEASEFILE + +# location of the pid file +pidfile PIDFILE + +opt dns ${domain_name_servers} +option subnet 255.255.255.0 +opt router CNETWORK.254 +opt wins CNETWORK.10 +option domain virtual.site ${domain_name} + +# additional options known to udhcpd +#subnet #timezone +#router #timesvr +#namesvr #dns +#logsvr #cookiesvr +#lprsvr #bootsize +#domain #swapsvr +#rootpath #ipttl +#mtu #broadcast +#wins #lease +#ntpsrv #tftp +#bootfile +" >/mnt/etc/opt/openslx/udhcpd.conf |
