VMware {code} Community
tdfeathe
Contributor
Contributor

Wait for the Guest OS to shutdown?

I tried a few things but I can't get code to wait for the Guest OS to shutdown. Any ideas?

0 Kudos
3 Replies
StefanPahrmann

That should do it:

do{
    my $temp_vms = Vim::find_entity_view(view_type => 'VirtualMachine',
                                               filter => {'name' => 'servername' });
 
    if($temp_vms->runtime->powerState->val ne 'poweredOff'){
         sleep 5;
     }else{
         $sd=1;
    }
}while($sd != 1);

-Stefan

0 Kudos
tdfeathe
Contributor
Contributor

I put that in a while loop and it still doesn't work....

0 Kudos
StefanPahrmann

Sorry was a bit fast with the code, I updated it to include a loop.

If you still aren't getting any right state, you can try to do some output with each loop:

    print $temp_vms->runtime->powerState."\n";

Are you sure there isn't any question pending?

0 Kudos