10 October, 2008

Building appliances with other OS images (ISO files)

VMware Studio ships with support for virtual appliance creation using a few different OS versions. Each OS version requires a specific ISO image with fixed md5 checksum.

Fortunately, the ISO image and its checksum are part of the appliance profile XML file and we can change those readily. People who roll their own ISO images with Fedora's Revisor or something similar will generally want to use a new ISO image each time they build an appliance.

I'm not going to describe how to build your own ISO image here but let's assume you regularly build one and save it to a web-accessible folder, for example:


http://yourserver/iso/latest/my-custom-centos52.iso


Now edit your appliance profile XML file to use this ISO image instead of the stock value. Appliance profiles are found in the directory /opt/vmware/var/lib/build/profiles/.

Look for the line:


<vadk:iso path="file:///opt/vmware/www/ISV/ISO/CentOS-5.0-i386-bin-DVD.iso"
md5sum="b5633ee6ee3b2e10d92672c74e594d75">
</vadk:iso>


And change it to point to your custom ISO image instead and change the md5sum to null to skip that validation:


<vadk:iso path="http://yourserver/iso/latest/my-custom-centos52.iso "
md5sum="">
</vadk:iso>


Studio will cache ISO images locally so to make it download this ISO image for each build we have to flush Studio's local ISO extraction cache by running:


root@localhost:~# studiocli -v --flushIsoCache


And now you can fire off your appliance builds as usual:


root@localhost# studiocli -cvp myAppliance.xml -i 20081010
Using build instance name: 20081010
Validating profile schema...
Validating Appliance Version formatting...
Validating Appliance Memory Size...
Validating non-empty ISO path...
Validating Appliance usernames and passwords...
Validating Appliance logo path...
Validating ovf:DiskSection_Type...
Validating ApplicationPackages URL...
Validating OS Package elements...
Validating controllers and disks...
Validating file transfer for ProvisioningEngine...
Validating provisioning engine connection...
Validating vmguest_lan...
Validating available disk space...
Preparing the OS installation files.
Creating the virtual machine.
Installing the OS and applications.
Creating an inventory of installed software.
Packaging the virtual machine.
Creating a software update for upgrading older appliance releases.
Publishing the software update to remote servers.
Removing temporary files.
The build has completed successfully.

Building Appliances without VMware Guest software

By default VMware Studio will build appliances with a number of software components added into the appliance itself. If you already build hardware appliances then you probably have most of your in-guest software needs already taken care of.

The software components that Studio adds into each VA it creates are:

- command line network and timezone setup
- EULA acceptance/handling
- a simple web GUI
- software update support
- CIM stack for managing the appliance (similar to SNMP)

All this is very useful stuff but not all of this is for everyone and each component has its own dependencies so keeping all that will add to virtual disk bloat.

So to take control of this you can customize the OS provisioning template (XSL) used to install the OS and apps on your appliances.

First login to the Studio web GUI and create an appliance and build it once. This will require a VMware Server instance and SSH service running on its host OS. Read the bundled developers guide to get you going. There are hoops to jump through but it's worth it :)

Once you have an appliance defined you can customize how the OS and applications are installed by copying & editing the OS provisioning template file.

Template files are found in the directory tree /opt/vmware/etc/build/templates/

For this example I'll assume you're building a Red Hat or CentOS-based appliance. The OS template used for this is redhat5.xsl, so copy that and edit the copy:


mkdir /root/templates

cp /opt/vmware/etc/build/profiles/redhat/5/redhat5.xsl \
/root/templates/custom_redhat5.xsl


(For Ubuntu and Suse builds the XSL file containing this shell code is called post.xsl, paired with ubuntu.xsl and suse.xsl)

The XSL template contains some shell code and we can simply delete the section that installs the guest software components. I've a diff here that shows what to delete:


root@localhost:~/templates# diff -u redhat5.xsl.orig redhat5.xsl
--- redhat5.xsl.orig 2008-10-10 11:04:52.000000000 -0700
+++ redhat5.xsl 2008-10-10 11:05:48.000000000 -0700
@@ -401,37 +401,6 @@
# Install VADK Guest software
#
installdir=/tmp/vabs; export installdir
-
-
-# create a sandbox
-mkdir -p $installdir
-
-# download packages
-wget $WGET_TIMEOUT -nv -nd --no-parent -r -A .deb,.rpm,.sh -l1 -P $installdir
-if [ $? -ne 0 ]
-then
- abort Downloading of VMware Studio runtime packages from failed.
-fi
-
-# search for install.sh bash files and execute them
-find $installdir -name install.sh |
-while read i
-do
- bash $i || abort Execution of VMware Studio runtime install.sh file failed.
-done
-
-#
-# Install all .rpm packages
-#
-pkglist=`find $installdir -name "*.rpm"`
-if [ "$pkglist" ]
-then
- rpm -Uvh $pkglist || abort Installation of VMware Studio runtime packages failed.
-fi
-
-# cleanup
-rm -rf $installdir
-


#
# Load ISV software


Now edit the appliance profile XML file to use this alternate OS provisioning template. Your profile is found in /opt/vmware/var/lib/build/profiles/

Edit the XML file and change the value of from the old /opt/vmare/etc/build/templates/redhat/5/redhat5.xsl to /root/templates/custom_redhat5.xsl

Save the XML file and fire off a build:

# vadkstudio -cvp /opt/vmare/var/lib/build/profiles/myappliance.xml

And hey look, the resulting VA has no extra guest software.

07 October, 2008

Welcome to Hacking VMware Studio

Hi folks,

Welcome to the new hacking blog for VMware's virtual appliance authoring tool, VMware Studio.

Studio was announced as a new, free product at VMworld in Las Vegas, September 2008.

You can download it from here:

http://vmware.com/download/va_authoring/

Also download VMware Server which will need to be installed on an x86_64/amd64 PC from here:

http://vmware.com/download/server/

Please feel free to ask whatever questions you have about Studio VA deployments, limitations, new features or patches.

Best,

Will