Monday, November 5, 2012

Installing the vSphere SDK for Perl on OS X

Since the first Intel based Macbook Pro was introduced, Apple OS X has been my preferred platform for work and play.  While VMware Fusion makes it particularly easy to run VMware toolkits and utilities, I still prefer native versions.  I started working with the VMware vSphere SDK for Perl years ago, developing against and natively running the SDK tools on my various Mac systems ever since.

Installing the VMware vSphere SDK for Perl is actually a straightforward process.  The installation steps outlined here were tested using the vSphere SDK for Perl 5.1 and OS X Mountain Lion, but the process should work just as well on older versions of both the SDK and OS X.

Warning:  Installing the vSphere SDK for Perl on OS X is unsupported by VMware.  I have not encountered any issues particular to running the Perl SDK on OS X over the years, but there may be unexpected conflicts.

Note:  Installation of the vSphere SDK for Perl will require CPAN.  If you haven't configured CPAN on your system, be sure to review my earlier blog post.

First, download the vSphere SDK for Perl 5.1 64-bit Linux installer.  At the time of this post, the current installer package was VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.tar.gz.

cd ~/Downloads
tar zxvf VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.tar.gz
cd vmware-vsphere-cli-distrib/

Then install the required vSphere SDK Perl modules through CPAN selecting default answers at any CPAN prompts.

sudo perl -MCPAN -e shell
cpan[1]> install Class::MethodMaker Crypt::SSLeay SOAP::Lite UUID Data::Dump
cpan[2]> exit

The vSphere Perl SDK requires UUID-0.03.  However, version 0.03 is marked as an unauthorized release.  I've run UUID-0.02 without issues, so as a fix we'll modify the vSphere Perl SDK Makefile.PL to use the current version of UUID hosted on CPAN.

sudo sed -i '.bak' -e "s/'UUID' => '0.03'/'UUID' => '0.02'/" Makefile.PL

On a supported operating system, the installer script would do all the work.  On OS X, however, the script will check and fail since it was called on an incompatible operating system.  We'll need to execute some of the installation steps manually to complete the vSphere SDK for Perl installation.

sudo perl Makefile.PL
sudo make install
# Copy esxcfg- and vicfg- commands to /usr/local/bin
sudo cp -rv ./bin/ /usr/local/bin/

The Perl Makefile.PL install placed the vSphere Perl SDK core modules into the standard Perl library path /Library/Perl/5.12/VMware.  The utility applications were installed under /usr/lib/vmware-viperl/apps.  The vSphere Perl SDK and WS-Management sample scripts were installed under /usr/share/doc/vmware-viperl/doc/samples.

Before testing the vSphere SDK for Perl utilities or running any custom scripts, you'll need to instruct LWP to ignore hostname validation of self-signed certificates.  Otherwise, you may get the cryptic message: Server version unavailable at '' at /Library/Perl/5.12/VMware/ line 545, <STDIN> line 1.

In newer versions of the Crypt::SSLeay module, stricter validation of SSL certificates is performed.  The issue has been discussed on the VMTN communities forums.

Note:  You should understand the full impact of globally disabling hostname verification in a production environment.  Blindly disabling SSL verification can increase the possibility of a man-in-the-middle attack.

The ESX CLI commands were copied into the default PATH location /usr/local/bin and can be invoked without a path prefix:
vicfg-vmknic --server= --username=administrator@vlab --vihost= --list
Verify ESX CLI Commands

The vSphere Perl SDK utility applications were installed into the /usr/lib/vmware-viperl/apps directory:
cd /usr/lib/vmware-viperl/apps/
general/ --username=administrator@vlab --server=
host/ --username=administrator@vlab --server= --hostname=
Validate vSphere Perl SDK Utilities

Finally, if you're interested in running the Web Services for Management (WS-Management) sample scripts or developing your own, the samples were installed into the /usr/share/doc/vmware-viperl/doc/samples directory:
cd /usr/share/doc/vmware-viperl/doc/samples
WSMan/ --server= --username=root
Validate vSphere Perl SDK WSMan

Note:  If you get the error Incorrect parameter at /Library/Perl/5.12/SOAP/ line 1993, <STDIN> line 1 when running the WS-Management sample scripts, it's most likely related to a known issue with the SOAP::Lite module.  As a quick workaround, you can modify line 1993 using the following sed command:
sudo sed -i '.bak' -e '1993s/\^\\d\$/\^\\d+\$/' /Library/Perl/5.12/SOAP/

The original version of the module will be copied to /Library/Perl/5.12/SOAP/ if you ever need to restore it.

The SOAP::Lite and Crypt::SSLeay issues aren't specific to OS X and will most likely be seen on supported Linux and Windows operating systems with those specific CPAN Perl module versions installed.

That's it!  You now have a working, unsupported vSphere SDK for Perl installation on your OS X system.


  1. This post is very helpful for me when I try to install WebService::Validator::CSS::W3C.
    Thank you for your great help!

  2. Wow! Thanks so much for the detailed and _accurate_ guide. You must have saved me at least 8 hours of frustration.

  3. Also requires XML::LibXML.

  4. Replies
    1. I never had any issues, usually XML::LibXML is already installed. What version of OSX are you using? Is it the default Perl install or a custom one?


  5. Thanks very much. I really need it.

  6. Trying to use it on iMac running Yosemite. I get the following SOAP request error for any command I attempt. Any thoughts or ideas will be most appreciated.

    SOAP request error - possibly a protocol issue: