No Account Yet?

You are not logged in.

Add to: JBookmarks Add to: Facebook Add to: Windows Live Add to: Digg Add to: Del.icoi.us Add to: Reddit Add to: StumbleUpon Add to: Slashdot Add to: Netscape Add to: Furl Add to: Yahoo Add to: Blogmarks Add to: Technorati Add to: Newsvine Add to: Google Information
VMware Perl SDK get license perl script E-mail
Virtualization - VMware
Written by Allen Sanabria   
Wednesday, 21 May 2008 17:34

I needed a script that would get all relevant license data from our VMWare ESX Server using the Perl SDK for VMWare. We needed to know what type of licenses we have with how many are being used and how many are available. I would like to thank my friend Chris Hahn for reminding me about Data::Dumper, because without that this would have taken me longer then it should have... ( I'm a Python Programmer )

Update... I realized after working with the SDK for the past 2 months that I did not need Data:Dumper and the script has now been updated and it is shorter.

This script assumes you have the VMware Infrastructure (VI) Perl Toolkit Packages installed and your $HOME/.visdkrc set correctly. Without the above the script below will not work!!

Example output of running this script.../

costUnit = cpuPackage
featureName = VMware DRS
featureDescription = count per CPU package
total = 100
available = 90 

#!/usr/bin/perl
#

#Purpose of this script is to get the Licenses we have from our VMWare ESX Server..
#Type of License, How many used, How many available..
#Copyright (C) 2008 Allen Sanabria

#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License along
#with this program; if not, write to the Free Software Foundation, Inc.,
#51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#Example output
#Cost per Unit:             cpuPackage
#Feature Name:            ESX Server Standard
#Feature Description:    Grants: count per CPU package
#Total Licenses:           314
#Total Available:           290



use strict;
use warnings;
use VMware::VIRuntime;
Opts::parse();
Opts::validate();
Util::connect();

my $content   = Vim::get_service_content();
my $licMgr    = Vim::get_view( mo_ref => $content->licenseManager );
my $lic_usage = $licMgr->QueryLicenseSourceAvailability;

foreach my $line (@$lic_usage) {
    print "Cost per Unit:\t\t" . $line->feature->costUnit . "\n";
    print "Feature Name:\t\t" . $line->feature->featureName . "\n";
    print "Feature Description:\t" . $line->feature->featureDescription . "\n";
    print "Total Licenses:\t\t" . $line->total . "\n";
    print "Total Available:\t" . $line->available . "\n\n";

}
Vim::logout();

Comments
Search RSS
dynasty  - Update     |SAdministrator |2008-07-01 08:09:26
Update... I realized after working with the SDK for the past 2 months that I did
not need Dataumper and the script has now been updated and it is shorter.
Only registered users can write comments!

3.22 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."

Last Updated ( Tuesday, 29 July 2008 12:20 )