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.
You'll want to use the strings 'true' and 'false' for your pattern matching.
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' => qr/true/i},* begin_entity=>$dc->vmFolder); print Dumper $v; foreach my $x (@$v) { print $x->name ."\n"; }
You'll want to use the strings 'true' and 'false' for your pattern matching.
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' => qr/true/i},* begin_entity=>$dc->vmFolder); print Dumper $v; foreach my $x (@$v) { print $x->name ."\n"; }
Beautiful! Thanks for the help.