VMware Cloud Community
Davide_Petruni
Contributor
Contributor

New to vCo: best practice to to wait for a Host restart

Hello,

I'm new to vCo and I start writing my first workflow.

I need to: set an Host in maintenance mode, move in another cluster, [make some other works, i.e. update and or change conf], reboot, move to initial cluster, exit from maintenance mode.

Initially it is all ok, but when the host start rebooting, vCo start the next task (move) and then the next ( exit from miantenance mode).

Which is the best practice to tell workflow to wait until an host completely restarts?

Thanks in advance,

Davide

0 Kudos
3 Replies
tschoergez
Leadership
Leadership

The workflow somehow has to check if the host is fully available again.

You can either let the host itself notify vCO that it's up and running (but that needs some sort of script on the host), or (much easier) use the status of the host reported by vCenter.

In this case that's the .runtime.connectionState attribute of an HostSystem object. (search the vSphere API reference if you can find some alternative properties, perhaps via the AlarmSystem)

General strategy:

How would a human operator decide when to continue the process?

Make a smart use of System.sleep() vs. WaitForDateTime element in the workflow (here likely the latter). See here for more: http://blogs.vmware.com/orchestrator/2013/01/how-to-deal-with-long-running-external-processes.html

Cheers,

Joerg

Lapsang28
Contributor
Contributor

Hello,

If you use the workflows embedded in VCO 5.5 (Enter maintenance mode, reboot host, and exit maintenance mode), they already manage the task waiting.

For example, look at the "reboot host" workflow : it uses a script, taht takes "host" and "force" in input, and that pulls "task" as output. Task variable is then in input of the next step (vim3WaitTaskEnd), so the workflow won't be over until this next step is over (so, it means the workflow will end when the reboot is complete).

If you put a worflow after this one, it won't start after the reboot is complete.

0 Kudos
jarushepic
Enthusiast
Enthusiast

The built in workflow doesn't wait for the host to come back up.  I cloned it and added two tasks.  The first task waits for the host to actually stop responding:

while (host.runtime.connectionState != VcHostSystemConnectionState.notResponding)

{

  System.sleep(5000);

}

The second task waits for the host to come back up.

sleptSeconds = 0;

while (host.runtime.connectionState == VcHostSystemConnectionState.notResponding)

{

  System.sleep(5000);

  sleptSeconds += 5;

  if (sleptSeconds >= timeout)

  {

  throw "timeout of " + timeout.toString() + ' reached while waiting for host to come back online';

  }

}

0 Kudos