From b7f6ea0dd458cee86da6060eda20062e8719c6b1 Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Sun, 28 Feb 2010 12:30:13 +0100 Subject: Updating vmchooser, heavy cleanup in vmware plugin ... --- .../plugins/vmware/OpenSLX/OSPlugin/vmware.pm | 131 ++++++++++----------- 1 file changed, 64 insertions(+), 67 deletions(-) (limited to 'os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm') diff --git a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm index 0be6fe74..72629a14 100644 --- a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm +++ b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm @@ -300,8 +300,7 @@ 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 @@ -327,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") { @@ -345,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( @@ -359,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!" ); } @@ -377,30 +381,28 @@ sub checkStage3AttrValues ####################################### # Write the runlevelscript +# usage: _writeRunlevelScript("$vmpath", "$kind") sub _writeRunlevelScript { my $self = shift; - my $kind = $self->{attrs}->{'vmware::kind'} || 'local'; + my $vmpath = shift; + my $kind = shift; my $initfile = newInitFile(); - my %versionhash = (vmversion => "", vmbuildversion => ""); - my $vmversion = ""; my $script = ""; - my $vmpath = ""; my $modpath = ""; my $modlist = ""; + # vmpath is to be redefined here ... if ($kind =~ /local*/) { - $vmpath = "/"; + $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)."); + $initfile->setDesc("Setup environment for VMware Workstation or Player ($kind)."); # functions ... $modlist = "vmnet vmmon"; @@ -417,7 +419,7 @@ sub _writeRunlevelScript 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') { + } 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 @@ -435,21 +437,20 @@ sub _writeRunlevelScript # 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 + location="$vmpath/usr/bin" 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 { + 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"); + $script .= unshiftHereDoc(<<" End-of-Here"); fi if [ -n "\$vmnet1" ] ; then - \$location/usr/bin/vmnet-netifup -d /var/run/vmnet-netifup-vmnet1.pid \\ + \$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 @@ -458,7 +459,7 @@ sub _writeRunlevelScript #iptables -A -s vmnet1 -d br0 fi /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \\ - -S /etc/vmware/udhcpd-vmnet1.conf/udhcpd.conf + -S /etc/vmware/udhcpd/udhcpd-vmnet1.conf fi if [ -n "\$vmnet8" ] ; then \$location/vmnet-netifup -d /var/run/vmnet-netifup-vmnet8.pid \\ @@ -469,9 +470,8 @@ sub _writeRunlevelScript # \$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 /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \\ - -S /etc/vmware/udhcpd-vmnet8.conf/udhcpd.conf - fi - } + -S /etc/vmware/udhcpd/udhcpd-vmnet8.conf + fi End-of-Here $initfile->addFunction( "vmnetif", @@ -504,12 +504,12 @@ sub _writeRunlevelScript "$script" ); $initfile->addToCase( - 'status', - 'vmstatus' + "status", + "vmstatus" ); $initfile->addToCase( - 'restart', - '$0 stop && $0 start' + "restart", + "\$0 stop && \$0 start" ); my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0]; @@ -651,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") { @@ -666,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; @@ -723,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"); @@ -759,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"); @@ -795,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"); -- cgit v1.2.3-55-g7522