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

项目:photon-model    文件:GetMoRef.java   
/**
 * Returns all the MOREFs of the specified type that are present under the
 * container
 *
 * @param container       {@link ManagedObjectReference} of the container to begin the
 *                        search from
 * @param morefType       Type of the managed entity that needs to be searched
 * @param morefProperties Array of properties to be fetched for the moref
 * @return Map of MOREF and Map of name value pair of properties requested of
 *         the managed objects present. If none exist then empty Map is
 *         returned
 * @throws InvalidPropertyFaultMsg
 * @throws RuntimeFaultFaultMsg
 */
public Map<ManagedObjectReference, Map<String, Object>> inContainerByType(
        ManagedObjectReference container, String morefType,
        String[] morefProperties, RetrieveOptions retrieveOptions)
        throws InvalidPropertyFaultMsg,
        RuntimeFaultFaultMsg {
    List<ObjectContent> oCont = containerViewByType(container, morefType, retrieveOptions,
            morefProperties).getObjects();

    Map<ManagedObjectReference, Map<String, Object>> tgtMoref =
            new HashMap<ManagedObjectReference, Map<String, Object>>();

    if (oCont != null) {
        for (ObjectContent oc : oCont) {
            Map<String, Object> propMap = new HashMap<String, Object>();
            List<DynamicProperty> dps = oc.getPropSet();
            if (dps != null) {
                for (DynamicProperty dp : dps) {
                    propMap.put(dp.getName(), dp.getVal());
                }
            }
            tgtMoref.put(oc.getObj(), propMap);
        }
    }
    return tgtMoref;
}
项目:cs-actions    文件:MoRefHandler.java   
/**
 * Method to retrieve properties of a {@link ManagedObjectReference}
 *
 * @param entityMor {@link ManagedObjectReference} of the entity
 * @param props     Array of properties to be looked up
 * @return Map of the property name and its corresponding value
 * @throws InvalidPropertyFaultMsg If a property does not exist
 * @throws RuntimeFaultFaultMsg
 */
public Map<String, Object> entityProps(ManagedObjectReference entityMor, String[] props)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    final HashMap<String, Object> retVal = new HashMap<>();
    // Create PropertyFilterSpec using the PropertySpec and ObjectPec
    PropertyFilterSpec[] propertyFilterSpecs = {new PropertyFilterSpecBuilder().propSet(
            // Create Property Spec
            new PropertySpecBuilder().all(false).type(entityMor.getType()).pathSet(props))
            .objectSet(
            // Now create Object Spec
            new ObjectSpecBuilder().obj(entityMor))};

    List<ObjectContent> objCont = vimPort.retrievePropertiesEx(serviceContent.getPropertyCollector(),
            Arrays.asList(propertyFilterSpecs), new RetrieveOptions()).getObjects();

    if (objCont != null) {
        for (ObjectContent oc : objCont) {
            List<DynamicProperty> dps = oc.getPropSet();
            for (DynamicProperty dp : dps) {
                retVal.put(dp.getName(), dp.getVal());
            }
        }
    }

    return retVal;
}
项目:oscm    文件:ManagedObjectAccessor.java   
/**
 * Uses the new RetrievePropertiesEx method to emulate the now deprecated
 * RetrieveProperties method
 *
 * @param filterSpecs
 * @return list of object content
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 * @throws Exception
 */
private List<ObjectContent> retrievePropertiesAllObjects(
        List<PropertyFilterSpec> filterSpecs)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {

    RetrieveOptions retrieveOptions = new RetrieveOptions();
    ManagedObjectReference collector = serviceContent
            .getPropertyCollector();

    List<ObjectContent> contents = new ArrayList<ObjectContent>();

    RetrieveResult results = vimPort.retrievePropertiesEx(collector,
            filterSpecs, retrieveOptions);
    if (results != null && results.getObjects() != null
            && !results.getObjects().isEmpty()) {
        contents.addAll(results.getObjects());
    }
    String token = null;
    if (results != null && results.getToken() != null) {
        token = results.getToken();
    }
    while (token != null && token.length() > 0) {
        results = vimPort.continueRetrievePropertiesEx(collector, token);
        token = null;
        if (results != null) {
            token = results.getToken();
            if (results.getObjects() != null
                    && !results.getObjects().isEmpty()) {
                contents.addAll(results.getObjects());
            }
        }
    }

    return contents;
}
项目:photon-model    文件:EnumerationClient.java   
ObjectContentIterator(ManagedObjectReference pc, PropertyFilterSpec spec) {
    this.pc = pc;
    this.spec = spec;

    this.opts = new RetrieveOptions();
    this.opts.setMaxObjects(DEFAULT_FETCH_PAGE_SIZE);
}
项目:photon-model    文件:GetMoRef.java   
public RetrieveResult containerViewByType(
        final ManagedObjectReference container,
        final String morefType,
        final RetrieveOptions retrieveOptions
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    return this.containerViewByType(container, morefType, retrieveOptions, "name");
}
项目:photon-model    文件:GetMoRef.java   
/**
 * Returns the raw RetrieveResult object for the provided container filtered on properties list
 *
 * @param container       - container to look in
 * @param morefType       - type to filter for
 * @param morefProperties - properties to include
 * @return com.vmware.vim25.RetrieveResult for this query
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 */
public RetrieveResult containerViewByType(
        final ManagedObjectReference container,
        final String morefType,
        final RetrieveOptions retrieveOptions,
        final String... morefProperties
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    init();

    PropertyFilterSpec[] propertyFilterSpecs = propertyFilterSpecs(container, morefType,
            morefProperties);

    return containerViewByType(container, morefType, morefProperties, retrieveOptions,
            propertyFilterSpecs);
}
项目:photon-model    文件:GetMoRef.java   
public RetrieveResult containerViewByType(
        final ManagedObjectReference container,
        final String morefType,
        final String[] morefProperties,
        final RetrieveOptions retrieveOptions,
        final PropertyFilterSpec... propertyFilterSpecs
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    init();
    return this.vimPort.retrievePropertiesEx(
            this.serviceContent.getPropertyCollector(),
            Arrays.asList(propertyFilterSpecs),
            retrieveOptions
    );
}
项目:photon-model    文件:GetMoRef.java   
/**
 * Returns all the MOREFs of the specified type that are present under the
 * folder
 *
 * @param folder    {@link ManagedObjectReference} of the folder to begin the search
 *                  from
 * @param morefType Type of the managed entity that needs to be searched
 * @return Map of name and MOREF of the managed objects present. If none
 *         exist then empty Map is returned
 * @throws InvalidPropertyFaultMsg
 *
 * @throws RuntimeFaultFaultMsg
 *
 */
public Map<String, ManagedObjectReference> inFolderByType(
        final ManagedObjectReference folder, final String morefType,
        final RetrieveOptions retrieveOptions
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    final PropertyFilterSpec[] propertyFilterSpecs = propertyFilterSpecs(folder, morefType,
            "name");

    // reuse this property collector again later to scroll through results
    final ManagedObjectReference propertyCollector = this.serviceContent.getPropertyCollector();

    RetrieveResult results = this.vimPort.retrievePropertiesEx(
            propertyCollector,
            Arrays.asList(propertyFilterSpecs),
            retrieveOptions);

    final Map<String, ManagedObjectReference> tgtMoref = new HashMap<>();
    while (results != null && !results.getObjects().isEmpty()) {
        resultsToTgtMorefMap(results, tgtMoref);
        final String token = results.getToken();
        // if we have a token, we can scroll through additional results, else there's nothing to do.
        results =
                (token != null) ?
                        this.vimPort.continueRetrievePropertiesEx(propertyCollector, token) : null;
    }

    return tgtMoref;
}
项目:photon-model    文件:GetMoRef.java   
/**
 * Method to retrieve properties of a {@link ManagedObjectReference}
 *
 * @param entityMor {@link ManagedObjectReference} of the entity
 * @param props     Array of properties to be looked up
 * @return Map of the property name and its corresponding value
 * @throws InvalidPropertyFaultMsg If a property does not exist
 * @throws RuntimeFaultFaultMsg
 */
public Map<String, Object> entityProps(
        ManagedObjectReference entityMor, String... props)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {

    init();

    final HashMap<String, Object> retVal = new HashMap<>();

    // Create PropertyFilterSpec using the PropertySpec and ObjectPec
    PropertyFilterSpec[] propertyFilterSpecs = {
            new PropertyFilterSpecBuilder()
                    .propSet(
                            // Create Property Spec
                            new PropertySpecBuilder()
                                    .all(Boolean.FALSE)
                                    .type(entityMor.getType())
                                    .pathSet(props)
                    )
                    .objectSet(
                    // Now create Object Spec
                    new ObjectSpecBuilder()
                            .obj(entityMor)
            )
    };

    List<ObjectContent> oCont =
            this.vimPort.retrievePropertiesEx(this.serviceContent.getPropertyCollector(),
                    Arrays.asList(propertyFilterSpecs), new RetrieveOptions()).getObjects();

    if (oCont != null) {
        for (ObjectContent oc : oCont) {
            List<DynamicProperty> dps = oc.getPropSet();
            for (DynamicProperty dp : dps) {
                retVal.put(dp.getName(), dp.getVal());
            }
        }
    }
    return retVal;
}
项目:vsphere-automation-sdk-java    文件:VimUtil.java   
/**
 * Uses the new RetrievePropertiesEx method to emulate the now deprecated
 * RetrieveProperties method.
 *
 * @param listpfs
 * @return list of object content
 * @throws Exception
 */
public static List<ObjectContent> retrievePropertiesAllObjects(
        VimPortType vimPort, ManagedObjectReference propCollectorRef,
        List<PropertyFilterSpec> listpfs)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    RetrieveOptions propObjectRetrieveOpts = new RetrieveOptions();
    List<ObjectContent> listobjcontent = new ArrayList<ObjectContent>();

    RetrieveResult rslts = vimPort.retrievePropertiesEx(propCollectorRef,
            listpfs, propObjectRetrieveOpts);
    if (rslts != null && rslts.getObjects() != null
            && !rslts.getObjects().isEmpty()) {
        listobjcontent.addAll(rslts.getObjects());
    }
    String token = null;
    if (rslts != null && rslts.getToken() != null) {
        token = rslts.getToken();
    }
    while (token != null && !token.isEmpty()) {
        rslts = vimPort.continueRetrievePropertiesEx(propCollectorRef,
                token);
        token = null;
        if (rslts != null) {
            token = rslts.getToken();
            if (rslts.getObjects() != null
                    && !rslts.getObjects().isEmpty()) {
                listobjcontent.addAll(rslts.getObjects());
            }
        }
    }

    return listobjcontent;
}
项目:development    文件:ManagedObjectAccessor.java   
/**
 * Uses the new RetrievePropertiesEx method to emulate the now deprecated
 * RetrieveProperties method
 *
 * @param filterSpecs
 * @return list of object content
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 * @throws Exception
 */
private List<ObjectContent> retrievePropertiesAllObjects(
        List<PropertyFilterSpec> filterSpecs)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {

    RetrieveOptions retrieveOptions = new RetrieveOptions();
    ManagedObjectReference collector = serviceContent
            .getPropertyCollector();

    List<ObjectContent> contents = new ArrayList<ObjectContent>();

    RetrieveResult results = vimPort.retrievePropertiesEx(collector,
            filterSpecs, retrieveOptions);
    if (results != null && results.getObjects() != null
            && !results.getObjects().isEmpty()) {
        contents.addAll(results.getObjects());
    }
    String token = null;
    if (results != null && results.getToken() != null) {
        token = results.getToken();
    }
    while (token != null && token.length() > 0) {
        results = vimPort.continueRetrievePropertiesEx(collector, token);
        token = null;
        if (results != null) {
            token = results.getToken();
            if (results.getObjects() != null
                    && !results.getObjects().isEmpty()) {
                contents.addAll(results.getObjects());
            }
        }
    }

    return contents;
}
项目:GraphiteReceiver    文件:Utils.java   
private static RetrieveResult getRetrieveResult(String clusterName, VimConnection connection, ManagedObjectReference rootFolder) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    List<String> clusterList = new ArrayList<String>();
    clusterList.add("ComputeResource");
    clusterList.add("HostSystem");
    clusterList.add("VirtualMachine");

    ManagedObjectReference rootFolderAux = (clusterName == null)? connection.getRootFolder():rootFolder;
    ManagedObjectReference viewManager = connection.getVimPort().createContainerView(connection.getViewManager(), rootFolderAux, clusterList, true);

    if(viewManager == null) {
        logger.debug("cViewRef is null: " + clusterName);
        return null;
    }
    logger.debug("cViewRef is not null: " + clusterName);

    ObjectSpec objectSpec = new ObjectSpec();
    objectSpec.setObj(viewManager);
    objectSpec.setSkip(true);
    objectSpec.getSelectSet().add(getTraversalSpec(clusterName));

    PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpec();
    propertyFilterSpec.getObjectSet().add(objectSpec);

    if(clusterName == null){
        propertyFilterSpec.getPropSet().add(getPropertySpec("ComputeResource"));
    }else{
        propertyFilterSpec.getPropSet().add(getPropertySpec("HostSystem"));
        propertyFilterSpec.getPropSet().add(getPropertySpec("VirtualMachine"));
    }
    List<PropertyFilterSpec> propertyFilterSpecs = new LinkedList<PropertyFilterSpec>();
    propertyFilterSpecs.add(propertyFilterSpec);
    return connection.getVimPort().retrievePropertiesEx(connection.getPropertyCollector(), propertyFilterSpecs, new RetrieveOptions());
}
项目:cs-actions    文件:GetObjectProperties.java   
/**
 * Uses the new RetrievePropertiesEx method to emulate the now deprecated
 * RetrieveProperties method
 *
 * @param propertyFilterSpecList
 * @return list of object content
 * @throws Exception
 */
private static List<ObjectContent> retrievePropertiesAllObjects(ConnectionResources connectionResources,
                                                               List<PropertyFilterSpec> propertyFilterSpecList)
        throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {

    VimPortType vimPort = connectionResources.getVimPortType();
    ManagedObjectReference serviceInstance = connectionResources.getServiceInstance();
    ServiceContent serviceContent = vimPort.retrieveServiceContent(serviceInstance);
    ManagedObjectReference propertyCollectorReference = serviceContent.getPropertyCollector();
    RetrieveOptions propertyObjectRetrieveOptions = new RetrieveOptions();
    List<ObjectContent> objectContentList = new ArrayList<>();

    RetrieveResult results = vimPort.retrievePropertiesEx(propertyCollectorReference,
            propertyFilterSpecList,
            propertyObjectRetrieveOptions);

    if (results != null && results.getObjects() != null && !results.getObjects().isEmpty()) {
        objectContentList.addAll(results.getObjects());
    }

    String token = null;
    if (results != null && results.getToken() != null) {
        token = results.getToken();
    }

    while (token != null && !token.isEmpty()) {
        results = vimPort.continueRetrievePropertiesEx(propertyCollectorReference, token);
        token = null;
        if (results != null) {
            token = results.getToken();
            if (results.getObjects() != null && !results.getObjects().isEmpty()) {
                objectContentList.addAll(results.getObjects());
            }
        }
    }

    return objectContentList;
}
项目:cs-actions    文件:MoRefHandler.java   
public ManagedObjectReference findManagedObjectReferenceByTypeAndId(final ManagedObjectReference folder,
                                                                    final String morefType,
                                                                    final RetrieveOptions retrieveOptions, final String id) throws Exception {
    final PropertyFilterSpec[] propertyFilterSpecs = propertyFilterSpecs(folder, morefType);
    final ManagedObjectReference searchedReference = findComponentReference(propertyFilterSpecs, retrieveOptions, id);
    if (searchedReference != null) {
        return searchedReference;
    }
    throw new RuntimeException(String.format(REFERENCE_TYPE_WITH_ID_NOT_FOUND, morefType, id));
}
项目:cs-actions    文件:MoRefHandler.java   
/**
 * Initialize the helper object on the current connection at invocation time. Do not initialize on construction
 * since the connection may not be ready yet.
 */

private RetrieveResult containerViewByType(final ManagedObjectReference container,
                                           final String morefType,
                                           final RetrieveOptions retrieveOptions
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    return this.containerViewByType(container, morefType, retrieveOptions, ManagedObjectType.NAME.getValue());
}
项目:cs-actions    文件:MoRefHandler.java   
private ManagedObjectReference findComponentReference(final PropertyFilterSpec[] propertyFilterSpecs,
                                                      final RetrieveOptions retrieveOptions, final String id) throws Exception {
    String token = null;
    ManagedObjectReference searched;
    do {
        final RetrieveResult retrieveResult = retrievePropertiesEx(Arrays.asList(propertyFilterSpecs), retrieveOptions, token);
        token = retrieveResult.getToken();
        searched = getFromRetrieveResult(retrieveResult, id);
    } while (searched == null && StringUtilities.isNotEmpty(token));
    return searched;
}
项目:cs-actions    文件:MoRefHandler.java   
private RetrieveResult retrievePropertiesEx(final List<PropertyFilterSpec> propertyFilterSpecs, final RetrieveOptions retrieveOptions,
                                            final String token) throws Exception {
    if (isEmpty(token)) {
        return vimPort.retrievePropertiesEx(serviceContent.getPropertyCollector(), propertyFilterSpecs, retrieveOptions);
    }
    return vimPort.continueRetrievePropertiesEx(serviceContent.getPropertyCollector(), token);
}
项目:photon-model    文件:GetMoRef.java   
/**
 * Get the MOR of the Virtual Machine by its name.
 *
 * @param vmName           The name of the Virtual Machine
 * @param propCollectorRef
 * @return The Managed Object reference for this VM
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 */
public ManagedObjectReference vmByVMname(
        final String vmName, final ManagedObjectReference propCollectorRef
) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {

    init();

    ManagedObjectReference rootFolder = this.serviceContent.getRootFolder();
    TraversalSpec tSpec = getVMTraversalSpec();
    // Create Property Spec
    PropertySpec propertySpec = new PropertySpecBuilder()
            .all(Boolean.FALSE)
            .pathSet("name")
            .type("VirtualMachine");

    // Now create Object Spec
    ObjectSpec objectSpec = new ObjectSpecBuilder()
            .obj(rootFolder)
            .skip(Boolean.TRUE)
            .selectSet(tSpec);

    // Create PropertyFilterSpec using the PropertySpec and ObjectPec
    // created above.
    PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpecBuilder()
            .propSet(propertySpec)
            .objectSet(objectSpec);

    List<PropertyFilterSpec> listpfs =
            new ArrayList<PropertyFilterSpec>(1);
    listpfs.add(propertyFilterSpec);
    RetrieveOptions options = new RetrieveOptions();
    // Query returns a fixed number of results
    // if token is returned we can get more results
    RetrieveResult retrieveResult =
            this.vimPort.retrievePropertiesEx(propCollectorRef, listpfs, options);
    String token = null;

    do {
        token = (retrieveResult != null) ? retrieveResult.getToken() : null;
        List<ObjectContent> listobcont =
                (retrieveResult != null) ?
                        retrieveResult.getObjects() : null;

        if (listobcont != null) {
            for (ObjectContent oc : listobcont) {
                ManagedObjectReference mr = oc.getObj();
                String vmnm = null;
                List<DynamicProperty> dps = oc.getPropSet();
                if (dps != null) {
                    for (DynamicProperty dp : dps) {
                        vmnm = (String) dp.getVal();
                        if (vmName.equals(vmnm)) {
                            return mr;
                        }
                    }
                }
            }
        }
        if (token != null) {
            retrieveResult = this.vimPort.continueRetrievePropertiesEx(propCollectorRef, token);
        }
    } while (token != null);

    return null;
}
项目:photon-model    文件:GetMoRef.java   
/**
 * Method to retrieve properties of list of {@link ManagedObjectReference}
 *
 * @param entityMors List of {@link ManagedObjectReference} for which the properties
 *                   needs to be retrieved
 * @param props      Common properties that need to be retrieved for all the
 *                   {@link ManagedObjectReference} passed
 * @return Map of {@link ManagedObjectReference} and their corresponding name
 *         value pair of properties
 * @throws InvalidPropertyFaultMsg
 * @throws RuntimeFaultFaultMsg
 */
public Map<ManagedObjectReference, Map<String, Object>> entityProps(
        List<ManagedObjectReference> entityMors, String[] props)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    init();

    Map<ManagedObjectReference, Map<String, Object>> retVal =
            new HashMap<ManagedObjectReference, Map<String, Object>>();
    // Create PropertyFilterSpec
    PropertyFilterSpecBuilder propertyFilterSpec = new PropertyFilterSpecBuilder();
    Map<String, String> typesCovered = new HashMap<String, String>();

    for (ManagedObjectReference mor : entityMors) {
        if (!typesCovered.containsKey(mor.getType())) {
            // Create & add new property Spec
            propertyFilterSpec.propSet(
                    new PropertySpecBuilder()
                            .all(Boolean.FALSE)
                            .type(mor.getType())
                            .pathSet(props)
            );
            typesCovered.put(mor.getType(), "");
        }
        // Now create & add Object Spec
        propertyFilterSpec.objectSet(
                new ObjectSpecBuilder().obj(mor)
        );
    }
    List<PropertyFilterSpec> propertyFilterSpecs =
            new ArrayList<PropertyFilterSpec>();
    propertyFilterSpecs.add(propertyFilterSpec);

    RetrieveResult rslts =
            this.vimPort.retrievePropertiesEx(this.serviceContent.getPropertyCollector(),
                    propertyFilterSpecs, new RetrieveOptions());

    List<ObjectContent> listobjcontent = new ArrayList<ObjectContent>();
    String token = populate(rslts, listobjcontent);
    while (token != null && !token.isEmpty()) {
        rslts =
                this.vimPort.continueRetrievePropertiesEx(
                        this.serviceContent.getPropertyCollector(), token);

        token = populate(rslts, listobjcontent);
    }

    for (ObjectContent oc : listobjcontent) {
        List<DynamicProperty> dps = oc.getPropSet();
        Map<String, Object> propMap = new HashMap<String, Object>();
        if (dps != null) {
            for (DynamicProperty dp : dps) {
                propMap.put(dp.getName(), dp.getVal());
            }
        }
        retVal.put(oc.getObj(), propMap);
    }
    return retVal;
}
项目:photon-model    文件:GetMoRef.java   
public Map<String, ManagedObjectReference> inContainerByType(ManagedObjectReference container,
        String morefType) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    return inContainerByType(container, morefType, new RetrieveOptions());
}
项目:photon-model    文件:GetMoRef.java   
public Map<String, ManagedObjectReference> inFolderByType(ManagedObjectReference folder,
        String morefType) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    return inFolderByType(folder, morefType, new RetrieveOptions());
}
项目:photon-model    文件:GetMoRef.java   
public Map<ManagedObjectReference, Map<String, Object>> inContainerByType(
        ManagedObjectReference container, String morefType, String[] strings)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    return inContainerByType(container, morefType, strings, new RetrieveOptions());
}
项目:vijava    文件:PropertyCollector.java   
/** @since SDK4.1 */
public RetrieveResult retrievePropertiesEx(PropertyFilterSpec[] specSet, RetrieveOptions options) throws InvalidProperty, RuntimeFault, RemoteException
{
  return getVimService().retrievePropertiesEx(getMOR(), specSet, options);
}
项目:cs-actions    文件:MorObjectHandler.java   
public ManagedObjectReference getMorById(final ConnectionResources connectionResources, final String filter, final String id) throws Exception {
    final ManagedObjectReference reference = connectionResources.getMorRootFolder();
    final RetrieveOptions retrieveOptions = new RetrieveOptions();
    return connectionResources.getMoRefHandler().findManagedObjectReferenceByTypeAndId(reference, filter, retrieveOptions, id);
}
项目:cs-actions    文件:MorObjectHandler.java   
public ManagedObjectReference getSpecificMor(ConnectionResources connectionResources, ManagedObjectReference reference,
                                             String filter, String parameter) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    return connectionResources.getMoRefHandler().inContainerByType(reference, filter, new RetrieveOptions()).get(parameter);
}
项目:cs-actions    文件:MoRefHandler.java   
public Map<String, ManagedObjectReference> inContainerByType(ManagedObjectReference container,
                                                             String morefType)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    return inContainerByType(container, morefType, new RetrieveOptions());
}
项目:cs-actions    文件:MoRefHandler.java   
private RetrieveResult containerViewByType(final RetrieveOptions retrieveOptions,
                                           final PropertyFilterSpec... propertyFilterSpecs)
        throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    return vimPort.retrievePropertiesEx(serviceContent.getPropertyCollector(), Arrays.asList(propertyFilterSpecs),
            retrieveOptions);
}
项目:cloudstack    文件:VMwareUtil.java   
public static Map<String, Object> getEntityProps(VMwareConnection connection, ManagedObjectReference entityMor, String[] props)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    Map<String, Object> retVal = new HashMap<>();

    PropertySpec propertySpec = new PropertySpec();

    propertySpec.setAll(Boolean.FALSE);
    propertySpec.setType(entityMor.getType());
    propertySpec.getPathSet().addAll(Arrays.asList(props));

    ObjectSpec objectSpec = new ObjectSpec();

    objectSpec.setObj(entityMor);

    // Create PropertyFilterSpec using the PropertySpec and ObjectPec created above.
    PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpec();

    propertyFilterSpec.getPropSet().add(propertySpec);
    propertyFilterSpec.getObjectSet().add(objectSpec);

    List<PropertyFilterSpec> propertyFilterSpecs = new ArrayList<>();

    propertyFilterSpecs.add(propertyFilterSpec);

    RetrieveResult rslts = connection.getVimPortType().retrievePropertiesEx(connection.getServiceContent().getPropertyCollector(),
            propertyFilterSpecs, new RetrieveOptions());
    List<ObjectContent> listobjcontent = new ArrayList<>();

    if (rslts != null && rslts.getObjects() != null && !rslts.getObjects().isEmpty()) {
        listobjcontent.addAll(rslts.getObjects());
    }

    String token = null;

    if (rslts != null && rslts.getToken() != null) {
        token = rslts.getToken();
    }

    while (token != null && !token.isEmpty()) {
        rslts = connection.getVimPortType().continueRetrievePropertiesEx(connection.getServiceContent().getPropertyCollector(),
                token);

        token = null;

        if (rslts != null) {
            token = rslts.getToken();

            if (rslts.getObjects() != null && !rslts.getObjects().isEmpty()) {
                listobjcontent.addAll(rslts.getObjects());
            }
        }
    }

    for (ObjectContent oc : listobjcontent) {
        List<DynamicProperty> dps = oc.getPropSet();

        if (dps != null) {
            for (DynamicProperty dp : dps) {
                retVal.put(dp.getName(), dp.getVal());
            }
        }
    }

    return retVal;
}
项目:photon-model    文件:GetMoRef.java   
/**
 * Returns all the MOREFs of the specified type that are present under the
 * container
 *
 * @param folder    {@link ManagedObjectReference} of the container to begin the
 *                  search from
 * @param morefType Type of the managed entity that needs to be searched
 * @return Map of name and MOREF of the managed objects present. If none
 *         exist then empty Map is returned
 * @throws InvalidPropertyFaultMsg
 * @throws RuntimeFaultFaultMsg
 */
public Map<String, ManagedObjectReference> inContainerByType(
        ManagedObjectReference folder, String morefType, RetrieveOptions retrieveOptions)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {

    init();
    RetrieveResult rslts = containerViewByType(folder, morefType, retrieveOptions);
    return toMap(rslts);
}
项目:cs-actions    文件:MoRefHandler.java   
/**
 * Returns all the MOREFs of the specified type that are present under the
 * container
 *
 * @param folder    {@link ManagedObjectReference} of the container to begin the
 *                  search from
 * @param morefType Type of the managed entity that needs to be searched
 * @return Map of name and MOREF of the managed objects present. If none
 *         exist then empty Map is returned
 * @throws InvalidPropertyFaultMsg
 * @throws RuntimeFaultFaultMsg
 */
public Map<String, ManagedObjectReference> inContainerByType(ManagedObjectReference folder,
                                                             String morefType,
                                                             RetrieveOptions retrieveOptions)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    RetrieveResult results = containerViewByType(folder, morefType, retrieveOptions);

    return toMap(results);
}
项目:cs-actions    文件:MoRefHandler.java   
/**
 * Returns the raw RetrieveResult object for the provided container filtered on properties list
 *
 * @param container       - container to look in
 * @param morefType       - type to filter for
 * @param morefProperties - properties to include
 * @return com.vmware.vim25.RetrieveResult for this query
 * @throws RuntimeFaultFaultMsg
 * @throws InvalidPropertyFaultMsg
 */
private RetrieveResult containerViewByType(final ManagedObjectReference container,
                                           final String morefType,
                                           final RetrieveOptions retrieveOptions,
                                           final String... morefProperties
) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    PropertyFilterSpec[] propertyFilterSpecs = propertyFilterSpecs(container, morefType, morefProperties);

    return containerViewByType(retrieveOptions, propertyFilterSpecs);
}