/** @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;
  }
Example #2
0
  /** @return TraversalSpec specification to get to the Datacenter managed object. */
  private static TraversalSpec getDatacenterTraversalSpec() {
    // Create a traversal spec that starts from the 'root' objects
    SelectionSpec sSpec = new SelectionSpec();
    sSpec.setName("VisitFolders");

    // TraversalSpec to get to the DataCenter from rootFolder
    TraversalSpec traversalSpec = new TraversalSpec();
    traversalSpec.setName("VisitFolders");
    traversalSpec.setType("Folder");
    traversalSpec.setPath("childEntity");
    traversalSpec.setSkip(false);
    traversalSpec.getSelectSet().add(sSpec);
    return traversalSpec;
  }
Example #3
0
  /** @return TraversalSpec specification to get to the HostSystem managed object. */
  private static TraversalSpec getHostSystemTraversalSpec() {
    // Create a traversal spec that starts from the 'root' objects
    // and traverses the inventory tree to get to the Host system.
    // Build the traversal specs bottoms up
    SelectionSpec ss = new SelectionSpec();
    ss.setName("VisitFolders");

    // Traversal to get to the host from ComputeResource
    TraversalSpec computeResourceToHostSystem = new TraversalSpec();
    computeResourceToHostSystem.setName("computeResourceToHostSystem");
    computeResourceToHostSystem.setType("ComputeResource");
    computeResourceToHostSystem.setPath("host");
    computeResourceToHostSystem.setSkip(false);
    computeResourceToHostSystem.getSelectSet().add(ss);

    // Traversal to get to the ComputeResource from hostFolder
    TraversalSpec hostFolderToComputeResource = new TraversalSpec();
    hostFolderToComputeResource.setName("hostFolderToComputeResource");
    hostFolderToComputeResource.setType("Folder");
    hostFolderToComputeResource.setPath("childEntity");
    hostFolderToComputeResource.setSkip(false);
    hostFolderToComputeResource.getSelectSet().add(ss);

    // Traversal to get to the hostFolder from DataCenter
    TraversalSpec dataCenterToHostFolder = new TraversalSpec();
    dataCenterToHostFolder.setName("DataCenterToHostFolder");
    dataCenterToHostFolder.setType("Datacenter");
    dataCenterToHostFolder.setPath("hostFolder");
    dataCenterToHostFolder.setSkip(false);
    dataCenterToHostFolder.getSelectSet().add(ss);

    // 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<SelectionSpec>();
    sSpecArr.add(ss);
    sSpecArr.add(dataCenterToHostFolder);
    sSpecArr.add(hostFolderToComputeResource);
    sSpecArr.add(computeResourceToHostSystem);
    traversalSpec.getSelectSet().addAll(sSpecArr);
    return traversalSpec;
  }
Example #4
0
  /** @return TraversalSpec specification to get to the VirtualMachine managed object. */
  private 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 VM in a VApp
    TraversalSpec vAppToVM = new TraversalSpec();
    vAppToVM.setName("vAppToVM");
    vAppToVM.setType("VirtualApp");
    vAppToVM.setPath("vm");

    // Traversal spec 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<SelectionSpec>();
    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<SelectionSpec>();
    sSpecArr.add(sSpec);
    sSpecArr.add(dataCenterToVMFolder);
    sSpecArr.add(vAppToVM);
    sSpecArr.add(vAppToVApp);
    traversalSpec.getSelectSet().addAll(sSpecArr);
    return traversalSpec;
  }
Example #5
0
 private static SelectionSpec getSelectionSpec(String name) {
   SelectionSpec genericSpec = new SelectionSpec();
   genericSpec.setName(name);
   return genericSpec;
 }