/** * Wait up to a minute for the nfcLease to become READY. * @throws Exception */ public void awaitReady() throws Exception { int i = 60; while (i-- > 0) { HttpNfcLeaseState state = getState(); if (state.equals(HttpNfcLeaseState.ERROR)) { LocalizedMethodFault leaseError = this.get.entityProp(this.nfcLease, PROP_ERROR); logger.warn("nfcLease error: {}", leaseError.getLocalizedMessage(), leaseError); VimUtils.rethrow(leaseError); } if (state.equals(HttpNfcLeaseState.READY)) { return; } logger.debug("Waiting for nfcLease {}", VimUtils.convertMoRefToString(this.nfcLease), state); Thread.sleep(LEASE_READY_RETRY_MILLIS); } throw new IllegalStateException("Lease not ready within configured timeout"); }
private Object[] getObjectState(String stateVal, Object[] filterValues) { if (stateVal == null) { return new Object[]{HttpNfcLeaseState.ERROR}; } else { switch (stateVal) { case READY: return new Object[]{HttpNfcLeaseState.READY}; case ERROR: return new Object[]{HttpNfcLeaseState.ERROR}; case FILTER_VALUES: return filterValues; default: return null; } } }
/** * For some reason getting the state of a nfcLease returns a element instead of HttpNfcLeaseState. * This method parses the dom element to a state. * * @return * @throws InvalidPropertyFaultMsg * @throws RuntimeFaultFaultMsg */ private HttpNfcLeaseState getState() throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg { Object state = this.get.entityProp(this.nfcLease, PROP_STATE); if (state instanceof HttpNfcLeaseState) { return (HttpNfcLeaseState) state; } if (state instanceof org.w3c.dom.Element) { org.w3c.dom.Element e = (org.w3c.dom.Element) state; return HttpNfcLeaseState.fromValue(e.getTextContent()); } throw new IllegalStateException("Cannot get state of nfcLease"); }
public HttpNfcLeaseState getState() throws Exception { Object stateProp = _context.getVimClient().getDynamicProperty(_mor, "state"); // Due to some issue in JAX-WS De-serialization getting the information // from the nodes assert (stateProp.toString().contains("val: null")); String stateVal = null; Element stateElement = (Element)stateProp; if (stateElement != null && stateElement.getFirstChild() != null) { stateVal = stateElement.getFirstChild().getTextContent(); } if (stateVal != null) { return HttpNfcLeaseState.fromValue(stateVal); } return HttpNfcLeaseState.ERROR; }
public HttpNfcLeaseState waitState(HttpNfcLeaseState[] states) throws Exception { assert (states != null); assert (states.length > 0); HttpNfcLeaseState state; while (true) { state = getState(); if (state == HttpNfcLeaseState.READY || state == HttpNfcLeaseState.ERROR) return state; } }
public HttpNfcLeaseState getState() { return (HttpNfcLeaseState)getCurrentProperty("state"); }