05 November, 2008

From the GUI to the CLI

VMware ships Studio as a virtual appliance (VA). I'm guessing they use VMware Studio to create VMware Studio based on the embedded CIM stack and management web GUI.

In this appliance there are a bunch of files. Lots of these are normal Linuxy files, many are from VMware.

The Studio VA itself is Ubuntu Feisty, 32bit. Almost all of the VMware bits reside in /opt/vmware/.

The easiest way to explain what files live where is to walk through an appliance build from scratch using the web interface.

Login to the VMware Studio GUI, http://whateverIP/



Click the Create Appliance button near the right side of the screen, select your base OS and specify a name for the appliance:



The list of base operating systems is generated by the XML files found in the directory:
/opt/vmware/etc/build/templates/

You'll notice an extra OS in the screenshot above, CentOS 5.2 x86_64. I added that by copying the file /opt/vmware/etc/build/templates/centos/5/2/build_profile.xml and making a few tweaks to it--those tweaks are another post in themselves.

Using the web GUI, type in your appliance name, version, description, etc. Keep clicking Next at the bottom of the screen to progress through the wizard. The only important thing here is that you have a VMware Server v1.something installed and accessible for the last step.



Click Save and Build to ensure this new profile and your build environment settings are working. If you have issues please rtfm else respond to this post and we can figure it out.

At this point you should have a completed build from the web GUI. Great stuff. What has happened under the hood is that the reference profile template was used to create a new appliance profile XML file in the directory /opt/vmware/var/lib/build/profiles/. The file in this directory should have a familiar name to it.

From now on you're ready to build from the command line. Run the command:

studiocli -cvp /opt/vmware/var/lib/build/profiles/myAppliance.xml


...And there you go. Nice. Debug-level verbosity is had with a second -v argument, as in:

studiocli -cvvp /opt/vmware/var/lib/build/profiles/myAppliance.xml

At this point you no longer need to use the web GUI to make changes to the appliance profile XML file. That file looks much like an OVF file with a few VMware Studio enhanced sections.

Nifty eh?

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