Dear All,
Here is my code which return VM count in
real | 0m38.877s |
user | 0m13.869s |
sys | 0m0.503s |
for below code, how do i improve the time to fetch the results.
my $host_name = Opts::get_option('vmhost');
my $host_view = Vim::find_entity_view(view_type => 'HostSystem', filter => {'name' => $host_name});
&listVMs($host_view);
sub listVMs {
# Prints a list of registered VM on the screen.
# Does not log it's use.
#
my ($host_view) = @_;
my $vms = Vim::get_views(mo_ref_array => $host_view->vm, properties => ['name','runtime.powerState','guest.toolsRunningStatus']);
my $totalVMs = 0;
foreach(@$vms) {
$totalVMs += 1;
print "VM: ".$_->{'name'}.", ".$_->{'runtime.powerState'}->val.", "
.$_->{'guest.toolsRunningStatus'}.", ".$_->{'mo_ref'}->value."\n";
}
print "\nTotal ".$totalVMs." VMs found.\n\n"
}