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 --- os-plugins/plugins/qemukvm/XX_qemukvm.sh | 2 +- os-plugins/plugins/virtualbox/XX_virtualbox.sh | 2 +- os-plugins/plugins/vmchooser/files/run-virt.sh | 65 ++++---------- .../plugins/vmware/OpenSLX/OSPlugin/vmware.pm | 99 ++++++++++++---------- os-plugins/plugins/vmware/files/run-virt.include | 43 +++++----- 5 files changed, 89 insertions(+), 122 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index 92285aea..669b4142 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -62,7 +62,7 @@ if [ -e /initramfs/plugin-conf/qemukvm.conf ]; then # copy version depending files - the vmchooser expects for every virtua- # lization plugin a file named after it (here run-qemukvm.include) testmkd /mnt/etc/opt/openslx - cp /mnt/opt/openslx/plugin-repo/run-qemukvm/files/run-virt.include \ + cp /mnt/opt/openslx/plugin-repo/run-qemukvm/run-virt.include \ /mnt/etc/opt/openslx/run-qemukvm.include fi diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 5fdf9f49..ab1a9c96 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -62,7 +62,7 @@ if [ -e /initramfs/plugin-conf/virtualbox.conf ]; then # copy version depending files - the vmchooser expects for every virtua- # lization plugin a file named after it (here run-virtualbox.include) testmkd /mnt/etc/opt/openslx - cp /mnt/opt/openslx/plugin-repo/run-virtualbox/files/run-virt.include \ + cp /mnt/opt/openslx/plugin-repo/run-virtualbox/run-virt.include \ /mnt/etc/opt/openslx/run-virtualbox.include fi diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 29f41477..7cb8b36b 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -26,13 +26,17 @@ # test if the xml path/file is valid (gotten via commandline first parameter) xml=$1 -[ -e "${xml}" ] && echo -e "\n\tNo XML file given!\n" && exit 1 +[ -e "${xml}" ] || { echo -e "\n\tNo XML file given!\n" && exit 1; } + +# path to the xml file(just take the path to the xml file) +imagepath=${xml%/*} # Read needed variables from XML file ############################################################################### # file name of the image imagename=$(grep -i "&1) - writelog "Filecheck:\n${filecheck}\n" - #TODO: don't understand the sence in it - noimage=$(echo ${filecheck} | grep -i "no such file or directory" | wc -l) - rightsfile=${diskfile} - - # check if link - # TODO: mistake with 2nd rightsfile if its in another directory? - if [ -L "${diskfile}" ]; then - # take link target - rightsfile=$(ls -lh ${diskfile} 2>&1 | awk -F "-> *" '{print $2}') - rightsfile=${vmdir}/${rightsfile} - filecheck=$(LANG=us ls -lh ${rightsfile} 2>&1) - fi - - # does file exist - if [ "${noimage}" -ge "1" ]; then - writelog "Vmware Image Problem:\c " - writelog "\tThe image you've specified doesn't exist." - writelog "Filecheck says:\c " - writelog "\t\t${diskfile}:\n\t\t\tNo such file or directory" - writelog "Hint:\c " - writelog "\t\t\tCompare spelling of the image with your options.\n" - exit 1 - fi - - # readable? - if ! [ -r "${diskfile}" >/dev/null 2>&1 \ - -o -r "${diskfile}" >/dev/null 2>&1 ]; then - writelog "Vmware Image Problem:\c " - writelog "\tThe image you've specified has wrong rights." - writelog "Filecheck says:\t\t$(echo ${filecheck} \ - | awk '{print $1" "$3" "$4}') ${rightsfile}" - writelog "Hint:\t\t\tChange rights with: chmod a+r ${rightsfile}\n" - exit 1 - fi - - # writable (for persistent-mode)? - if ! [ -w "${diskfile}" >/dev/null 2>&1 \ - -o -w "${diskfile}" >/dev/null 2>&1 ] \ - && [ "${np}" = "independent-persistent" ]; then - writelog "Vmware Image Problem:\c " - writelog "\tThe image you have specified has wrong rights." - writelog "Filecheck says:\t\t$(echo ${filecheck} \ - | awk '{print $1" "$3" "$4}') ${rightsfile}" - writelog "Hint:\t\t\tUse nonpersistent-mode or change rights to rw\n" - exit 1 - fi + #filecheck=$(LANG=us ls -lh ${diskfile} 2>&1) + #writelog "Filecheck:\n${filecheck}\n" + : } +# function to write to stdout and logfile +writelog () +{ + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >>run-virt.log +} # setup the rest of the environment and run the virtualization tool just confi- # gured 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 diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include index 49df4c38..5afe3692 100644 --- a/os-plugins/plugins/vmware/files/run-virt.include +++ b/os-plugins/plugins/vmware/files/run-virt.include @@ -18,6 +18,15 @@ # declaration of default variables ################################################################################ +# temporary disk space for logs, etc... +redodir=/tmp/vmware/${USER} +# dir for configs and vmem file +confdir=${redodir} +# configfile +conffile="${confdir}/run-vmware.conf" +# users vmware config folder +vmhome="${HOME}/.vmware" + # serial port defined (e.g. "ttyS0" or "autodetect") serial=$(grep -i "&1) @@ -202,7 +198,7 @@ numvcpus = \"1\" # ide-disks ide0:0.present = \"${ide}\" ide0:0.fileName = \"${diskfile}\" -ide0:0.mode = \"${np}\" +ide0:0.mode = \"independent-nonpersistent\" ide1:0.present = \"${cdr_1}\" ide1:0.autodetect = \"TRUE\" ide1:0.fileName = \"auto detect\" @@ -217,7 +213,7 @@ scsi0.present = \"${scsi}\" scsi0:0.present = \"${scsi}\" scsi0:0.fileName = \"${diskfile}\" scsi0.virtualDev = \"lsilogic\" #\"${hddrv}\" -scsi0:0.mode = \"${np}\" +scsi0:0.mode = \"independent-nonpersistent\" # floppies floppy0.present = \"${floppya}\" @@ -353,7 +349,7 @@ mkdir -p ${vmhome} >/dev/null 2>&1 ## log script information writelog "# File created by $0 (v.${version})\n# on $(date)\n" -writelog "Starting with $(echo ${np} | sed 's/i.*-//g')-mode ...\n" +writelog "Starting with nonpersistent mode ...\n" ## look for cdrom, dvd and add them to the vm config file @@ -391,7 +387,7 @@ writelog "\tVMostype:\t${vmostype}" writelog "\tDisplayname:\t${displayname}" # check if image exists, etc... -filecheck +#filecheck # VMPlayer Version. # strings is the fastest and most secure way, vmplayer -v takes too much time @@ -424,4 +420,3 @@ done # set the variables appropriately VIRTCMD=vmplayer VIRTCMDOPTS="${vmopt} ${conffile}" - -- cgit v1.2.3-55-g7522