public static boolean waitForHostStatus(IHostRepository repo, Host host, String status, int numAttempts){ int attempt = 0; while(attempt < numAttempts){ attempt++; try{Thread.sleep(1000);}catch(Exception e){throw new RuntimeException(e);} Host hostRefreshed = repo.show(host); LOG.debug("host " + host.getName() +" status: " + host.getState()); if(hostRefreshed.getState().equals(status)) return true; } return false; }
public Host createAndWaitForUp(IHostRepository repo, Host host) { host = repo.createOrShow(host); if (host.getState().equals("maintenance")) repo.activate(host); WaitUtil.waitForHostStatus(repo, host, "up", 30); return host; }