Reply to Message

View discussion in a popup

Replying to:
stumpr
Virtuoso
Virtuoso

Probably the easiest way is to check the HostSystem's runtime.connectionState.

$host = Vim::find_entity_view(view_type => 'HostSystem', properties => ['name', 'runtime.connectionState'], filter => {'name' => $host_name});

$connected = 0;

until ($connected) {

     $host->update_view_data();

     $connected = $host->{'runtime.connectionState'};

     # Add a timeout break here

}

# ...do something with newly rebooted host

I've also used runtime.bootTime in the past, where I wait for the value to be greater than the previous time XSD string recorded before the reboot request (with a long timeout to avoid any problems).  This is better than the connectionState option since it handles the window between the reboot request and the actual reboot.  It *shouldn't* update until the host is connected again (and available for you call to leave maintenanceMode).

Using these values works even when the host is not connected (cached by the vCenter API service), so you can wait for them to change (and in the case of connectionState, change again).  You'll just have to account for the window from the request to reboot and the actual reboot before you start polling using connectionState.

You can probably drop your ping logic as well if you properly code around the API state variables for the Host.

Reuben Stump | http://www.virtuin.com | @ReubenStump

View solution in original post

Reply
0 Kudos