VMware {code} Community
piuhapofuhpaosf
Contributor
Contributor

Trouble with find_entity_views

I'm trying to grab all of the templates from a datacenter. To do that, I'm trying to use find_entity_views and filter by 'config.template' => 1. Unfortunately, this is not working for me. Here's the code:

my $dc = $vim->find_entity_view(view_type=>'Datacenter',

filter=>{name=>'CALO-RTP-DEV'});

my $v = $vim->find_entity_views(view_type=>'VirtualMachine',

filter=>{'config.template'=>1},

begin_entity=>$dc->vmFolder);

print Dumper $v;

foreach my $x (@$v) {

print $x->name ."\n";

}

Unfortunately, no VMs are returned from the find_entity_views call. I've also tried this without using the begin_entity, as well as setting the begin_entity to just be the datacenter itself, and I still get nothing returned. In fact, the only way I've successfully gotten a return value from find_entity_views when using a filter is if to filter only searches the VM name (filter=>{name=>'whateverthenameis'}). That seems to be the only field it will successfully search. Also, it won't return anything when I filter using wildcard characters (filter=>{name=>'.something.'} OR filter=>{name=>qr/.something./i}). I've seen samples containing just about all of these sorts of searches, yet none of them work for me. Any ideas why that is? Any help is greatly appareciated.

0 Kudos
1 Reply
lamw
Community Manager
Community Manager

Duplicated thread, please refer to:

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Comuunity

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos