Just Enough Developed Infrastructure

Interacting - Programming Vmware Vsphere - Esx - On Mac OS X

This blogpost gives an overview of the options you have on Mac OSX to interact with a Vmware Esx, Vsphere server. I feel that Vmware threats Mac OSX users as a second thought, which is kind of strange. The options that we will explore are:

  1. GUI Options : simple GUI, not much of automation here
  2. Commandline Options : commandline options to interact
  3. Programming/Scripting Options : using programming languages such as java, C#, ruby , Powershell, Perl

GUI Options

Suppose you have installed a new Vmware Vsphere/Esx server, the screen will greet you with a URL that you can use to connect to the server. That URL will redirect you to a webpage that gives you two client options:

Install the Vpshere Client: as there is only a windows .exe , this option can't be used on a Mac OSX system. I found two ways to get around the problem but it requires you to have a windows machine running:

  1. The guys from Punching Clouds describe how to run a vSphere Client on Mac OS X using Rdesktop and Seamless RDP access to a windows Server.
  2. Install Windows inside your Vmware Fusion and run it in Unity Mode to use it as a client, but this of course requires Vmware Fusion installed.

Interact via the Web UI: The second way of interacting, is by using the Web UI. The URL to connect to https:///ui . This is disabled by default. To enable it, you need to run the following commands on your ESX server:

$ chkconfig –level 345 vmware-webAccess on
$ /etc/init.d/vmware-webAccess start or service vmware-webAccess start

You can find more info in the vmware vpshere Web access PDF Document

Interact with Virtual Machines Console: The web interface allows you to do the most common tasks , the only thing you can't do on an Mac is to view the console of a machine. This requires a plugin for the browser. The plugin either runs in Linux or Windows, and there is no Mac version of the plugin.

To get around that problem, I found these options:

Beware that you need to allow the VNC service on the server for this

$ esxcfg-firewall -e vncServer
  • Using the Vmware View Open Client :this lets you connect from a Linux or Mac OS X desktop to remote Windows desktops managed by VMware View. It is available under the GNU Lesser General Public License version 2.1 (LGPL v 2.1). http://code.google.com/p/vmware-view-open-client/

Commandline options:

On the Vsphere server: Vmware provides several commandline tools on the server platform, through the following commands:

On Mac OS X: If you can't ssh into the server, your options are more limited on Mac OSX:

Programming Options

If the commandline tools are too limited for you, or scripting is not your thing, Vmware provides a multitude of options to program/script against an Vsphere/Esx server.

Note: if you only have an ESXi version, you can only read information! You can't do changes.

Visual Programming:

Project Onyx is a new tool in that generates code based on the mouse clicks you make in the vSphere Client. Project Onyx makes it easy to see what is happening behind the covers and can help with development of scripts and automation solutions. Please refer to the Using Project Onyx video for set up and more information.

Official Programming language options

All the official programming options are listed at http://www.vmware.com/support/pubs/sdk_pubs.html

On a side note, in case you want to automate stuff in the Guest you can use the Vix-API http://www.vmware.com/support/developer/vix-api/ . The VIX API helps you write programs and scripts to automate virtual machine operations and run programs or manipulate files within guest operating systems

Semi Official

From the official options, I consider only the java one to be usable on my Mac. I found the interface for programming Webservices in java, rather cumbersome. And samples are rather spread over the whole site.

I found much more consistency in the Open Source VI (vSphere) Java API for Managing VMware Platforms (VIjava) Created by Steve Jin , it builds upon the WebService interface but provides a great, rather simple but powerful programming API. And it has lots of samples and documentation.

Personally I believe, this is the way forward: java will undoubtably stay important with the SpringSource acquisition by VMware.

Other options: The truth is out there

More Java:

https://github.com/andreaturli/jclouds/tree/477466ca64253cb91875cbe58ec60845b66abe5c/sandbox/vsphere

Ruby:

It would be nice to interface with ruby, similar to the Powershell on Windows. I found some hints that this might happen in the future in a blogpost Vmware looking into Ruby? http://blog.mccrory.me/2010/10/08/vmware-looking-to-ruby/ . Hopefully to be continued in the future.

Python:

I'm not much into python, but if Python is your thing:

Puppet:

Last but not least, I was thinking on creating an interface for puppet to integrate it within manifests. Not much there yet, but I found these useful pointers:

And if Libvirt finally gets good esx/vsphere support, the Puppet-Virt project https://github.com/carlasouza/puppet-virt would be an awesome way to interface.

But that's still future stuff...