Looked through the perl toolkit programming guide but nothing clicked yet.
I guess a "VI PHP toolkit" is out of the question so I'm forced to learn Perl (which probably isn't a bad idea anyway, even if it is second best next to PHP). (lighten up, just instigating).
Now that some of you are shaking in anger, I'll ask my question:
How can I get a list of VM's and the hosts they are running on within a resource pool using the perl toolkit?
(vidiscovery.pl gets me close but not exactly what I need).
Hi,
following will do (put the right values in the first 4 lines):
my $filter=<ressourcegroup name>; my $service_url="https://localhost/sdk"; my $username=""; my $password=""; use VMware::VIM2Runtime; use VMware::VILib; Vim::login(service_url => $service_url, user_name => $username, password => $password); my $ressource_group = Vim::find_entity_view(view_type => 'ResourcePool', filter => {'name' => $filter } ); my $xvm_views = Vim::find_entity_views(view_type => "VirtualMachine", begin_entity => $ressource_group ); foreach(@$xvm_views){ $host=Vim::get_view(mo_ref => ($_->runtime->host) ); print "VM: ".$_->name; print " Host:".$host->name."\n"; } Vim::logout();
Regards
Stefan
Message was edited by: StefanPahrmann (forgot the 'use'-statements)
Hi,
following will do (put the right values in the first 4 lines):
my $filter=<ressourcegroup name>; my $service_url="https://localhost/sdk"; my $username=""; my $password=""; use VMware::VIM2Runtime; use VMware::VILib; Vim::login(service_url => $service_url, user_name => $username, password => $password); my $ressource_group = Vim::find_entity_view(view_type => 'ResourcePool', filter => {'name' => $filter } ); my $xvm_views = Vim::find_entity_views(view_type => "VirtualMachine", begin_entity => $ressource_group ); foreach(@$xvm_views){ $host=Vim::get_view(mo_ref => ($_->runtime->host) ); print "VM: ".$_->name; print " Host:".$host->name."\n"; } Vim::logout();
Regards
Stefan
Message was edited by: StefanPahrmann (forgot the 'use'-statements)
Perfect. Thanks Stefan.
FWIW, Learning Perl, has been a big help.
You're welcome, glad i could help
Btw I would appreciate if you marked my answer as a correct answer.
Regards
Stefan