From 74be7469519e6201dd345359e5a396b2a8fafd6b Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 27 Nov 2012 15:49:43 +0100 Subject: Working on VirtualBox for OpenSLX clients ... (including changes for vmchooser) --- .../plugins/virtualbox/OpenSLX/Distro/Base.pm | 4 +- .../plugins/virtualbox/OpenSLX/Distro/Debian.pm | 4 +- .../plugins/virtualbox/OpenSLX/Distro/Suse.pm | 8 +- .../plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm | 5 +- .../virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 31 +------ src/os-plugins/plugins/virtualbox/XX_virtualbox.sh | 9 +- .../plugins/virtualbox/files/machine.include | 78 ++++++------------ .../plugins/virtualbox/files/run-virt.include | 71 ++++++++++++---- .../plugins/virtualbox/files/virtualbox.include | 16 ++-- src/os-plugins/plugins/vmchooser/XX_vmchooser.sh | 7 ++ src/os-plugins/plugins/vmchooser/files/run-virt.sh | 2 +- src/os-plugins/plugins/vmware/XX_vmware.sh | 7 +- src/os-plugins/plugins/vmware/files/README | 2 +- .../plugins/vmware/files/run-virt.include | 95 ++++++++++++++-------- 14 files changed, 185 insertions(+), 154 deletions(-) diff --git a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm index d26cdfcc..fb23c4f8 100644 --- a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm +++ b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm @@ -1,4 +1,4 @@ -# Copyright (c) 2009 - OpenSLX GmbH +# Copyright (c) 2012 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -50,7 +50,7 @@ sub installVbox my $engine = $self->{'engine'}; - # lets try it... we can't loose anything :) + # lets try it ... but better have it installed in the clone source system $engine->installPackages('virtualbox-ose'); return; diff --git a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm index edd117ca..eeaa0627 100644 --- a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm +++ b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm @@ -1,4 +1,4 @@ -# Copyright (c) 2009 - OpenSLX GmbH +# Copyright (c) 2012 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -34,7 +34,6 @@ sub installVbox my $release = `lsb_release -rs`; chomp($release); - # lenny(5.0) has v1.6 # testing is ok. but no clue which lsb_release -rs it has... if ( $release eq "999999.0") { #the usual "in stage1 chroot we get another kernel vers. problem" @@ -43,6 +42,7 @@ sub installVbox #system('/etc/init.d/virtualbox-ose setup'); } else { print "Couldn't install VirtualBox, no package from distribution\n"; + print "Install and configure VirtualBox in your clone source\n"; exit; } diff --git a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm index 9af3191e..6b571d6b 100644 --- a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm +++ b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm @@ -1,4 +1,4 @@ -# Copyright (c) 2009 - OpenSLX GmbH +# Copyright (c) 2012 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -35,10 +35,12 @@ sub installVbox my $release = `lsb_release -rs`; chomp($release); - if ( $release eq "11.1" || $release eq "11.0" || $release eq "10.3") { - $engine->installPackages('virtualbox-ose'); + if ( $release eq "12.2" || $release eq "12.1" ) { + $engine->installPackages('VirtualBox'); } else { print "Couldn't install VirtualBox, no package from distribution\n"; + print "Install and configure VirtualBox in your clone source\n"; + exit; } diff --git a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm index 44695680..ac270747 100644 --- a/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm +++ b/src/os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm @@ -1,4 +1,4 @@ -# Copyright (c) 2008 - OpenSLX GmbH +# Copyright (c) 2012 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -36,7 +36,7 @@ sub installVbox my $release = `lsb_release -rs`; chomp($release); - # hardy (8.04LTS): only version VBox v1.5 + # does not really makes sense to install it into stage2 if ( $release eq "8.10" || $release eq "9.04") { #the usual "in stage1 chroot we get another kernel vers. problem" # kernel modules need to be installed from the cloned system @@ -44,6 +44,7 @@ sub installVbox #system('/etc/init.d/virtualbox-ose setup'); } else { print "Couldn't install VirtualBox, no package from distribution!\n"; + print "Install and configure VirtualBox in your clone source\n"; exit; } diff --git a/src/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/src/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index 07ec9dc0..d07cd92f 100644 --- a/src/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/src/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -1,5 +1,5 @@ # Copyright (c) 2009..2010 - RZ Uni Freiburg -# Copyright (c) 2009..2010 - OpenSLX GmbH +# Copyright (c) 2009..2012 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -85,8 +85,6 @@ sub getAttrInfo }, # attribute 'bridge' defines if bridged network mode should be # switched on - # TODO: change to net -> nat, bridge, hostonly? - # TODO: since we use def in XML maybe use to override 'virtualbox::bridge' => { applies_to_systems => 1, applies_to_clients => 1, @@ -98,30 +96,6 @@ sub getAttrInfo content_descr => '0 or 1', default => '1', }, - # attribute 'mem' defines if memory should be forced - 'virtualbox::mem' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - Do you want to force a ralative amount of RAM? - (Not implemented right now!) - End-of-Here - content_regex => qr{^(\d\d??)$}, - content_descr => 'Between 0 - 99', - default => undef, - }, - # attribute 'kvm' defines if KVM modules should be forced - 'virtualbox::kvm' => { - applies_to_systems => 1, - applies_to_clients => 1, - description => unshiftHereDoc(<<' End-of-Here'), - Do you want to force the usage of KVM modules where applicable? - (Not implemented right now!) - End-of-Here - content_regex => qr{^(0|1)$}, - content_descr => '0 or 1', - default => undef, - }, # attribute 'tftpdir' defines TFTP dir for network boots /w NAT 'virtualbox::tftpdir' => { applies_to_systems => 1, @@ -192,7 +166,6 @@ sub checkStage3AttrValues my $self = shift; my $stage3Attrs = shift; my $vendorOSAttrs = shift; - #my @problems; #my $vmimg = $stage3Attrs->{'virtualbox::imagesrc'} || ''; @@ -209,7 +182,7 @@ sub _writeRunlevelScript $initfile->setName("vbox-slx"); $initfile->setDesc("Setup environment for virtualbox. Part of OpenSLX virtualbox plugin."); - # todo: Function need to be formated proper... not important right now + # todo: Function need to be formated properly ... $initfile->addFunction( 'running', 'lsmod | grep -q "$1[^_-]"' diff --git a/src/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/src/os-plugins/plugins/virtualbox/XX_virtualbox.sh index b54b4bec..e92b930d 100644 --- a/src/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/src/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -1,5 +1,5 @@ # Copyright (c) 2009..2010 - RZ Uni Freiburg -# Copyright (c) 2009..2010 - OpenSLX GmbH +# Copyright (c) 2009..2012 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -89,6 +89,13 @@ if [ -e ${CONFFILE} ]; then mknod -m 0660 /dev/vboxdrv c 10 59 chown root:vboxusers /dev/vboxdrv + # setting the base samba configuration +# [ -f /mnt/opt/openslx/plugins/virtualization/smb.conf -a -f /mnt/usr/sbin/smbd ] && \ +# sed -e "s,NWIF,vboxnet0,;s,PIDDIR,/var/run/vbox," \ +# /mnt/opt/openslx/plugins/virtualization/smb.conf \ +# >/mnt/etc/vbox/smb.conf + fi + # finished ... [ $DEBUGLEVEL -gt 0 ] && echo "done with 'virtualbox' os-plugin ..." fi diff --git a/src/os-plugins/plugins/virtualbox/files/machine.include b/src/os-plugins/plugins/virtualbox/files/machine.include index 96acd7a2..7b81390d 100644 --- a/src/os-plugins/plugins/virtualbox/files/machine.include +++ b/src/os-plugins/plugins/virtualbox/files/machine.include @@ -1,17 +1,17 @@ -# Include file (machine template) for run-virt.include of the virtualbox plugin +# Include file (machine template) for run-virt.include of the OpenSLX virtualbox plugin cat << EOF > "${machconfig}" - + - + + - @@ -27,7 +27,8 @@ cat << EOF > "${machconfig}" - + + @@ -43,13 +44,13 @@ cat << EOF > "${machconfig}" <${network_kind}/> - - - - - - - + + + + + + + @@ -59,7 +60,9 @@ cat << EOF > "${machconfig}" - + + + @@ -67,48 +70,17 @@ cat << EOF > "${machconfig}" + - + @@ -117,10 +89,10 @@ cat << EOF > "${machconfig}" + @@ -9,11 +9,10 @@ cat << EOF > "${confdir}/VirtualBox.xml" - - - + + @@ -25,22 +24,19 @@ cat << EOF > "${confdir}/VirtualBox.xml" - + - + diff --git a/src/os-plugins/plugins/vmchooser/XX_vmchooser.sh b/src/os-plugins/plugins/vmchooser/XX_vmchooser.sh index cd6d54e5..9fcc1c39 100644 --- a/src/os-plugins/plugins/vmchooser/XX_vmchooser.sh +++ b/src/os-plugins/plugins/vmchooser/XX_vmchooser.sh @@ -78,11 +78,18 @@ if [ -e $CONFFILE ]; then # enable normal users to setup the extended virtual machine redo file space # and image source via network block device (NBD only at the moment) + # allow to start/stop samba on virtual devices (latter one ignores multiple + # independent daemons) cat >> /mnt/etc/sudoers << EOF # allow to start and stop the special /tmp redo file space (RAM + NBD/NFS server RAID) ALL ALL=NOPASSWD: /sbin/losetup /dev/loop* ALL ALL=NOPASSWD: /sbin/mdadm -C /dev/md0 -l linear --raid-devices=2 /dev/loop* /dev/* ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/sbin/nbd-client * * /dev/nbd* +# allow to configure and start/stop samba services +ALL ALL=NOPASSWD: /opt/openslx/rootfs/bin/sed -i /etc/*/smb.conf -e * +ALL ALL=NOPASSWD: /usr/sbin/nmbd -c /etc/*/smb.conf +ALL ALL=NOPASSWD: /usr/sbin/smbd -c /etc/*/smb.conf +ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/bin/killall nmbd smbd EOF # finished ... diff --git a/src/os-plugins/plugins/vmchooser/files/run-virt.sh b/src/os-plugins/plugins/vmchooser/files/run-virt.sh index 5a03e63f..b3863a2e 100644 --- a/src/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/src/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -364,7 +364,7 @@ esac # Enable 3D enable3d=$(grep -i "/dev/null | \ - awk -F '=' {'print $2'}) + awk -F '=' {'print $2'} | tr "[A-Z]" "[a-z]") # Add rw share sharepath="${HOME}" diff --git a/src/os-plugins/plugins/vmware/XX_vmware.sh b/src/os-plugins/plugins/vmware/XX_vmware.sh index 59996db6..7a953eae 100644 --- a/src/os-plugins/plugins/vmware/XX_vmware.sh +++ b/src/os-plugins/plugins/vmware/XX_vmware.sh @@ -1,5 +1,5 @@ # Copyright (c) 2007..2009 - RZ Uni Freiburg -# Copyright (c) 2008..2011 - OpenSLX GmbH +# Copyright (c) 2008..2012 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -75,6 +75,11 @@ stage3 setup" > ${PLUGINCONFDIR}/vmware.conf -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 + # setting the base samba configuration if available + [ -f /mnt/opt/openslx/plugins/virtualization/smb.conf -a -f /mnt/usr/sbin/smbd ] && \ + sed -e "s,NWIF,$vmsub,;s,PIDDIR,/var/run/vmware," \ + /mnt/opt/openslx/plugins/virtualization/smb.conf \ + >/etc/vmware/smb.conf fi # vmware nat interface configuration diff --git a/src/os-plugins/plugins/vmware/files/README b/src/os-plugins/plugins/vmware/files/README index ae8bf1e7..8e33187b 100644 --- a/src/os-plugins/plugins/vmware/files/README +++ b/src/os-plugins/plugins/vmware/files/README @@ -1,5 +1,5 @@ Files -- nvram (version from VMware5) +- nvram (version from VMware5, compatible for newer machines too) This nvram supports a second Floppy drive. Helpfull if you want to get some data from linux to your Windows VirtualMachine (like Scanner-IP or Userinformation) diff --git a/src/os-plugins/plugins/vmware/files/run-virt.include b/src/os-plugins/plugins/vmware/files/run-virt.include index 3ec8eafc..86efb1a8 100644 --- a/src/os-plugins/plugins/vmware/files/run-virt.include +++ b/src/os-plugins/plugins/vmware/files/run-virt.include @@ -22,74 +22,86 @@ runvmwareconfheader () { echo "# This configuration file was generated by $0" >${conffile} -case "$vmversion" in - *) - svga_autodetect="TRUE" - numvcpus="1" - shared_folder="FALSE" - echo ".encoding = \"UTF-8\" -# version specific stuff - all versions -config.version = \"8\"" >>${conffile} - ;; -esac -case "$vmversion" in - 2.*|3.*|4.*|6.*|7.*|8.*) - shared_folder="TRUE" - echo " -# version specific stuff - ver. 2.*|3.*|6.*|7.* -sharedFolder.option = \"alwaysEnabled\"" >>${conffile} - ;; -esac -case "$vmversion" in - 2.5|3.*|4.*|6.5|7.*|8.*) - if [ "${cpu_cores}" -ge "2" 2>/dev/null ]; then - numvcpus="2" - fi - cap3d="TRUE" # helper var for loging output - echo " -# version specific stuff - ver. 2.5|3.*|6.5|7.* -ehci.present = \"TRUE\" -mks.enable3d = \"${enable3d}\"" >>${conffile} - ;; -esac # check for the ostype case "${vmostype}" in win31*) mem="32" cpu_cores="1" sound="sb16" + shfolders="FALSE" ;; win95*) mem="92" cpu_cores="1" + shfolders="FALSE" ;; win98*|winme*) mem="256" cpu_cores="1" + shfolders="FALSE" ;; winxp*|windowsxp*) + shfolders="TRUE" ;; winvista*|windowsvista*) + shfolders="TRUE" ;; windows7*) + shfolders="TRUE" + ;; + windows8*) + shfolders="TRUE" ;; linux*|*ubuntu*|*suse*|debian*|*sci*) vmostype="linux" + shfolders="TRUE" ;; macos*) cpu_cores="1" vmostype="other" + shfolders="FALSE" ;; beos*) cpu_cores="1" vmostype="other" + shfolders="FALSE" ;; *) vmostype="other" + shfolders="FALSE" + ;; +esac +case "$vmversion" in + *) + svga_autodetect="TRUE" + numvcpus="1" + shfolders="FALSE" + echo ".encoding = \"UTF-8\" +# version specific stuff - all versions +config.version = \"8\"" >>${conffile} + ;; +esac +case "$vmversion" in + 2.*|3.*|4.*|6.*|7.*|8.*|9.*) + echo " +# version specific stuff - ver. 2.*|3.*|6.*|7.*|8.*|9.* +sharedFolder.option = \"alwaysEnabled\"" >>${conffile} + ;; +esac +case "$vmversion" in + 2.5|3.*|4.*|6.5|7.*|8.*) + if [ "${cpu_cores}" -ge "2" 2>/dev/null ]; then + numvcpus="2" + fi + cap3d="TRUE" # helper var for loging output + echo " +# version specific stuff - ver. 2.5|3.*|6.5|7.* +ehci.present = \"TRUE\" +mks.enable3d = \"${enable3d}\"" >>${conffile} ;; esac case "$vmversion" in - 3.*|4.*|7.*|8.*) + 3.*|4.*|7.*|8.*|9.*) numvcpus="${cpu_cores}" if [ "${cpu_cores}" -ge "4" 2>/dev/null ]; then numvcpus="4" @@ -176,9 +188,15 @@ svga.autodetect = \"${svga_autodetect}\" usb.present = \"TRUE\" usb.generic.autoconnect = \"TRUE\" +# pci configuration +usb.pciSlotNumber = "16" +ethernet0.pciSlotNumber = "17" +sound.pciSlotNumber = "18" +ehci.pciSlotNumber = "19" + # shared folders -sharedFolder0.present = \"TRUE\" -sharedFolder0.enabled = \"${shared_folder}\" +sharedFolder0.present = \"${shfolders}\" +sharedFolder0.enabled = \"${shfolders}\" sharedFolder0.expiration = \"never\" sharedFolder0.guestName = \"${sharename}\" sharedFolder0.hostPath = \"${sharepath}\" @@ -306,8 +324,8 @@ fi sound="es1371" # check for 3D configuration setting -case "$enable3d" in - *true*|*TRUE*|*yes*|*YES*) +case "${enable3d}" in + *true*|*yes*) enable3d="TRUE" ;; *) @@ -492,6 +510,13 @@ writelog "" # finally set env for run-virt.sh ################################################################################ +# configure and start samba service to provide user's home directory +if [ -f /usr/sbin/smbd ] ; then + sudo /opt/openslx/rootfs/bin/sed -i /etc/vmware/smb.conf -e "s,$USER,USER," + sudo /usr/sbin/nmbd -c /etc/vmware/smb.conf + sudo /usr/sbin/smbd -c /etc/vmware/smb.conf +fi + # using the modified version of the wrapper script VIRTCMD="${OPENSLX_DEFAULT_BINDIR}/vmplayer" VIRTCMDOPTS="${vmopt} ${conffile}" -- cgit v1.2.3-55-g7522