Hello All!
I am having an issue with a script I have written using the VIPerlToolKit. When I list the VM's in my inventory using the code below I am getting all VM's and Templates returned as well. Is there a filter or a different way to query to gain a list of only actual Virtual Machines and not the templates on the system.
my $vm = Vim::find_entity_views(view_type => "VirtualMachine");
foreach (@$vm) {
eval {
my $vmname = $_->name;
\# Do Some Work Here
}
}
Thanks Chris
I was able to do this by using the bit of code below
my $vm = Vim::find_entity_views(view_type => "VirtualMachine");
foreach (@$vm) {
eval {
my $vmname = $_->name;
my$vmtemplate = $_->\{config}->\{'template'};
if ($vmtemplates == 0 ){
\# Virtual Machine
}else{
#Template
}
}
}
A good perl debugger helps so much!
just a little hint...
what helped me a lot was dumping a vm view (or host view, network view,...)to a text file.
use Data::Dumper;
my $vm_view = Vim::find_entity_view(view_type => 'VirtualMachine');
print Dumper $vm_view;
run this one and save the output to a file (perl script.pl > vmview.txt)and you have one complete view of the first machine. (this would have also helped you searching for the dnsname)
now if you search something specific just open the textfile...
chris
