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

项目:vsphere-automation-sdk-java    文件:WaitForValues.java   
/**
 * This method returns a boolean value specifying whether the Task is
 * succeeded or failed.
 *
 * @param task
 *            ManagedObjectReference representing the Task.
 * @return boolean value representing the Task result.
 * @throws InvalidCollectorVersionFaultMsg
 *
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 */
public boolean getTaskResultAfterDone(ManagedObjectReference task)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg,
        InvalidCollectorVersionFaultMsg {

    boolean retVal = false;

    // info has a property - state for state of the task
    Object[] result = wait(task,
            new String[] { "info.state", "info.error" },
            new String[] { "state" }, new Object[][] { new Object[] {
                TaskInfoState.SUCCESS, TaskInfoState.ERROR } });

    if (result[0].equals(TaskInfoState.SUCCESS)) {
        retVal = true;
    }
    if (result[1] instanceof LocalizedMethodFault) {
        throw new RuntimeException(
                ((LocalizedMethodFault) result[1]).getLocalizedMessage());
    }
    return retVal;
}
项目:photon-model    文件:VimUtils.java   
public static TaskInfo waitTaskEnd(Connection connection, ManagedObjectReference task)
        throws InvalidCollectorVersionFaultMsg, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    WaitForValues waitForValues = new WaitForValues(connection);

    Object[] info = waitForValues.wait(task,
            new String[] { VimPath.task_info },
            new String[] { VimPath.task_info_state },
            new Object[][] { new Object[] {
                    TaskInfoState.SUCCESS,
                    TaskInfoState.ERROR
            } });

    return (TaskInfo) info[0];
}
项目:cs-actions    文件:ResponseHelper.java   
public Map<String, String> getResultsMap(String successMessage, String failureMessage)
        throws InvalidCollectorVersionFaultMsg, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {

    return (getTaskResultAfterDone(connectionResources, task)) ?
            ResponseUtils.getResultsMap(successMessage, Outputs.RETURN_CODE_SUCCESS) :
            ResponseUtils.getResultsMap(failureMessage, Outputs.RETURN_CODE_FAILURE);
}
项目:cs-actions    文件:ResponseHelper.java   
protected boolean getTaskResultAfterDone(ConnectionResources connectionResources, ManagedObjectReference task)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
    WaitForValues waitForValues = new WaitForValues(connectionResources.getConnection());
    Object[] result = waitForValues.wait(task, new String[]{ManagedObjectType.INFO_STATE.getValue(),
                    ManagedObjectType.INFO_ERROR.getValue()}, new String[]{ManagedObjectType.STATE.getValue()},
            new Object[][]{new Object[]{TaskInfoState.SUCCESS, TaskInfoState.ERROR}});

    if (result[1] instanceof LocalizedMethodFault) {
        throw new RuntimeException(((LocalizedMethodFault) result[1]).getLocalizedMessage());
    }

    return result[0].equals(TaskInfoState.SUCCESS);
}
项目:photon-model    文件:InstanceClient.java   
private TaskInfo waitTaskEnd(ManagedObjectReference task)
        throws InvalidCollectorVersionFaultMsg, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    return VimUtils.waitTaskEnd(this.connection, task);
}
项目:photon-model    文件:DiskClient.java   
/**
 * Wait for the server initiated task to complete.
 */
private TaskInfo waitTaskEnd(ManagedObjectReference task)
        throws InvalidCollectorVersionFaultMsg, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    return VimUtils.waitTaskEnd(this.connection, task);
}
项目:cs-actions    文件:WaitForValues.java   
/**
 * Handle Updates for a single object. waits till expected values of
 * properties to check are reached Destroys the ObjectFilter when done.
 *
 * @param objMor         MOR of the Object to wait for param
 * @param filterProps    Properties list to filter
 * @param endWaitProps   Properties list to check for expected values these be properties
 *                       of a property in the filter properties list
 * @param expectedValues values for properties to end the wait
 * @return true indicating expected values were met, and false otherwise
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 * @throws InvalidCollectorVersionFaultMsg
 */
public Object[] wait(ManagedObjectReference objMor, String[] filterProps, String[] endWaitProps, Object[][] expectedValues)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {

    String version = Constants.EMPTY;
    String stateVal = null;

    Object[] endValues = new Object[endWaitProps.length];
    Object[] filterValues = new Object[filterProps.length];

    PropertyFilterSpec spec = propertyFilterSpec(objMor, filterProps);
    ManagedObjectReference filterSpecRef = vimPort.createFilter(serviceContent.getPropertyCollector(), spec, true);

    boolean reached = false;
    UpdateSet updateset;
    while (!reached) {
        updateset = vimPort.waitForUpdatesEx(serviceContent.getPropertyCollector(), version, new WaitOptions());

        int waitForUpdateCounter = 0;
        if (updateset == null || updateset.getFilterSet() == null) {
            waitForUpdateCounter++;
            if (waitForUpdateCounter <= MAX_TRIED_WAIT_FOR_UPDATE_COUNTER) {
                continue;
            }
            break;
        }

        version = updateset.getVersion();
        for (PropertyFilterUpdate filtup : updateset.getFilterSet()) {
            for (ObjectUpdate objup : filtup.getObjectSet()) {
                if (objup.getKind() == ObjectUpdateKind.MODIFY || objup.getKind() == ObjectUpdateKind.ENTER ||
                        objup.getKind() == ObjectUpdateKind.LEAVE) {
                    for (PropertyChange propchg : objup.getChangeSet()) {
                        updateValues(endWaitProps, endValues, propchg);
                        updateValues(filterProps, filterValues, propchg);
                    }
                }
            }
        }
        // Check if the expected values have been reached and exit the loop if done.
        // Also exit the WaitForUpdates loop if this is the case.
        for (int chgi = 0; chgi < endValues.length && !reached; chgi++) {
            for (int vali = 0; vali < expectedValues[chgi].length && !reached; vali++) {
                Object expctdval = expectedValues[chgi][vali];
                if (endValues[chgi].toString().contains(KEY_VALUE_NULL_STRING)) {
                    Element stateElement = (Element) endValues[chgi];
                    if (stateElement != null && stateElement.getFirstChild() != null) {
                        stateVal = stateElement.getFirstChild().getTextContent();
                        reached = expctdval.toString().equalsIgnoreCase(stateVal);
                    }
                } else {
                    expctdval = expectedValues[chgi][vali];
                    reached = expctdval.equals(endValues[chgi]);
                    stateVal = FILTER_VALUES;
                }
            }
        }
    }
    try {
        vimPort.destroyPropertyFilter(filterSpecRef);
    } catch (RuntimeFaultFaultMsg e) {
        throw new RuntimeException(e.getMessage());
    }

    return getObjectState(stateVal, filterValues);
}
项目:cloudstack    文件:VMwareUtil.java   
private static Object[] waitForValues(VMwareConnection connection, ManagedObjectReference morObj, String[] filterProps,
        String[] endWaitProps, Object[][] expectedVals) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg,
        InvalidCollectorVersionFaultMsg {
    String version = "";
    Object[] endVals = new Object[endWaitProps.length];
    Object[] filterVals = new Object[filterProps.length];

    PropertyFilterSpec spec = new PropertyFilterSpec();

    ObjectSpec oSpec = new ObjectSpec();

    oSpec.setObj(morObj);
    oSpec.setSkip(Boolean.FALSE);

    spec.getObjectSet().add(oSpec);

    PropertySpec pSpec = new PropertySpec();

    pSpec.getPathSet().addAll(Arrays.asList(filterProps));
    pSpec.setType(morObj.getType());

    spec.getPropSet().add(pSpec);

    ManagedObjectReference propertyCollector = connection.getServiceContent().getPropertyCollector();
    ManagedObjectReference filterSpecRef = connection.getVimPortType().createFilter(propertyCollector, spec, true);

    boolean reached = false;

    UpdateSet updateSet;
    List<PropertyFilterUpdate> lstPropertyFilterUpdates;
    List<ObjectUpdate> lstObjectUpdates;
    List<PropertyChange> lstPropertyChanges;

    while (!reached) {
        updateSet = connection.getVimPortType().waitForUpdates(propertyCollector, version);

        if (updateSet == null || updateSet.getFilterSet() == null) {
            continue;
        }

        version = updateSet.getVersion();

        lstPropertyFilterUpdates = updateSet.getFilterSet();

        for (PropertyFilterUpdate propertyFilterUpdate : lstPropertyFilterUpdates) {
            lstObjectUpdates = propertyFilterUpdate.getObjectSet();

            for (ObjectUpdate objUpdate : lstObjectUpdates) {
                if (objUpdate.getKind() == ObjectUpdateKind.MODIFY || objUpdate.getKind() == ObjectUpdateKind.ENTER ||
                        objUpdate.getKind() == ObjectUpdateKind.LEAVE) {
                    lstPropertyChanges = objUpdate.getChangeSet();

                    for (PropertyChange propchg : lstPropertyChanges) {
                        updateValues(endWaitProps, endVals, propchg);
                        updateValues(filterProps, filterVals, propchg);
                    }
                }
            }
        }

        Object expectedValue;

        // Check if the expected values have been reached and exit the loop if done.
        // Also, exit the WaitForUpdates loop if this is the case.
        for (int chgi = 0; chgi < endVals.length && !reached; chgi++) {
            for (int vali = 0; vali < expectedVals[chgi].length && !reached; vali++) {
                expectedValue = expectedVals[chgi][vali];

                reached = expectedValue.equals(endVals[chgi]) || reached;
            }
        }
    }

    // Destroy the filter when we are done.
    connection.getVimPortType().destroyPropertyFilter(filterSpecRef);

    return filterVals;
}
项目:photon-model    文件:WaitForValues.java   
/**
 * @see #wait(ManagedObjectReference, String[], String[], Object[][], Integer)
 * @param moRef
 * @param fetchProps
 * @param propsToMatch
 * @param propsMatchValues
 * @return
 * @throws InvalidPropertyFaultMsg
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidCollectorVersionFaultMsg
 */
public Object[] wait(ManagedObjectReference moRef,
        String[] fetchProps, String[] propsToMatch, Object[][] propsMatchValues)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg,
        InvalidCollectorVersionFaultMsg {
    return wait(moRef, fetchProps, propsToMatch, propsMatchValues, null);
}