Child pages
  • vSphere Perl SDK and CLI RPM Packages

Table of contents


Overview

This is what VMware have to say about the vSphere Perl SDK:

The vSphere SDK for Perl provides an easy-to-use Perl scripting interface to the vSphere API. Administrators and developers can work with vSphere API objects using vSphere SDK for Perl subroutines.

The SDK is provided as a tarball which contains an installer script which is good, but for those of us that prefer to have a bit more control over our environments an RPM would be much nicer. The following information provides everything you will need to bundle the VMware provided tarball into an RPM which will allow simpler installation and more importantly cleaner uninstallation.

My personal preference is to install third party software to /opt so there is a patch applied to the SDK during package build to make this happen. There is also a second patch to switch from the UUID perl module to Data::UUID instead since this is supplied natively on Red Hat Enterprise 6 and Fedora systems as far back as release 8. The Data::UUID Perl module is provided by EPEL on Red Hat Enterprise 5 systems so presumably that would work too. Note that there is an unsatisfied dependency on the ExtUtils::MakeMaker Perl module on Red Hat Enterprise 5. This module is not available through the EPEL repository either, though it can be found in other third party repositories.

The VMware site offers separate downloads for VMware-vSphere-Perl-SDK and VMware-vSphere-CLI installers however despite the different names these packages are in fact identical. As such the patches and RPM spec file will work for either installer provided all references to VMware-vSphere-Perl-SDK in the spec file are altered in the case of VMware-vSphere-CLI.

 

Preparation

Files

If you are new to RPM packaging the have a read through this overview of Linux - RPM Packages#Package Building.

When you are ready to build the package download the following files into your RPM build environment:

$rpmbuild/SOURCES/VMware-vSphere-Perl-SDK/VMware-vSphere-Perl-SDK-5.1.0-780721.x86_64.tar.gz
$rpmbuild/SOURCES/VMware-vSphere-Perl-SDK/makefile.patch
$rpmbuild/SOURCES/VMware-vSphere-Perl-SDK/uuid-module.patch
$rpmbuild/SPECS/VMware-vSphere-Perl-SDK.spec

Packages

The following packages are required on Red Hat and Fedora systems to build the VMware vSphere Perl SDK package.

  • perl
  • perl-Crypt-SSLeay
  • perl-ExtUtils-MakeMaker
  • perl-libwww-perl
  • perl-Net-SSLeay
  • perl-SOAP-Lite
  • perl-URI
  • perl-XML-LibXML
  • rpm-build
  • uuid-perl

The following command would install all these packages in one go:

sudo yum install perl perl-Crypt-SSLeay perl-ExtUtils-MakeMaker perl-libwww-perl perl-Net-SSLeay \
                 perl-SOAP-Lite perl-URI perl-XML-LibXML rpm-build uuid-perl

 

Building the package

 

Always build packages as a non-privileged user and never as root

Building the package will result in the created of two RPM packages, VMware-vSphere-Perl-SDK and VMware-vSphere-CLI.

rpmbuild -ba ~rpmbuild/SPECS/VMware-vSphere-Perl-SDK.spec

Many thanks to Schlomo Schapiro for providing updates for version 5.1.0.

 

Installation

As mentioned in the build section there are two packages. The VMware-vSphere-Perl-SDK package can be installed by itself and only provides the VMware SDK Perl modules which can be used to develop yourr own vSphere tools.

sudo yum localinstall ~rpmbuild/RPMS/VMware-vSphere-Perl-SDK-5.0.0-422456.1.fc15.x86_64.rpm

The VMware-vSphere-CLI package provides the RCLI/vCLI components which are used to remotely manage vCenter and hypervisor hosts. This package depends on the Perl SDK in which case both packages need to be installed.

sudo yum localinstall ~rpmbuild/RPMS/VMware-vSphere-Perl-SDK-5.0.0-422456.1.fc15.x86_64.rpm \
                      ~rpmbuild/RPMS/VMware-vSphere-CLI-5.0.0-422456.1.fc15.x86_64.rpm

 

Troubleshooting

"Server version unavailable" error message

First ensure that LWP::Protocol::https is installed. Secondly recent versions of the Perl LWP module have strict checking enabled for SSL connections by default. Since most ESX and vCenter installs make use of self-signed certificates the check will fail as these certificates are not signed by a trusted certificate authority.

To fix the strict checking issue any of the following options are available:

  • Install certificates signed by a certificate authority on all ESX and vCenter hosts
    If an enterprise internal certificate authority is used the CA certificate will need to be installed on the Perl SDK hosts as well
  • set the PERL_LWP_SSL_VERIFY_HOSTNAME environment variable to 0prior to running the scripts (or set it in your profile)

    export PERL_LWP_SSL_VERIFY_HOSTNAME=0
  • add the environment variable to any scripts that use the Perl SDK

    $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;

If none of these options work then it could also be a proxy issue so try unsetting any $http_proxy and $https_proxy environment variables if not required for connections to the ESXi or vCenter hosts.