From 86feb9d871595f4c1efe4e521ba2cdae021aa59b Mon Sep 17 00:00:00 2001 From: Dirk von Suchodoletz Date: Wed, 18 Feb 2009 21:49:44 +0000 Subject: More on the new virtualization starter framework. git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2609 95ad53e4-c205-0410-b2fa-d234c58c8868 --- .../plugins/vmware/OpenSLX/OSPlugin/vmware.pm | 99 ++++++++++++---------- 1 file changed, 52 insertions(+), 47 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 f52365d5..9835bb33 100644 --- a/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm +++ b/os-plugins/plugins/vmware/OpenSLX/OSPlugin/vmware.pm @@ -267,6 +267,10 @@ sub installationPhase $self->{openslxConfigPath} = $info->{'openslx-config-path'}; $self->{attrs} = $info->{'plugin-attrs'}; + # copy common part of run-virt.include to the appropriate place for + # inclusion in stage4 + copyFile("$self->{openslxBasePath}/lib/plugins/vmware/files/run-virt.include", + "$self->{pluginRepositoryPath}/"); # kinds we will configure and install # TODO: write a list of installed/setted up and check it in stage3 @@ -298,9 +302,6 @@ sub installationPhase linkFile("/var/X11R6/bin/vmware", "/usr/bin/vmware"); rename("/usr/bin/vmware", "/usr/bin/vmware.slx-bak"); } - # copy run-virt.include to the appropriate place for inclusion in stage4 - copyFile("$self->{openslxBasePath}/lib/plugins/vmware/files/run-virt.include", - "$self->{pluginRepositoryPath}/"); } sub removalPhase @@ -387,10 +388,6 @@ sub _writeRunlevelScript # call the distrospecific fillup my $runlevelScript = $self->{distro}->fillRunlevelScript($location, $kind); - # OLTA: this backup strategy is useless if invoked twice, so I have - # deactivated it - # rename($file, "${file}.slx-bak") if -e $file; - spitFile($file, $runlevelScript); } @@ -459,13 +456,50 @@ sub _writeVmwareConfig { my $self = shift; my $kind = shift; my $vmpath = shift; + my %versionhash = (vmversion => "", vmbuildversion => ""); + my $vmversion = ""; + my $vmbuildversion = ""; + my $config = "libdir=\"$vmpath\"\n"; - my $config = "libdir = \"$vmpath\"\n"; + %versionhash = _getVersion($vmpath); + + $config .= "version=\"".$versionhash{vmversion}."\"\n"; + $config .= "buildversion=\"".$versionhash{vmbuildversion}."\""; spitFile("$self->{'pluginRepositoryPath'}/$kind/config", $config); chmod 0755, "$self->{'pluginRepositoryPath'}/$kind/config"; } +sub _getVersion { + + my $vmpath = shift; + my $vmversion = ""; + my $vmbuildversion = ""; + my %versioninfo = (vmversion => "", vmbuildversion => ""); + + # get version information about installed vmplayer + open(FH, "$vmpath/bin/vmplayer"); + $/ = undef; + my $data = ; + close FH; + # depending on the installation it could differ and has multiple build + # strings + if ($data =~ m{[^\d\.](\d\.\d) build-(\d+)}) { + $vmversion = $1; + $vmbuildversion = $2; + } + if ($data =~ m{\0(2\.[05])\.[0-9]}) { + $vmversion = $1; + } + # else { TODO: errorhandling if file or string doesn't exist } + chomp($vmversion); + chomp($vmbuildversion); + + $versioninfo{vmversion} = $vmversion; + $versioninfo{vmbuildversion} = $vmbuildversion; + return %versioninfo; +} + ######################################################################## ## Functions, which setup the different environments (local, ws-v(5.5|6), ## player-v(1|2) @@ -481,6 +515,7 @@ sub _localInstallation my $kind = "local"; my $vmpath = "/usr/lib/vmware"; my $vmbin = "/usr/bin"; + my %versionhash = (vmversion => "", vmbuildversion => ""); my $vmversion = ""; my $vmbuildversion = ""; @@ -494,41 +529,12 @@ sub _localInstallation # we will only use vmplayer if (-e "/usr/lib/vmware/bin/vmplayer") { - ## ## Get and write version information + %versionhash = _getVersion($vmpath); + $vmversion = $versionhash{vmversion}; + $vmbuildversion = $versionhash{vmbuildversion}; - # get version information about installed vmplayer - open(FH, "/usr/lib/vmware/bin/vmplayer"); - $/ = undef; - my $data = ; - close FH; - # perhaps we need to recheck the following check. depending - # on the installation it could differ and has multiple build- - # strings - if ($data =~ m{[^\d\.](\d\.\d) build-(\d+)}) { - $vmversion = $1; - $vmbuildversion = $2; - } - if ($data =~ m{\0(2\.[05])\.[0-9]}) { - $vmversion = $1; - } - # else { TODO: errorhandling if file or string doesn't exist } - chomp($vmversion); - chomp($vmbuildversion); - - # write informations about local installed vmplayer in file - # TODO: perhaps we don't need this file. - # TODO2: write vmbuildversion and stuff in runvmware in stage1 - open FILE, ">$self->{'pluginRepositoryPath'}/$kind/versioninfo.txt" - or die $!; - print FILE "vmversion=\"$vmversion\"\n"; - print FILE "vmbuildversion=\"$vmbuildversion\"\n"; - close FILE; - - ## ## Copy needed files - - # copy 'normal' needed files my @files = qw(nvram.5.0); foreach my $file (@files) { copyFile("$pluginFilesPath/$file", "$installationPath"); @@ -545,8 +551,7 @@ sub _localInstallation copyFile("$pluginFilesPath/runvmware-player-v25", "$installationPath", "runvmware"); } - ## - ## Create runlevel script + ## Create runlevel script -> to be fixed!! my $runlevelScript = "$self->{'pluginRepositoryPath'}/$kind/vmware.init"; if ($vmversion eq "2.5") { $self->_writeRunlevelScript($vmbin, $runlevelScript, "local25"); @@ -554,7 +559,6 @@ sub _localInstallation $self->_writeRunlevelScript($vmbin, $runlevelScript, $kind); } - ## ## Create wrapperscripts if (-e "/usr/bin/vmware") { $self->_writeWrapperScript("$vmpath", "$kind", "ws") @@ -564,6 +568,9 @@ sub _localInstallation } # else { TODO: errorhandling } + + ## Creating needed config /etc/vmware/config + $self->_writeVmwareConfig("$kind", "$vmpath"); } @@ -573,8 +580,6 @@ sub _vmpl2Installation { my $kind = "vmpl2.0"; my $vmpath = "/opt/openslx/plugin-repo/vmware/$kind/vmroot/lib/vmware"; my $vmbin = "/opt/openslx/plugin-repo/vmware/$kind/vmroot/bin"; - my $vmversion = "TODO_we_need_it_for_enhanced_runvmware_config_in_stage?"; - my $vmbuildversion = "TODO_we_need_it_for_enhanced_runvmware_config_in_stage1"; my $pluginFilesPath = "$self->{'openslxBasePath'}/lib/plugins/$self->{'name'}/files"; @@ -619,7 +624,7 @@ sub _vmpl25Installation { my $kind = "vmpl2.5"; my $vmpath = "/opt/openslx/plugin-repo/vmware/$kind/vmroot/lib/vmware"; my $vmbin = "/opt/openslx/plugin-repo/vmware/$kind/vmroot/bin"; - my $vmversion = "TODO_we_need_it_for_enhanced_runvmware_config_in_stage?"; + my $vmversion = "6.5"; my $vmbuildversion = "TODO_we_need_it_for_enhanced_runvmware_config_in_stage1"; my $pluginFilesPath @@ -666,7 +671,7 @@ sub _vmpl1Installation { my $kind = "vmpl1.0"; my $vmpath = "/opt/openslx/plugin-repo/vmware/$kind/vmroot/lib/vmware"; my $vmbin = "/opt/openslx/plugin-repo/vmware/$kind/vmroot/bin"; - my $vmversion = "TODO_we_need_it_for_enhanced_runvmware_config_in_stage?"; + my $vmversion = "5.5"; my $vmbuildversion = "TODO_we_need_it_for_enhanced_runvmware_config_in_stage1"; my $pluginFilesPath -- cgit v1.2.3-55-g7522