Java 类com.vmware.vim25.HttpNfcLeaseState 实例源码

项目:photon-model    文件:LeaseProgressUpdater.java   
/**
 * 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");
}
项目:cs-actions    文件:WaitForValues.java   
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;
        }
    }
}
项目:photon-model    文件:LeaseProgressUpdater.java   
/**
 * 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");
}
项目:cloudstack    文件:HttpNfcLeaseMO.java   
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;
}
项目:cloudstack    文件:HttpNfcLeaseMO.java   
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;
    }
}
项目:vijava    文件:HttpNfcLease.java   
public HttpNfcLeaseState getState()
{
    return (HttpNfcLeaseState)getCurrentProperty("state");
}