Пример #1
0
  /** @return TraversalSpec specification to get to the VirtualMachine managed object. */
  public static 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 vmFolder from DataCenter
    TraversalSpec dataCenterToVMFolder = new TraversalSpec();
    dataCenterToVMFolder.setName("DataCenterToVMFolder");
    dataCenterToVMFolder.setType("Datacenter");
    dataCenterToVMFolder.setPath("vmFolder");
    dataCenterToVMFolder.setSkip(false);
    SelectionSpec sSpec = new SelectionSpec();
    sSpec.setName("VisitFolders");
    SelectionSpec[] sSpecs = new SelectionSpec[] {sSpec};
    dataCenterToVMFolder.setSelectSet(sSpecs);

    // TraversalSpec to get to the DataCenter from rootFolder
    TraversalSpec traversalSpec = new TraversalSpec();
    traversalSpec.setName("VisitFolders");
    traversalSpec.setType("Folder");
    traversalSpec.setPath("childEntity");
    traversalSpec.setSkip(false);
    SelectionSpec[] sSpecArr = new SelectionSpec[] {sSpec, dataCenterToVMFolder};
    traversalSpec.setSelectSet(sSpecArr);

    return traversalSpec;
  }