Ejemplo n.º 1
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;
  }
Ejemplo n.º 2
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;
  }
Ejemplo n.º 3
0
  /**
   * @return An array of SelectionSpec covering VM, Host, Resource pool, Cluster Compute Resource
   *     and Datastore.
   */
  private static List<SelectionSpec> buildFullTraversal() {
    // Terminal traversal specs

    // RP -> VM
    TraversalSpec rpToVm = new TraversalSpec();
    rpToVm.setName("rpToVm");
    rpToVm.setType("ResourcePool");
    rpToVm.setPath("vm");
    rpToVm.setSkip(Boolean.FALSE);

    // vApp -> VM
    TraversalSpec vAppToVM = new TraversalSpec();
    vAppToVM.setName("vAppToVM");
    vAppToVM.setType("VirtualApp");
    vAppToVM.setPath("vm");

    // HostSystem -> VM
    TraversalSpec hToVm = new TraversalSpec();
    hToVm.setType("HostSystem");
    hToVm.setPath("vm");
    hToVm.setName("hToVm");
    hToVm.getSelectSet().add(getSelectionSpec("VisitFolders"));
    hToVm.setSkip(Boolean.FALSE);

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

    // Recurse through all ResourcePools
    TraversalSpec rpToRp = new TraversalSpec();
    rpToRp.setType("ResourcePool");
    rpToRp.setPath("resourcePool");
    rpToRp.setSkip(Boolean.FALSE);
    rpToRp.setName("rpToRp");
    rpToRp.getSelectSet().add(getSelectionSpec("rpToRp"));

    TraversalSpec crToRp = new TraversalSpec();
    crToRp.setType("ComputeResource");
    crToRp.setPath("resourcePool");
    crToRp.setSkip(Boolean.FALSE);
    crToRp.setName("crToRp");
    crToRp.getSelectSet().add(getSelectionSpec("rpToRp"));

    TraversalSpec crToH = new TraversalSpec();
    crToH.setSkip(Boolean.FALSE);
    crToH.setType("ComputeResource");
    crToH.setPath("host");
    crToH.setName("crToH");

    TraversalSpec dcToHf = new TraversalSpec();
    dcToHf.setSkip(Boolean.FALSE);
    dcToHf.setType("Datacenter");
    dcToHf.setPath("hostFolder");
    dcToHf.setName("dcToHf");
    dcToHf.getSelectSet().add(getSelectionSpec("VisitFolders"));

    TraversalSpec vAppToRp = new TraversalSpec();
    vAppToRp.setName("vAppToRp");
    vAppToRp.setType("VirtualApp");
    vAppToRp.setPath("resourcePool");
    vAppToRp.getSelectSet().add(getSelectionSpec("rpToRp"));

    TraversalSpec dcToVmf = new TraversalSpec();
    dcToVmf.setType("Datacenter");
    dcToVmf.setSkip(Boolean.FALSE);
    dcToVmf.setPath("vmFolder");
    dcToVmf.setName("dcToVmf");
    dcToVmf.getSelectSet().add(getSelectionSpec("VisitFolders"));

    // For Folder -> Folder recursion
    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(getSelectionSpec("crToRp"));
    sspecarrvf.add(getSelectionSpec("crToH"));
    sspecarrvf.add(getSelectionSpec("dcToVmf"));
    sspecarrvf.add(getSelectionSpec("dcToHf"));
    sspecarrvf.add(getSelectionSpec("vAppToRp"));
    sspecarrvf.add(getSelectionSpec("vAppToVM"));
    sspecarrvf.add(getSelectionSpec("dcToDs"));
    sspecarrvf.add(getSelectionSpec("hToVm"));
    sspecarrvf.add(getSelectionSpec("rpToVm"));
    sspecarrvf.add(getSelectionSpec("VisitFolders"));

    visitFolders.getSelectSet().addAll(sspecarrvf);

    List<SelectionSpec> resultspec = new ArrayList<SelectionSpec>();
    resultspec.add(visitFolders);
    resultspec.add(crToRp);
    resultspec.add(crToH);
    resultspec.add(dcToVmf);
    resultspec.add(dcToHf);
    resultspec.add(vAppToRp);
    resultspec.add(vAppToVM);
    resultspec.add(dcToDs);
    resultspec.add(hToVm);
    resultspec.add(rpToVm);
    resultspec.add(rpToRp);

    return resultspec;
  }