return ImmutableList.copyOf(jobIds);
}
public static void waitForVMtoStart(final CloudStackClient client, final String vmName) {
checkNotEmpty(vmName);
VirtualMachine machine = getVirtualMachineByName(client, vmName);
String id = machine.getId();
long startTime = System.currentTimeMillis();
while (machine.getState() == STARTING) {
try {
LOG.info("Waiting for VM {} - id {} to start", machine.getName(), machine.getId());
TimeUnit.SECONDS.sleep(BETWEEN_REQUESTS_SLEEP_TIME);
machine = client.getVirtualMachineClient().getVirtualMachine(id);
} catch (InterruptedException e) {
LOG.info("Interrupted while waiting for VM's to start");
Throwables.propagateIfPossible(e);
}
if (timeOutExceeded(startTime)) {
break;
}
}
switch (machine.getState()) {
case RUNNING:
LOG.info("VM {} is running, as expected", vmName);
break;
default:
throw new IllegalStateException("VM " + machine + "is not in RUNNING state");