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

项目:photon-model    文件:Finder.java   
private List<ObjectContent> ancestrySet(ManagedObjectReference ref)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    ObjectSpec ospec = new ObjectSpec();
    ospec.setObj(ref);
    ospec.setSkip(false);

    TraversalSpec tspec = new TraversalSpec();
    tspec.setSkip(false);
    tspec.setPath("parent");
    tspec.setType("ManagedEntity");
    tspec.setName("traverseParent");

    SelectionSpec selSpec = new SelectionSpec();
    selSpec.setName("traverseParent");

    tspec.getSelectSet().add(selSpec);

    ospec.getSelectSet().add(tspec);

    PropertySpec pspec = new PropertySpec();
    pspec.setType("ManagedEntity");
    pspec.getPathSet().add("name");
    pspec.getPathSet().add("parent");

    PropertyFilterSpec filter = new PropertyFilterSpec();
    filter.getObjectSet().add(ospec);
    filter.getPropSet().add(pspec);

    return this.connection.getVimPort()
            .retrieveProperties(this.connection.getServiceContent().getPropertyCollector(),
                    Collections.singletonList(filter));

}
项目:vsphere-automation-sdk-java    文件:VimUtil.java   
/**
 * @return An array of SelectionSpec covering Datacenter to DatastoreFolder.
 */
private static SelectionSpec[] buildTraversal() {

    // For Folder -> Folder recursion
    SelectionSpec sspecvfolders = new SelectionSpec();
    sspecvfolders.setName("VisitFolders");

    TraversalSpec dcToDf = new TraversalSpec();
    dcToDf.setType("Datacenter");
    dcToDf.setSkip(Boolean.FALSE);
    dcToDf.setPath("datastoreFolder");
    dcToDf.setName("dcToDf");
    dcToDf.getSelectSet().add(sspecvfolders);

    // DC -> DS
    TraversalSpec dcToDs = new TraversalSpec();
    dcToDs.setType("Datacenter");
    dcToDs.setPath("datastore");
    dcToDs.setName("dcToDs");
    dcToDs.setSkip(Boolean.FALSE);

    TraversalSpec visitFolders = new TraversalSpec();
    visitFolders.setType("Folder");
    visitFolders.setPath("childEntity");
    visitFolders.setSkip(Boolean.FALSE);
    visitFolders.setName("VisitFolders");

    List<SelectionSpec> sspecarrvf = new ArrayList<SelectionSpec>();
    sspecarrvf.add(dcToDs);
    sspecarrvf.add(dcToDf);
    sspecarrvf.add(sspecvfolders);

    visitFolders.getSelectSet().addAll(sspecarrvf);
    return new SelectionSpec[] { visitFolders };
}
项目:contrail-vcenter-plugin    文件:VCenterNotify.java   
private PropertyFilterSpec createEventFilterSpec(EventHistoryCollector collector)
        throws Exception
{
    // Set up a PropertySpec to use the latestPage attribute
    // of the EventHistoryCollector
    PropertySpec propSpec = new PropertySpec();
    propSpec.setAll(new Boolean(false));
    propSpec.setPathSet(new String[] { "latestPage" });
    propSpec.setType(collector.getMOR().getType());

    // PropertySpecs are wrapped in a PropertySpec array
    PropertySpec[] propSpecAry = new PropertySpec[] { propSpec };

    // Set up an ObjectSpec with the above PropertySpec for the
    // EventHistoryCollector we just created
    // as the Root or Starting Object to get Attributes for.
    ObjectSpec objSpec = new ObjectSpec();
    objSpec.setObj(collector.getMOR());
    objSpec.setSkip(new Boolean(false));

    // Get Event objects in "latestPage" from "EventHistoryCollector"
    // and no "traversal" further, so, no SelectionSpec is specified
    objSpec.setSelectSet(new SelectionSpec[] {});

    // ObjectSpecs are wrapped in an ObjectSpec array
    ObjectSpec[] objSpecAry = new ObjectSpec[] { objSpec };

    PropertyFilterSpec spec = new PropertyFilterSpec();
    spec.setPropSet(propSpecAry);
    spec.setObjectSet(objSpecAry);
    return spec;
}
项目:vijava    文件:VMEventsMonitor.java   
private PropertyFilterSpec createEventFilterSpec()
{
    // Set up a PropertySpec to use the latestPage attribute
    // of the EventHistoryCollector

    PropertySpec propSpec = new PropertySpec();
    propSpec.setAll(new Boolean(false));
    propSpec.setPathSet(new String[] { "latestPage" });
    propSpec.setType(_eventHistoryCollector.getMOR().getType());

    // PropertySpecs are wrapped in a PropertySpec array
    PropertySpec[] propSpecAry = new PropertySpec[] { propSpec };

    // Set up an ObjectSpec with the above PropertySpec for the
    // EventHistoryCollector we just created
    // as the Root or Starting Object to get Attributes for.
    ObjectSpec objSpec = new ObjectSpec();
    objSpec.setObj(_eventHistoryCollector.getMOR());
    objSpec.setSkip(new Boolean(false));

    // Get Event objects in "latestPage" from "EventHistoryCollector"
    // and no "traversl" further, so, no SelectionSpec is specified
    objSpec.setSelectSet(new SelectionSpec[] {});

    // ObjectSpecs are wrapped in an ObjectSpec array
    ObjectSpec[] objSpecAry = new ObjectSpec[] { objSpec };

    PropertyFilterSpec spec = new PropertyFilterSpec();
    spec.setPropSet(propSpecAry);
    spec.setObjectSet(objSpecAry);
    return spec;
}
项目:cloudstack    文件:DatacenterMO.java   
public List<ObjectContent> getHostPropertiesOnDatacenterHostFolder(String[] propertyPaths) throws Exception {
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("HostSystem");
    pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));

    TraversalSpec computeResource2HostTraversal = new TraversalSpec();
    computeResource2HostTraversal.setType("ComputeResource");
    computeResource2HostTraversal.setPath("host");
    computeResource2HostTraversal.setName("computeResource2HostTraversal");

    SelectionSpec recurseFolders = new SelectionSpec();
    recurseFolders.setName("folder2childEntity");

    TraversalSpec folder2childEntity = new TraversalSpec();
    folder2childEntity.setType("Folder");
    folder2childEntity.setPath("childEntity");
    folder2childEntity.setName(recurseFolders.getName());
    folder2childEntity.getSelectSet().add(recurseFolders);
    folder2childEntity.getSelectSet().add(computeResource2HostTraversal);

    TraversalSpec dc2HostFolderTraversal = new TraversalSpec();
    dc2HostFolderTraversal.setType("Datacenter");
    dc2HostFolderTraversal.setPath("hostFolder");
    dc2HostFolderTraversal.setName("dc2HostFolderTraversal");
    dc2HostFolderTraversal.getSelectSet().add(folder2childEntity);

    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(_mor);
    oSpec.setSkip(Boolean.TRUE);
    oSpec.getSelectSet().add(dc2HostFolderTraversal);

    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.getPropSet().add(pSpec);
    pfSpec.getObjectSet().add(oSpec);
    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
    pfSpecArr.add(pfSpec);

    return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);

}
项目:cloudstack    文件:DatacenterMO.java   
public List<ObjectContent> getVmPropertiesOnDatacenterVmFolder(String[] propertyPaths) throws Exception {
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("VirtualMachine");
    pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));

    TraversalSpec dc2VmFolderTraversal = new TraversalSpec();
    dc2VmFolderTraversal.setType("Datacenter");
    dc2VmFolderTraversal.setPath("vmFolder");
    dc2VmFolderTraversal.setName("dc2VmFolderTraversal");

    SelectionSpec recurseFolders = new SelectionSpec();
    recurseFolders.setName("folder2childEntity");

    TraversalSpec folder2childEntity = new TraversalSpec();
    folder2childEntity.setType("Folder");
    folder2childEntity.setPath("childEntity");
    folder2childEntity.setName(recurseFolders.getName());
    folder2childEntity.getSelectSet().add(recurseFolders);
    dc2VmFolderTraversal.getSelectSet().add(folder2childEntity);

    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(_mor);
    oSpec.setSkip(Boolean.TRUE);
    oSpec.getSelectSet().add(dc2VmFolderTraversal);

    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.getPropSet().add(pSpec);
    pfSpec.getObjectSet().add(oSpec);
    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
    pfSpecArr.add(pfSpec);

    return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
}
项目:cloudstack    文件:DatacenterMO.java   
public static Pair<DatacenterMO, String> getOwnerDatacenter(VmwareContext context, ManagedObjectReference morEntity) throws Exception {

        PropertySpec pSpec = new PropertySpec();
        pSpec.setType("Datacenter");
        pSpec.getPathSet().add("name");

        TraversalSpec entityParentTraversal = new TraversalSpec();
        entityParentTraversal.setType("ManagedEntity");
        entityParentTraversal.setPath("parent");
        entityParentTraversal.setName("entityParentTraversal");
        SelectionSpec selSpec = new SelectionSpec();
        selSpec.setName("entityParentTraversal");
        entityParentTraversal.getSelectSet().add(selSpec);

        ObjectSpec oSpec = new ObjectSpec();
        oSpec.setObj(morEntity);
        oSpec.setSkip(Boolean.TRUE);
        oSpec.getSelectSet().add(entityParentTraversal);

        PropertyFilterSpec pfSpec = new PropertyFilterSpec();
        pfSpec.getPropSet().add(pSpec);
        pfSpec.getObjectSet().add(oSpec);
        List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
        pfSpecArr.add(pfSpec);

        List<ObjectContent> ocs = context.getService().retrieveProperties(context.getPropertyCollector(), pfSpecArr);

        assert (ocs != null && ocs.size() > 0);
        assert (ocs.get(0).getObj() != null);
        assert (ocs.get(0).getPropSet().get(0) != null);
        assert (ocs.get(0).getPropSet().get(0).getVal() != null);

        String dcName = ocs.get(0).getPropSet().get(0).getVal().toString();
        return new Pair<DatacenterMO, String>(new DatacenterMO(context, ocs.get(0).getObj()), dcName);
    }
项目:photon-model    文件:EnumerationClient.java   
private SelectionSpec getSelectionSpec(String name) {
    SelectionSpec genericSpec = new SelectionSpec();
    genericSpec.setName(name);
    return genericSpec;
}
项目:photon-model    文件:DatacenterLister.java   
public List<Element> listAllDatacenters() throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    PropertyFilterSpec spec = new PropertyFilterSpec();

    ObjectSpec ospec = new ObjectSpec();
    ospec.setObj(connection.getServiceContent().getRootFolder());
    ospec.setSkip(false);
    spec.getObjectSet().add(ospec);

    TraversalSpec traverseFolders = new TraversalSpec();
    traverseFolders.setPath("childEntity");
    traverseFolders.setSkip(false);
    String traversalName = "folder2child";
    traverseFolders.setName(traversalName);
    traverseFolders.setType(VimNames.TYPE_FOLDER);

    SelectionSpec selSpec = new SelectionSpec();
    selSpec.setName(traversalName);
    traverseFolders.getSelectSet().add(selSpec);

    ospec.getSelectSet().add(traverseFolders);

    for (String t : new String[] { VimNames.TYPE_FOLDER, VimNames.TYPE_DATACENTER }) {
        PropertySpec pspec = new PropertySpec();
        pspec.setType(t);
        pspec.getPathSet().add(VimNames.PROPERTY_NAME);
        pspec.getPathSet().add(VimNames.PROPERTY_PARENT);

        spec.getPropSet().add(pspec);
    }

    List<ObjectContent> ocs = retrieveProperties(spec);
    List<Element> res = new ArrayList<>();

    for (ObjectContent oc : ocs) {
        if (oc.getObj().getType().equals(VimNames.TYPE_FOLDER)) {
            continue;
        }

        String parentPath = buildPathToParent(prop(oc, VimNames.PROPERTY_PARENT), ocs);
        res.add(Element.make(oc.getObj(), parentPath + "/" + prop(oc, VimNames.PROPERTY_NAME)));
    }

    return res;
}
项目:photon-model    文件:GetMoRef.java   
/**
 * @return TraversalSpec specification to get to the VirtualMachine managed
 *         object.
 */
public TraversalSpec getVMTraversalSpec() {
    // Create a traversal spec that starts from the 'root' objects
    // and traverses the inventory tree to get to the VirtualMachines.
    // Build the traversal specs bottoms up

    //Traversal to get to the VM in a VApp
    TraversalSpec vAppToVM = new TraversalSpecBuilder()
            .name("vAppToVM")
            .type("VirtualApp")
            .path("vm");

    //Traversal spec for VApp to VApp
    TraversalSpec vAppToVApp = new TraversalSpecBuilder()
            .name("vAppToVApp")
            .type("VirtualApp")
            .path("resourcePool")
            .selectSet(
                    //SelectionSpec for both VApp to VApp and VApp to VM
                    new SelectionSpecBuilder().name("vAppToVApp"),
                    new SelectionSpecBuilder().name("vAppToVM")
            );

    //This SelectionSpec is used for recursion for Folder recursion
    SelectionSpec visitFolders = new SelectionSpecBuilder().name("VisitFolders");

    // Traversal to get to the vmFolder from DataCenter
    TraversalSpec dataCenterToVMFolder = new TraversalSpecBuilder()
            .name("DataCenterToVMFolder")
            .type("Datacenter")
            .path("vmFolder")
            .skip(false)
            .selectSet(visitFolders);

    // TraversalSpec to get to the DataCenter from rootFolder
    return new TraversalSpecBuilder()
            .name("VisitFolders")
            .type("Folder")
            .path("childEntity")
            .skip(false)
            .selectSet(
                    visitFolders,
                    dataCenterToVMFolder,
                    vAppToVM,
                    vAppToVApp
            );
}
项目:photon-model    文件:TraversalSpecBuilder.java   
private void init() {
    if (this.selectSet == null) {
        this.selectSet = new ArrayList<SelectionSpec>();
    }
}
项目:photon-model    文件:TraversalSpecBuilder.java   
public TraversalSpecBuilder selectSet(final SelectionSpec... selectionSpecs) {
    init();
    this.selectSet.addAll(Arrays.asList(selectionSpecs));
    return this;
}
项目:photon-model    文件:ObjectSpecBuilder.java   
private void init() {
    if (this.selectSet == null) {
        this.selectSet = new ArrayList<SelectionSpec>();
    }
}
项目:photon-model    文件:ObjectSpecBuilder.java   
public ObjectSpecBuilder selectSet(final SelectionSpec... selectionSpecs) {
    init();
    this.selectSet.addAll(Arrays.asList(selectionSpecs));
    return this;
}
项目:vsphere-automation-sdk-java    文件:VimUtil.java   
/**
 * Retrieves the list of hosts of the given cluster.
 *
 * @param vimPort
 *            vimPort
 * @param serviceContent
 *            serviceContent
 * @param cluster
 *            cluster
 * @return the list of hosts of the clusters
 * @throws InvalidPropertyFaultMsg
 * @throws RuntimeFaultFaultMsg
 */
public static List<ManagedObjectReference> getHosts(VimPortType vimPort,
        ServiceContent serviceContent, ManagedObjectReference cluster)
        throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    PropertySpec hostPropSpec = new PropertySpec();
    hostPropSpec.setType("HostSystem");
    hostPropSpec.setAll(false);
    hostPropSpec.getPathSet().addAll(Collections.<String>emptyList());

    TraversalSpec hostTSpec = new TraversalSpec();
    hostTSpec.setType("ComputeResource");
    hostTSpec.setPath("host");
    hostTSpec.setName("hosts");

    final SelectionSpec selectionSpec = new SelectionSpec();
    selectionSpec.setName(hostTSpec.getName());

    hostTSpec.getSelectSet().add(selectionSpec);

    List<ObjectSpec> ospecList = new ArrayList<>();
    ObjectSpec ospec = new ObjectSpec();
    ospec.setObj(cluster);
    ospec.setSkip(true);
    ospec.getSelectSet().addAll(Arrays.asList(hostTSpec));
    ospecList.add(ospec);

    PropertyFilterSpec propertyFilterSpec = new PropertyFilterSpec();
    propertyFilterSpec.getPropSet().addAll(Arrays.asList(hostPropSpec));
    propertyFilterSpec.getObjectSet().addAll(ospecList);

    List<PropertyFilterSpec> listpfs = new ArrayList<>(1);
    listpfs.add(propertyFilterSpec);
    List<ObjectContent> listObjContent = VimUtil
            .retrievePropertiesAllObjects(vimPort,
                    serviceContent.getPropertyCollector(), listpfs);

    List<ManagedObjectReference> hosts = new ArrayList<>();

    if (listObjContent != null) {
        for (ObjectContent oc : listObjContent) {
            hosts.add(oc.getObj());
        }
    }
    return hosts;
}
项目:vsphere-automation-sdk-java    文件:VimUtil.java   
/**
 * Gets the VM TraversalSpec.
 *
 * @return the VM TraversalSpec
 */
private static TraversalSpec getVMTraversalSpec() {
    TraversalSpec vAppToVM = new TraversalSpec();
    vAppToVM.setName("vAppToVM");
    vAppToVM.setType("VirtualApp");
    vAppToVM.setPath("vm");

    TraversalSpec vAppToVApp = new TraversalSpec();
    vAppToVApp.setName("vAppToVApp");
    vAppToVApp.setType("VirtualApp");
    vAppToVApp.setPath("resourcePool");

    SelectionSpec vAppRecursion = new SelectionSpec();
    vAppRecursion.setName("vAppToVApp");

    SelectionSpec vmInVApp = new SelectionSpec();
    vmInVApp.setName("vAppToVM");

    List<SelectionSpec> vAppToVMSS = new ArrayList<SelectionSpec>();
    vAppToVMSS.add(vAppRecursion);
    vAppToVMSS.add(vmInVApp);
    vAppToVApp.getSelectSet().addAll(vAppToVMSS);

    SelectionSpec sSpec = new SelectionSpec();
    sSpec.setName("VisitFolders");

    TraversalSpec dataCenterToVMFolder = new TraversalSpec();
    dataCenterToVMFolder.setName("DataCenterToVMFolder");
    dataCenterToVMFolder.setType("Datacenter");
    dataCenterToVMFolder.setPath("vmFolder");
    dataCenterToVMFolder.setSkip(false);
    dataCenterToVMFolder.getSelectSet().add(sSpec);

    TraversalSpec traversalSpec = new TraversalSpec();
    traversalSpec.setName("VisitFolders");
    traversalSpec.setType("Folder");
    traversalSpec.setPath("childEntity");
    traversalSpec.setSkip(false);
    List<SelectionSpec> sSpecArr = new ArrayList<SelectionSpec>();
    sSpecArr.add(sSpec);
    sSpecArr.add(dataCenterToVMFolder);
    sSpecArr.add(vAppToVM);
    sSpecArr.add(vAppToVApp);
    traversalSpec.getSelectSet().addAll(sSpecArr);
    return traversalSpec;
}
项目:vsphere-ws    文件:TraversalSpecBuilder.java   
private void init() {
    if (selectSet == null) {
        selectSet = new ArrayList<SelectionSpec>();
    }
}
项目:vsphere-ws    文件:TraversalSpecBuilder.java   
public TraversalSpecBuilder selectSet(final SelectionSpec... selectionSpecs) {
    init();
    this.selectSet.addAll(Arrays.asList(selectionSpecs));
    return this;
}
项目:vsphere-ws    文件:ObjectSpecBuilder.java   
private void init() {
    if (selectSet == null) {
        selectSet = new ArrayList<SelectionSpec>();
    }
}
项目:vsphere-ws    文件:ObjectSpecBuilder.java   
public ObjectSpecBuilder selectSet(final SelectionSpec... selectionSpecs) {
    init();
    this.selectSet.addAll(Arrays.asList(selectionSpecs));
    return this;
}
项目:vsphere-ws    文件:TraversalSpecBuilder.java   
private void init() {
    if (selectSet == null) {
        selectSet = new ArrayList<SelectionSpec>();
    }
}
项目:vsphere-ws    文件:TraversalSpecBuilder.java   
public TraversalSpecBuilder selectSet(final SelectionSpec... selectionSpecs) {
    init();
    this.selectSet.addAll(Arrays.asList(selectionSpecs));
    return this;
}
项目:vsphere-ws    文件:ObjectSpecBuilder.java   
private void init() {
    if (selectSet == null) {
        selectSet = new ArrayList<SelectionSpec>();
    }
}
项目:vsphere-ws    文件:ObjectSpecBuilder.java   
public ObjectSpecBuilder selectSet(final SelectionSpec... selectionSpecs) {
    init();
    this.selectSet.addAll(Arrays.asList(selectionSpecs));
    return this;
}
项目:cs-actions    文件:ObjectSpecBuilder.java   
public ObjectSpecBuilder selectSet(final SelectionSpec... selectionSpecs) {
    init();
    this.selectSet.addAll(Arrays.asList(selectionSpecs));
    return this;
}
项目:cloudstack    文件:DatastoreMO.java   
public Pair<DatacenterMO, String> getOwnerDatacenter() throws Exception {
    if (_ownerDc != null)
        return _ownerDc;

    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("Datacenter");
    pSpec.getPathSet().add("name");

    TraversalSpec folderParentTraversal = new TraversalSpec();
    folderParentTraversal.setType("Folder");
    folderParentTraversal.setPath("parent");
    folderParentTraversal.setName("folderParentTraversal");
    SelectionSpec sSpec = new SelectionSpec();
    sSpec.setName("folderParentTraversal");
    folderParentTraversal.getSelectSet().add(sSpec);

    TraversalSpec dsParentTraversal = new TraversalSpec();
    dsParentTraversal.setType("Datastore");
    dsParentTraversal.setPath("parent");
    dsParentTraversal.setName("dsParentTraversal");
    dsParentTraversal.getSelectSet().add(folderParentTraversal);

    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(getMor());
    oSpec.setSkip(Boolean.TRUE);
    oSpec.getSelectSet().add(dsParentTraversal);

    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.getPropSet().add(pSpec);
    pfSpec.getObjectSet().add(oSpec);
    List<PropertyFilterSpec> pfSpecArr = new ArrayList<>();
    pfSpecArr.add(pfSpec);

    List<ObjectContent> ocs = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);

    assert (ocs != null && ocs.size() > 0);
    assert (ocs.get(0).getObj() != null);
    assert (ocs.get(0).getPropSet() != null);
    String dcName = ocs.get(0).getPropSet().get(0).getVal().toString();
    _ownerDc = new Pair<>(new DatacenterMO(_context, ocs.get(0).getObj()), dcName);
    return _ownerDc;
}
项目:cloudstack    文件:VmwareClient.java   
private SelectionSpec getSelectionSpec(String name) {
    SelectionSpec genericSpec = new SelectionSpec();
    genericSpec.setName(name);
    return genericSpec;
}
项目:cloudstack    文件:VMwareUtil.java   
private static TraversalSpec getVMTraversalSpec() {
    // Create a TraversalSpec that starts from the 'root' objects
    // and traverses the inventory tree to get to the VirtualMachines.
    // Build the traversal specs bottoms up

    // TraversalSpec to get to the VM in a vApp
    TraversalSpec vAppToVM = new TraversalSpec();

    vAppToVM.setName("vAppToVM");
    vAppToVM.setType("VirtualApp");
    vAppToVM.setPath("vm");

    // TraversalSpec for vApp to vApp
    TraversalSpec vAppToVApp = new TraversalSpec();

    vAppToVApp.setName("vAppToVApp");
    vAppToVApp.setType("VirtualApp");
    vAppToVApp.setPath("resourcePool");

    // SelectionSpec for vApp-to-vApp recursion
    SelectionSpec vAppRecursion = new SelectionSpec();

    vAppRecursion.setName("vAppToVApp");

    // SelectionSpec to get to a VM in the vApp
    SelectionSpec vmInVApp = new SelectionSpec();

    vmInVApp.setName("vAppToVM");

    // SelectionSpec for both vApp to vApp and vApp to VM
    List<SelectionSpec> vAppToVMSS = new ArrayList<>();

    vAppToVMSS.add(vAppRecursion);
    vAppToVMSS.add(vmInVApp);

    vAppToVApp.getSelectSet().addAll(vAppToVMSS);

    // This SelectionSpec is used for recursion for Folder recursion
    SelectionSpec sSpec = new SelectionSpec();

    sSpec.setName("VisitFolders");

    // Traversal to get to the vmFolder from DataCenter
    TraversalSpec dataCenterToVMFolder = new TraversalSpec();

    dataCenterToVMFolder.setName("DataCenterToVMFolder");
    dataCenterToVMFolder.setType("Datacenter");
    dataCenterToVMFolder.setPath("vmFolder");
    dataCenterToVMFolder.setSkip(false);

    dataCenterToVMFolder.getSelectSet().add(sSpec);

    // TraversalSpec to get to the DataCenter from rootFolder
    TraversalSpec traversalSpec = new TraversalSpec();

    traversalSpec.setName("VisitFolders");
    traversalSpec.setType("Folder");
    traversalSpec.setPath("childEntity");
    traversalSpec.setSkip(false);

    List<SelectionSpec> sSpecArr = new ArrayList<>();

    sSpecArr.add(sSpec);
    sSpecArr.add(dataCenterToVMFolder);
    sSpecArr.add(vAppToVM);
    sSpecArr.add(vAppToVApp);

    traversalSpec.getSelectSet().addAll(sSpecArr);

    return traversalSpec;
}