Administering vSphere using Perl – Introducing VSPP

Yes, I know you can use the vSphere Perl SDK and it’s ‘OK’ , however, as I wanted to a) learn more perl and b) learn more about the vSphere SDK I started playing with the idea of creating an abstraction layer on top of the vSphere perl SDK that provided perl functions similar in operation to the PowerCLI cmdlets available.

Why?  Well there is a) and b) above, but additionally there is c) because I can 🙂

I figured some of the code might be interesting to some so I created a project over at and i’m making the code available for anyone who wants it –  if no one does then that is OK as well.

The project is called VSPP (vsphere power perl) , yes you can tell I don’t work in marketing!  You can find the code via subversion at sourceforge.   It’s still pretty crude, no installable packages yet (or maybe ever).

Here’s an example piece of code (also in the svn repos) that Displays all the Hosts in a Datacenter using the VSPP api.

#!/usr/bin/perl -w

# DisplayHostsDatacenter: Display all the hosts in a specific datacenter
use strict;
use warnings;

use vspp;

my %opts = (
Datacenter => {
type => "=s",
help => "Datacenter name to display hosts for",
required => 1}

my $dcname=Opts::get_option('Datacenter');


my $dc = vspp::GetDatacenter( Name => $dcname ) ;
my $hosts = vspp::GetVMHost( Location => $dc );
print "Datacenter $dcname has " . scalar(@$hosts) . " hosts \nThey are :\n";
foreach (@$hosts) {
print $_->name . "\n";


And the output looks like this :

> ./ --server --Datacenter HomeDC
Datacenter HomeDC has 5 hosts 
They are :

This is ‘similar’ to what you would see in PowerCLI and considerably easier than using the vSphere SDK directly.

Anyway, enjoy.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s