Hello, I'm trying to write a little perl script to collect events related to VM from the last 24H on a vCenter with the Perl VMware SDK 6.5 I use this code: my ($Y,$M,$D,$H,$Min,$S,$st,$et); ...
See more...
Hello, I'm trying to write a little perl script to collect events related to VM from the last 24H on a vCenter with the Perl VMware SDK 6.5 I use this code: my ($Y,$M,$D,$H,$Min,$S,$st,$et); my $today = DateTime->now; $Y = $today->year; $M = $today->month; $D = $today->day; $H = $today->hour; $Min = $today->minute; $S = $today->second; $st = DateTime->new( year => $Y, month => $M, day => $D-1, hour => $H , minute => $Min , second => $S); $et = DateTime->new( year => $Y, month => $M, day => $D , hour => $H , minute => $Min , second => $S); my $timeSpec = EventFilterSpecByTime->new(beginTime => $st); my $filterSpec = EventFilterSpec->new(time => $timeSpec, type => ["VmCreatedEvent", "VmClonedEvent","VmDeployedEvent", "VmRegisteredEvent","VmRemovedEvent"]); my $content = Vim::get_service_content(); my $eventMgr = Vim::get_view(mo_ref => $content->eventManager); my $results = $eventMgr->CreateCollectorForEvents(filter => $filterSpec); my $eventCollector = Vim::get_view(mo_ref => $results); $eventCollector->ResetCollector(); my $events = $eventCollector->latestPage; But the time filter seems to be not working, I have some result from the last few days, if i change the range I have alway the same result, same if I delete the filterSpec. With powercli and getvi-event I can get events from several month but for this need I need to use Perl. Did you already success to use a filterspec with Perl? Thanks, Raphaël