Wednesday, October 22, 2008

Poor Man's VDI ...

Once again, I'm amazed at some of our Partners and what they do.  DJ, who works for a Sun VAR in the Switzerland, www.acceleris.ch, sent me this. If you are in need of saving money, call DJ an Acceleris.

Here is just one instance of DJ wanting to help the community more than any one company could do.  This is why Sun Microsystems is a partner centric organization.  The whole is greater than the sum of it's parts.  Or the Community is greater the the sum of just Sun's Parts.

Here is what DJ wrote to me, and he ask that I share it with you!


________________________________



In my opinion (yes I admit: I am biased ;-) ) this stuff is highly useful for anyone who has to work with a tight budget ... and given the current financial crisis worldwide I could imagine that many people in many companies and IT departments have tight budgets too now ...

So all this is written under the following assumptions:

a) You cannot afford or simply don't want to pay the mind-boggling license costs for VMware's ESX and "Virtual Infrastructure" products
b) you don't have the server hardware required to run VMware ESX anyway ... but having VDI-like features would be nice.
c) but you have a reasonably strong PC somewhere somehow and you have a few Sun Ray DTU's which you could use
d) you don't mind not (yet) having the management abilities VI3 offers and you're perfectly happy with any alternative ... (Sun will soon release xVM Server and xVM OpsCenter anyway)

I myself implemented my "Poor Man's VDI" on the following configuration:

- Sun Ultra 24 PC, Intel Quad-Core CPU, 8 GB RAM, 250 GB disk
- OS: Solaris Express, build 98
- SRSS 4.1

and last but not least:  VirtualBox 2.0.2 :-)

Here we go:


1.) Install Solaris

... confgure a few demo user accounts, and then install SRSS (I use Solaris Express build-98 + SRSS 4.1), configure it the way you want, e.g. Kiosk Mode and everything. On my setup I use Opera 9.61 as "kiosk mode browser":

- get the Solaris package for Opera: http://www.opera.com/download/solaris/
- unpack and install it
- switch to a normal account (not root!) and launch it:  /usr/local/bin/opera
- Opera will open and and ask you to confirm the license ... Hit "I agree" ... you shouldn't see that window ever again.
- adjust Opera to your own liking, e.g. set the homepage to http://www.sun.com
- quit Opera

Now we copy your newly generated Opera settings somewhere else so every Kiosk user gets these same settings:

cp -r /export/home/yourusername/.opera /opt/
mv /opt/.opera /opt/opera-prototype
chown -R root:root /opt/opera-prototype
find /opt/opera-protype -type d -exec chmod 755 {} \;
find /opt/opera-prototype -type f -exec chmod 644 {} \:

Then in the Sun Ray Admin Console make sure that this command gets executed in the kiosk mode (I placed it into a script: /usr/bin/opera_kiosk.sh), e.g. as "Executable" and mode set to "Critical":

#! /bin/bash
/usr/local/bin/opera -personaldir /opt/opera-prototype -resetonexit -kioskmode -nosplash -nomail -nomaillinks -noprint -nosave -nohotlist -nomenu -nocontextmenu -nodownload -nosession -kioskbuttons -kioskwindows http://www.sun.com

=> Result: a very good looking but pretty much locked-down web browser ... ideal for kiosk mode sessions.


2.) Download and install VirtualBox

 e.g. from here:
http://download.virtualbox.org/virtualbox/2.0.2/VirtualBox-2.0.2-36488-SunOS_amd64.tar.gz


3.) switch to normal user accounts and create a few VM's in VirtualBox.

Make sure that the guest addons are installed. In my case I have a virtual Ubuntu machine in one account; another account has a virtual Windows XP, and then again another account has a virtual Novell SLED installation, and so on ...

Piece of advice: Don't use spaces in the names, e.g. don't call your VM "My OpenSolaris test VM" but rather something like "OpenSolaris_Test"

And if you want:  Configure your VM to perform an "Auto Login", e.g. not ask for username and password. User authentication and access to your VM will be handled by the Sun Ray server later, so there is no need for extra authentication via the guest-OS, IMHO


4.) Each user who wants to use "Poor Man's VDI" should have an ".autovm" file in their $HOME directory.

The file should contain the name of the virtual machine that you want to access when you login via dtlogin, e.g.:

echo my_WinXP > ~/.autovm

... If they don't have that file and try to access the "AutoVM" session (see below for that) they will get an error message and be returned back to dtlogin.


5.) Configure dtlogin 

But first credit where credit is due:  For the life of me I could not figure out how to create a custom session for "dtlogin" (on Linux with "gdm" it is sooo easy!) ... I then ran across this web page which shows how to create a custom "IceWM" session for dtlogin ... So I more or less "borrowed" everything from here:  http://www.softagalleria.net/icewm.php   .... And then I installed XFCE and borrowed even more from the various scripts there.

We need to create a bunch of files now:


a) /usr/bin/vbox_autovm :

#! /usr/bin/bash
AUTOVM=`cat $HOME/.autovm`
if [ -z $AUTOVM ]
  then
    /usr/bin/zenity --error --text="You have not yet configured your ~/.autovm file. Please ask your administrator."
    exit 1
fi
/usr/bin/VBoxSDL -fullscreen -vm $AUTOVM



b) /usr/dt/config/Xsession.autovm :

#!/bin/ksh
#####################################################################
###  File:              Xsession.autovm  Version 0.1
###
###  Default Location:  /usr/dt/config/Xsession.autovm
###
###  Purpose:           Automatic start of VirtualBox VMs
###
###  Invoked by:        Solaris Desktop Login Manager (dtlogin)
###
#####################################################################

DTDSPMSG=/usr/dt/bin/dtdspmsg

export SESSIONTYPE="altDt"
export SDT_ALT_SESSION="/usr/dt/config/Xsession2.autovm"
export SDT_ALT_HELLO="/bin/true"
export SDT_NO_TOOLTALK="1"
export SDT_NO_DTDBCACHE="1"
export START_SPECKEYSD="no"
exec /usr/dt/bin/Xsession


c) /usr/dt/config/Xsession2.autovm :

#!/bin/ksh
#####################################################################
###  File:              Xsession2.autovm  Version 0.1 $Revision: 1.0 $
###
###  Default Location:  /usr/dt/config/Xsession2.autovm
###
###  Purpose:           Launch VirtualBox VMs
###
###  Invoked by:        /usr/dt/bin/Xsession
###
#####################################################################

# First a little namespace cleanup of vars associated with this
# (and /usr/dt/bin/Xsession.ow) scripts.

unset SDT_ALT_SESSION
unset SDT_ALT_HELLO
unset SDT_NO_DSDM

if [ -f /etc/dt/config/Xinitrc.autovm ]; then
    XINITRC="/etc/dt/config/Xinitrc.autovm"
else
    XINITRC="/usr/dt/config/Xinitrc.autovm"
fi

if [ -x /usr/dt/bin/xmbind ]; then
    /usr/dt/bin/xmbind
fi

echo 'AutoVM'

if [ -f $XINITRC ]; then
    echo "using xinitrc file: $XINITRC"
    /bin/ksh $XINITRC
else
    echo "xinitrc file: $XINITRC not found"
fi


d) /usr/dt/config/Xinitrc.autovm :

#!/bin/ksh
#####################################################################
###  File:              Xinitrc.autovm  Version 0.1 $Revision: 1.0 $
###
###  Default Location:  /usr/dt/config/Xinitrc.autovm
###
###  Purpose:           Launch VirtualBox VMs
###
###  Invoked by:        /usr/dt/bin/Xsession
###
#####################################################################

if [ "x$LC_ALL" = x -a "x$LANG" = x -o "x$LANG" = xC ]; then
  export LC_ALL="C"
  export LC_CTYPE="C"
else
  export LC_MESSAGES=$LANG
fi

export G_FILENAME_ENCODING=@locale,UTF-8
export G_BROKEN_FILENAMES=yes

/usr/openwin/bin/xrdb -merge << EOF
! Default CDE resources
*WindowColor:           #8A008A008A00
!*WindowForeground:      #FF0000000000
!*DataBackground:        #0000FF000000
*DataForeground:        #FF0000000000
*WorkspaceColor:        #8A008A008A00
*Color.Background:      #FF000000FF00
!*Color.Foreground:      #0000FF000000
*foreground:            #000000000000
! Hack for Dtmail
*XmText*background: seashell
*XmTextField*background: seashell
*Message_List*background: seashell
*background:    #AE00B200C300
Dthello*string:        Welcome to the OpenSolaris Xfce Desktop
EOF

if [ -f $HOME/.Xdefaults ]; then
    xrdb -merge $HOME/.Xdefaults        # Load Users X11 resource database
fi

/usr/bin/linc-cleanup-sockets

command=/usr/bin/vbox_autovm

if [ -x "/usr/bin/dbus-launch" -a -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
    command="/usr/bin/dbus-launch --exit-with-session $command"
else
    echo "$0: dbus-launch not found."
fi

if [ -x "/usr/bin/ssh-agent" ] && [ -z "$SSH_AUTH_SOCK" ]; then
    command="/usr/bin/ssh-agent -- $command"
else
    echo "$0: ssh-agent not found."
fi

echo 'Starting AutoVM'
exec $command


e) /usr/dt/config/C/Xresources.d/Xresources.autovm :

Dtlogin*altDtsIncrement:    True
Dtlogin*altDtName:    AutoVM
Dtlogin*altDtKey:     /usr/bin/vbox_autovm
Dtlogin*altDtStart:     /usr/dt/config/Xsession.autovm
Dtlogin*altDtLogo:    XFCE


=> this last file also needs to be copied to the other locales ... as "root":

find /usr/dt/config -name Xresources.d -exec cp /usr/dt/config/C/Xresources.d/Xresources.autovm {} \;


Voila, done!

If you did correctly setup everything and if you did not forget to create that ~/.autovm  file that contains the name of the VM you want to start, you should now be able to go to your next best Sun Ray, type in your username into the "dtlogin" mask, select "AutoVM" as your session type, type in your password .... and you should now be watching how your favourite VM is booting. And it boots pretty fast (yes, VirtualBox rocks!)

Once it's booted you can just leave it like that ... Session hotdesking of course works as well. Insert your SmartCard into another DTU and your VM follows you wherever you go ...

I tested this stuff here in my lab and my colleagues here are pretty happy with it especially given the price tag for the software (not including possible license costs needed for proprietary guest Operating Systems in your VM's ...):  Zero. All the software needed (Solaris + SRSS + VirtualBox) to implement this type of "Poor Man's VDI" can be downloaded for free from SUN's web site.

Insert card ... we have a Novell SLED running. Insert another card ... Windows XP ... Insert another card: Ubuntu .... Insert another card: Solaris desktop.  .... Even better: Thanks to the "Remote Control" scripts you already posted this also works from SGD, e.g. a user can access whatever VM he has started in the office via the "My Sun Ray Session" menu entry inside SGD ... :-)

So what exactly do I need VMware and their incredibly expensive licenses for?? :-)

4 comments:

Anonymous said...

Hi - first of all, thanks so much for your informative post! I'm a newbie to both Solaris and VirtualBox - tried using your instructions but the latest Solaris (10-8) with the latest VirtualBox (2.0.4) doesn't work because of missing SDL libraries. What version of the OS & VirtualBox are you using? Greatly appreciate any help you could give. Lastly, as a newbie - took me half a day to realize I had to set execute permissions on the scripts above, an update to highlight this would make this post even better! (I used JDS's text editor in root, and saved the files to the provided locations, but after that you still need to set permissions appropriately) Will be reading your blog will continued interest!!! paul-at-taksys.com.sg

Tim Ebbers said...

Paul, I will update to take into account your finding's. I haven't tried this yet, so I will in the coming weeks and will post updates.

Thanks for reading.

T

Anonymous said...

I was wondering if/how this could be implemented with the VirtualBox VM's located on several different machines all separate from the SRSS?

Tim Ebbers said...

This can be done, and depending on your implementation time frame, VDI 2.0 will contain the ability to do just that.

It's in Early Release right now, and I will start testing with it next week. So if you can way until First Quarter next year, it will be real easy.

I'm sure it could be scripted to do that as well from these scripts, but I would have to take a look at them and try it out, but remember, VirtualBox can be RDPed to using the UTTSC client regardless of the OS that's running inside of VB.

So you could easy setup a flat file on an NFS share that all of the SRSS servers use, and create another Kiosk session and write a script to read the owner of card and uttsc to the correct IP or, if you can control DNS, just have the VM's setup in DNS to uttsc to the user which is tied to an IP.

Just some thoughts. If you want to know more, e-mail me.