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
How to list Virtual Machines in VMware using the Perl SDK API E-mail
Virtualization - VMware
Written by Allen Sanabria   
Wednesday, 04 June 2008 19:41

In this Quick HowTo, I will show you how to list all the Virtual Machines on VMware ESX 3.+ server using the Perl SDK API for VMware.

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!!


#!/usr/bin/perl

#This script will create a snapshot and list them for you
#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.



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


# Obtain all inventory objects of the specified type
my $e_vm = Vim::find_entity_views(view_type => 'VirtualMachine');
foreach $views (sort(@$e_vm)) {
    $vm_name = $views->name;
    print $vm_name, "\n";
    }
}
Util::disconnect();

Comments
Search RSS
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 )