From ee7ee5f951463ac421d3db22522d378a202fbb51 Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Fri, 21 Mar 2008 14:28:58 +0000 Subject: Some changes for the vmware plugin to integrate properly ... git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1667 95ad53e4-c205-0410-b2fa-d234c58c8868 --- .../plugins/vmware/OpenSLX/OSPlugin/vmware.pm | 22 ++-- os-plugins/plugins/vmware/XX_vmware.sh | 38 +++---- os-plugins/plugins/vmware/files/vmware-init | 115 +++++++++++++++++++++ os-plugins/plugins/vmware/files/vmware-startscript | 115 --------------------- 4 files changed, 141 insertions(+), 149 deletions(-) create mode 100755 os-plugins/plugins/vmware/files/vmware-init delete mode 100755 os-plugins/plugins/vmware/files/vmware-startscript diff --git a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm index ab975506..4ccb5850 100644 --- a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm +++ b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm @@ -18,6 +18,7 @@ use warnings; use base qw(OpenSLX::OSPlugin::Base); +use File::Basename; use File::Path; use OpenSLX::Basics; @@ -98,7 +99,7 @@ sub getAttrInfo to the ethernet the host is connected to) be enabled End-of-Here content_descr => 'Allowed values: 0 or 1', - default => '', + default => '1', }, # attribute 'vmnet1' defines if the host connection network mode # should be switched on and NAT should be enabled @@ -110,7 +111,7 @@ sub getAttrInfo Format ServerIP/Netprefix,NAT enables NAT/Masquerading End-of-Here content_descr => 'Allowed value: IP/Prefix[,NAT]', - default => '', + default => '192.168.101.1/24,NAT', }, # attribute 'vmnet8' defines if vmware specific NATed network mode # should be switched on @@ -121,7 +122,7 @@ sub getAttrInfo Format ServerIP/Netprefix End-of-Here content_descr => 'Allowed value: IP/Prefix', - default => '', + default => '192.168.102.1/24', }, # is to be discussed how to handle this - there is no single set of # vmware files!! @@ -145,17 +146,19 @@ sub getAttrInfo sub installationPhase { my $self = shift; - my $pluginRepositoryPath = shift; - my $pluginTempPath = shift; - my $openslxPath = shift; + + $self->{pluginRepositoryPath} = shift; + $self->{pluginTempPath} = shift; + $self->{openslxPath} = shift; + $self->{attrs} = shift; # get path of files we need to install - my $pluginFilesPath = "$openslxPath/lib/plugins/$self->{'name'}/files"; + my $pluginFilesPath = "$self->{'openslxPath'}/lib/plugins/$self->{'name'}/files"; # copy all needed files now - my @files = qw( dhcpd.conf nat.conf nvram.5.0 runvmware-v2 ); + my @files = qw( vmware-init nvram.5.0 runvmware-v2 ); foreach my $file (@files) { - copyFile("$pluginFilesPath/$file", $pluginRepositoryPath); + copyFile("$pluginFilesPath/$file", $self->{'pluginRepositoryPath'}); } } @@ -164,7 +167,6 @@ sub removalPhase my $self = shift; my $pluginRepositoryPath = shift; my $pluginTempPath = shift; - my $openslxPath = shift; rmtree ( [ $pluginRepositoryPath ] ); diff --git a/os-plugins/plugins/vmware/XX_vmware.sh b/os-plugins/plugins/vmware/XX_vmware.sh index 47697c4d..e1d0d84b 100644 --- a/os-plugins/plugins/vmware/XX_vmware.sh +++ b/os-plugins/plugins/vmware/XX_vmware.sh @@ -40,7 +40,11 @@ if [ -e /initramfs/plugin-conf/vmware.conf ]; then . /etc/sysconfig/config # prepare all needed vmware configuration files - testmkd /mnt/etc/vmware + if [ -d /mnt/etc/vmware ] ; then + rm -rf /mnt/etc/vmware/* + else + mkdir -p /mnt/etc/vmware + fi # write the /etc/vmware/slxvmconfig file # check for the several variables and write the several files: # dhcpd.conf for vmnet* interfaces @@ -90,7 +94,12 @@ device = /dev/vmnet8\nactiveFTP = 1\n[udp]\ntimeout = 60\n[incomingtcp]\n\ [incomingudp]" > /mnt/etc/vmware/nat.conf echo "00:50:56:F1:30:50" > /mnt/etc/vmware/vmnet-natd-8.mac fi - + # copy the runlevelscript to the proper place + cp /mnt/opt/openslx/plugin-repo/vmware/vmware-init \ + /mnt/etc/${D_INITDIR}/vmware + rllinker "vmware" 20 2 + + echo " * vmware part 1" ############################################################################# # vmware stuff first part: two scenarios @@ -105,8 +114,8 @@ device = /dev/vmnet8\nactiveFTP = 1\n[udp]\ntimeout = 60\n[incomingtcp]\n\ # get source of vmware image server (get type, server and path) if strinstr "/" "${vmware_imagesrc}" ; then vmimgprot=$(uri_token ${vmware_imagesrc} prot) - vmimgserv=$(uri_token ${vmware_imagesrc} server) - vmimgpath="$(uri_token ${vmware_imagesrc} path)" + vmimgserv=$(uri_token ${vmware_imagesrc} server) + vmimgpath="$(uri_token ${vmware_imagesrc} path)" fi if [ -n "${vmimgserv}" ] ; then testmkd /mnt/var/lib/vmware @@ -139,8 +148,7 @@ device = /dev/vmnet8\nactiveFTP = 1\n[udp]\ntimeout = 60\n[incomingtcp]\n\ # vmware stuff second part: setting up the environment # create needed directories and files - for i in /etc/vmware/vmnet1/dhcpd /etc/vmware/vmnet8/nat \ - /etc/vmware/vmnet8/dhcpd /var/run/vmware /etc/vmware/loopimg \ + for i in /var/run/vmware /etc/vmware/loopimg \ /etc/vmware/fd-loop /var/X11R6/bin /etc/X11/sessions; do testmkd /mnt/$i done @@ -183,30 +191,12 @@ device = /dev/vmnet8\nactiveFTP = 1\n[udp]\ntimeout = 60\n[incomingtcp]\n\ # needed for VMware 5.5.3 and versions below echo -e "\tmount -t usbfs usbfs /proc/bus/usb 2>/dev/null" \ >>/mnt/etc/${D_INITDIR}/boot.slx - - # link /etc/init.d/vmware, so it starts uppon boot - if [ -f /mnt/etc/${D_INITDIR}/vmware ] ; then - rllinker "vmware" 20 2 - else - error "df_errvmw" nonfatal - fi chmod 1777 /mnt/var/run/vmware # define a variable where gdm/kdm should look for additional sessions # do we really need it? looks like we can delete it... # export vmsessions=/var/lib/vmware/vmsessions - # we configured vmware, so we can delete the not_configured file - rm /mnt/etc/vmware/not_configured 2>/dev/null - - # copy dhcpd.conf and nat for vmnet8 (nat) - # fixme: It should be possible to start just one vmware dhcp which should - # listen to both interfaces vmnet1 and vmnet8 ... - cp /mnt/opt/openslx/plugin-repo/vmware/dhcpd.conf \ - /mnt/etc/vmware/vmnet8/dhcpd 2>/dev/null - cp /mnt/opt/openslx/plugin-repo/vmware/nat.conf \ - /mnt/etc/vmware/vmnet8/nat 2>/dev/null - # TODO: perhaps we can a) kick out vmdir # b) configure vmdir by plugin configuration # TODO: How to start it. See Wiki. Currently a) implemnted diff --git a/os-plugins/plugins/vmware/files/vmware-init b/os-plugins/plugins/vmware/files/vmware-init new file mode 100755 index 00000000..d41230ca --- /dev/null +++ b/os-plugins/plugins/vmware/files/vmware-init @@ -0,0 +1,115 @@ +#!/bin/sh +# +# parts 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 +# Used by insserv and other LSB compliant tools. +### BEGIN INIT INFO +# Provides: VMware +# Required-Start: $network $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 + +# prereqs: +# 1) a) this script b) the modules (vmmon, vmblock, vmnet) match the +# installed vmware/player version (ensured by stage1 install) +# 2) the script is tailored to the vendor-os we are running +# 3) the script checks a configuration file to know which modes to +# prepare +# 4) we use the dhcp-server for ALL internal interfaces we are running +# 5) stage3 produces a configfile /etc/vmware/slxvmconfig where the +# settings of networking etc. are made + +# read the configuration file generated in stage3 to configure the +# host internal interfaces +. /etc/vmware/slxvmconfig + + +load_modules() { + # to be filled in via the stage1 configuration script + modprobe -qa vmmon vmnet vmblock 2>/dev/null + # most probably nobody wants to run the parallel port driver ... + #modprobe vm... +} +unload_modules() { + # to be filled with the proper list within via the stage1 configuration + # script + rmmod vmmon vmblock vmnet 2>/dev/null +} +# the bridged interface +setup_vmnet0() { + if [ -n "$vmnet0" ] ; then + # the path might be directly point to the plugin dir + /usr/bin/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vmnet0 eth0 + 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 + /usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \ + /dev/vmnet1 vmnet1 + dhcpif="$dhcpif vmnet1" + ip addr add $vmnet1 dev vmnet1 + 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 + fi +} +# incomplete ... +setup_vmnet8() { + if [ -n "$vmnet8" ] ; then + test -c /dev/vmnet1 || mknod c 119 8 /dev/vmnet8 + # /etc/vmware/vmnet-natd-8.mac simply contains a mac like 00:50:56:F1:30:50 + /usr/bin/vmnet-natd -d /var/run/vmnet-natd-8.pid \ + -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf + dhcpif="$dhcpif vmnet8" + ip addr add $vmnet8 dev vmnet8 + fi +} +runvmdhcpd() { + if [ -n "$dhcpif" ] ; then + # the path might be directly point to the plugin dir + mkdir /var/run/vmware 2>/dev/null + /usr/bin/vmnet-dhcpd -cf /etc/vmware/dhcpd.conf -lf \ + /var/run/vmware/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid $dhcpif + fi +} + +case $1 in + start) + # message output should match the given vendor-os + echo "Starting vmware background services ..." + load_modules + setup_vmnet0 + setup_vmnet1 + setup_vmnet8 + runvmdhcpd + ;; + 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 2>/dev/null + # wait for shutting down of interfaces + usleep 50000 + unload_modules + ;; + status) + echo "Say something useful here ..." + ;; +esac + +exit 0 diff --git a/os-plugins/plugins/vmware/files/vmware-startscript b/os-plugins/plugins/vmware/files/vmware-startscript deleted file mode 100755 index d41230ca..00000000 --- a/os-plugins/plugins/vmware/files/vmware-startscript +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh -# -# parts 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 -# Used by insserv and other LSB compliant tools. -### BEGIN INIT INFO -# Provides: VMware -# Required-Start: $network $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 - -# prereqs: -# 1) a) this script b) the modules (vmmon, vmblock, vmnet) match the -# installed vmware/player version (ensured by stage1 install) -# 2) the script is tailored to the vendor-os we are running -# 3) the script checks a configuration file to know which modes to -# prepare -# 4) we use the dhcp-server for ALL internal interfaces we are running -# 5) stage3 produces a configfile /etc/vmware/slxvmconfig where the -# settings of networking etc. are made - -# read the configuration file generated in stage3 to configure the -# host internal interfaces -. /etc/vmware/slxvmconfig - - -load_modules() { - # to be filled in via the stage1 configuration script - modprobe -qa vmmon vmnet vmblock 2>/dev/null - # most probably nobody wants to run the parallel port driver ... - #modprobe vm... -} -unload_modules() { - # to be filled with the proper list within via the stage1 configuration - # script - rmmod vmmon vmblock vmnet 2>/dev/null -} -# the bridged interface -setup_vmnet0() { - if [ -n "$vmnet0" ] ; then - # the path might be directly point to the plugin dir - /usr/bin/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vmnet0 eth0 - 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 - /usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \ - /dev/vmnet1 vmnet1 - dhcpif="$dhcpif vmnet1" - ip addr add $vmnet1 dev vmnet1 - 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 - fi -} -# incomplete ... -setup_vmnet8() { - if [ -n "$vmnet8" ] ; then - test -c /dev/vmnet1 || mknod c 119 8 /dev/vmnet8 - # /etc/vmware/vmnet-natd-8.mac simply contains a mac like 00:50:56:F1:30:50 - /usr/bin/vmnet-natd -d /var/run/vmnet-natd-8.pid \ - -m /etc/vmware/vmnet-natd-8.mac -c /etc/vmware/nat.conf - dhcpif="$dhcpif vmnet8" - ip addr add $vmnet8 dev vmnet8 - fi -} -runvmdhcpd() { - if [ -n "$dhcpif" ] ; then - # the path might be directly point to the plugin dir - mkdir /var/run/vmware 2>/dev/null - /usr/bin/vmnet-dhcpd -cf /etc/vmware/dhcpd.conf -lf \ - /var/run/vmware/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid $dhcpif - fi -} - -case $1 in - start) - # message output should match the given vendor-os - echo "Starting vmware background services ..." - load_modules - setup_vmnet0 - setup_vmnet1 - setup_vmnet8 - runvmdhcpd - ;; - 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 2>/dev/null - # wait for shutting down of interfaces - usleep 50000 - unload_modules - ;; - status) - echo "Say something useful here ..." - ;; -esac - -exit 0 -- cgit v1.2.3-55-g7522