VMware {code} Community
norisnetwork
Enthusiast
Enthusiast

List of VMs with IOPS-Limit in a specific Cluster

Hello,

I want to list all VMs in a specific cluster which doesn't have an IOPS-Limit set on any of there disks.

My virtualisation environment looks like:

DATASTORE

- Cluster x

- Cluster y

  * Ressource Pool x

  * Ressource Pool y

    = VM 1

    = VM 2

How can I list VMs in a specific cluster and then only these, where any disk hasn't got an IOPS-Limit.

Thanks for any help,


Greets

Alex

Reply
0 Kudos
1 Reply
lamw
Community Manager
Community Manager

You can use the "begin_entity" as part of your filter to search within a specific cluster. Here's a quick snippet that'll get you started which accepts a Cluster name and will filter only VMs within that cluster.

#!/usr/bin/perl -w

use strict;
use warnings;
use VMware::VILib;
use VMware::VIRuntime;

my %opts = (
        cluster => {
                type => "=s",
                help => "Name of vSphere Cluster",
                required => 1,
        },
);

Opts::add_options(%opts);

Opts::parse();
Opts::validate();
Util::connect();

my $cluster = Opts::get_option('cluster');

my $cluster_view = Vim::find_entity_view(view_type => 'ClusterComputeResource', filter => {'name' => $cluster});
my $vm_views = Vim::find_entity_views(view_type => 'VirtualMachine', begin_entity => $cluster_view);

foreach my $vm (@$vm_views) {
        print $vm->name . "\n";
}

Util::disconnect();

Now that you have the list of VMs, you'll need to iterate through each of it's VirtualDisk and look at it's Shares and check on the limit property as referenced in the vSphere API - http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.StorageRes... and if it's -1 it means it's unlimited and any other value, there is a limit set.

I would recommend taking a look at the vSphere SDK for Perl programming guide to help get started http://www.vmware.com/support/developer/viperltoolkit/doc/perl_toolkit_guide_idx.html

Reply
0 Kudos