|
Reply
Re: List current tasks and its progress (percent) for a selected VM Jan 7, 2008 10:41 AM
|
|
Reply
Re: List current tasks and its progress (percent) for a selected VM Jan 8, 2008 1:38 AM
Reply
3.
Re: List current tasks and its progress (percent) for a selected VM Jan 8, 2008 1:38 AM
Hi,
Here you go with the perl sample code that you can use. It lists down all the task in the Recent Task List and displays their progress and Status. #!/usr/bin/perl -w #
use strict; use warnings; use FindBin; use lib "$FindBin::Bin/../"; use VMware::VIM2Runtime; use VMware::VILib; $Util::script_version = "1.0"; Opts::parse(); Opts::validate(); Util::connect(); display_progress(); Util::disconnect(); sub display_progress { Util::trace(0, "\nConnection Sucessful\n"); my $status = 'running'; my $si_moref = ManagedObjectReference->new(type => 'ServiceInstance', value => 'ServiceInstance'); my $si_view = Vim::get_view(mo_ref => $si_moref); my $sc_view; my $task; my $mytaskref; my $tm_view; $sc_view = $si_view->RetrieveServiceContent(); $tm_view = Vim::get_view (mo_ref =>$sc_view->taskManager); if (defined $tm_view->recentTask) { foreach (@{$tm_view->recentTask}) { $task = Vim::get_view(mo_ref => $_); print "\nTask Name: ". $task->info->descriptionId ." Status: ". $task->info->state->val . " Progress: " .$task->info->progress ."% Complete"; } } else { print "\nNo Recent Tasks available.\n"; } print "\nDisconnecting \n"; } Hope this code helps. ~ Sidharth |
|
Reply
Re: List current tasks and its progress (percent) for a selected VM Jan 8, 2008 6:13 AM
Reply
4.
Re: List current tasks and its progress (percent) for a selected VM Jan 8, 2008 6:13 AM
Thank you!!! It works! The only changes I need to do is to include the VM name behind the task name and fix a small error ( Use of uninitialized value in concatenation (.) or string at ./task.pl line 40.) when a task is queue, and have no progress yet..(I think). I also needed to change from VIM2Runtime to VIM25Runtime Points awarded! |