Search in sources :

Example 46 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project photon-model by vmware.

the class Lister method listFolder.

private List<Element> listFolder() throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, FinderException {
    PropertyFilterSpec spec = new PropertyFilterSpec();
    ObjectSpec objSpec = new ObjectSpec();
    objSpec.setObj(this.start);
    TraversalSpec selectionSpec = new TraversalSpec();
    selectionSpec.setPath("childEntity");
    selectionSpec.setType("Folder");
    selectionSpec.setSkip(false);
    objSpec.getSelectSet().add(selectionSpec);
    spec.getObjectSet().add(objSpec);
    // Retrieve all objects that we can deal with
    String[] childTypes = { "Folder", "Datacenter", "VirtualMachine", "Network", "ComputeResource", "ClusterComputeResource", "Datastore" };
    for (String t : childTypes) {
        PropertySpec pspec = new PropertySpec();
        pspec.setType(t);
        pspec.getPathSet().add("name");
        // Additional basic properties.
        if (t.equals("ComputeResource") || t.equals("ClusterComputeResource")) {
            // The ComputeResource and ClusterComputeResource are dereferenced in
            // the ResourcePoolFlag. Make sure they always have their resourcePool
            // field populated.
            pspec.getPathSet().add("resourcePool");
        }
        spec.getPropSet().add(pspec);
    }
    return callPropertyCollectorAndConvert(spec);
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec)

Example 47 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project photon-model by vmware.

the class Lister method listComputeResource.

private List<Element> listComputeResource() throws FinderException, InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
    ObjectSpec ospec = new ObjectSpec();
    ospec.setSkip(true);
    ospec.setObj(this.start);
    for (String f : new String[] { "host", "resourcePool" }) {
        TraversalSpec tspec = new TraversalSpec();
        tspec.setPath(f);
        tspec.setType("ComputeResource");
        tspec.setSkip(false);
        ospec.getSelectSet().add(tspec);
    }
    PropertyFilterSpec filter = new PropertyFilterSpec();
    filter.getObjectSet().add(ospec);
    for (String t : new String[] { "HostSystem", "ResourcePool" }) {
        PropertySpec pspec = new PropertySpec();
        pspec.setType(t);
        pspec.getPathSet().add("name");
        filter.getPropSet().add(pspec);
    }
    return callPropertyCollectorAndConvert(filter);
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec)

Example 48 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project photon-model by vmware.

the class Lister method listDatacenter.

private List<Element> listDatacenter() throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg, FinderException {
    ObjectSpec ospec = new ObjectSpec();
    ospec.setObj(this.start);
    ospec.setSkip(true);
    // Include every datastore folder in the select set
    String[] fields = { "vmFolder", "hostFolder", "datastoreFolder", "networkFolder", "datastore" };
    for (String f : fields) {
        TraversalSpec tspec = new TraversalSpec();
        tspec.setPath(f);
        tspec.setSkip(false);
        tspec.setType(VimNames.TYPE_DATACENTER);
        ospec.getSelectSet().add(tspec);
    }
    PropertySpec pspec = new PropertySpec();
    pspec.setType(VimNames.TYPE_FOLDER);
    pspec.getPathSet().add(VimNames.PROPERTY_NAME);
    PropertySpec dcspec = new PropertySpec();
    dcspec.setType(VimNames.TYPE_DATACENTER);
    dcspec.getPathSet().add(VimNames.PROPERTY_NAME);
    PropertySpec dsspec = new PropertySpec();
    dsspec.setType(VimNames.TYPE_DATASTORE);
    dsspec.getPathSet().add(VimNames.PROPERTY_NAME);
    PropertyFilterSpec spec = new PropertyFilterSpec();
    spec.getObjectSet().add(ospec);
    spec.getPropSet().add(pspec);
    spec.getPropSet().add(dcspec);
    spec.getPropSet().add(dsspec);
    return callPropertyCollectorAndConvert(spec);
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec)

Example 49 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project photon-model by vmware.

the class EnumerationClient method createVmFilterSpec.

public PropertyFilterSpec createVmFilterSpec(ManagedObjectReference dc) {
    ObjectSpec ospec = new ObjectSpec();
    ospec.setObj(dc);
    ospec.setSkip(false);
    ospec.getSelectSet().addAll(buildFullTraversal());
    PropertySpec vmSpec = new PropertySpec();
    vmSpec.setType(VimNames.TYPE_VM);
    vmSpec.getPathSet().addAll(Arrays.asList(VimPath.vm_config_name, VimPath.vm_config_instanceUuid, VimPath.vm_config_changeVersion, VimPath.vm_config_hardware_device, VimPath.vm_config_hardware_memoryMB, VimPath.vm_summary_config_numCpu, VimPath.vm_config_template, VimPath.vm_runtime_host, VimPath.vm_guest_net, VimPath.vm_guest_hostName, VimPath.vm_runtime_powerState, VimPath.vm_runtime_maxCpuUsage, VimPath.vm_runtime_maxMemoryUsage, VimPath.vm_summary_guest_ipAddress, VimPath.vm_summary_guest_hostName, VimPath.vm_snapshot_rootSnapshotList, VimPath.res_resourcePool, VimPath.vm_summary_config_guestFullName));
    PropertyFilterSpec filterSpec = new PropertyFilterSpec();
    filterSpec.getObjectSet().add(ospec);
    filterSpec.getPropSet().add(vmSpec);
    return filterSpec;
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec)

Example 50 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project photon-model by vmware.

the class EnumerationClient method createPropertyCollectorWithFilter.

public ManagedObjectReference createPropertyCollectorWithFilter(PropertyFilterSpec spec) throws RuntimeFaultFaultMsg, InvalidPropertyFaultMsg {
    ManagedObjectReference pc = createPropertyCollector();
    boolean partialUpdates = false;
    getVimPort().createFilter(pc, spec, partialUpdates);
    return pc;
}
Also used : ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Aggregations

PropertyFilterSpec (com.vmware.vim25.PropertyFilterSpec)68 ObjectSpec (com.vmware.vim25.ObjectSpec)60 PropertySpec (com.vmware.vim25.PropertySpec)60 TraversalSpec (com.vmware.vim25.TraversalSpec)47 ObjectContent (com.vmware.vim25.ObjectContent)46 ArrayList (java.util.ArrayList)37 DynamicProperty (com.vmware.vim25.DynamicProperty)21 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)19 SelectionSpec (com.vmware.vim25.SelectionSpec)11 Gson (com.google.gson.Gson)10 RetrieveOptions (com.vmware.vim25.RetrieveOptions)6 RetrieveResult (com.vmware.vim25.RetrieveResult)6 HashMap (java.util.HashMap)6 Pair (com.cloud.utils.Pair)4 ObjectSpecBuilder (com.vmware.photon.controller.model.adapters.vsphere.util.builders.ObjectSpecBuilder)4 PropertyFilterSpecBuilder (com.vmware.photon.controller.model.adapters.vsphere.util.builders.PropertyFilterSpecBuilder)4 PropertySpecBuilder (com.vmware.photon.controller.model.adapters.vsphere.util.builders.PropertySpecBuilder)4 ObjectUpdate (com.vmware.vim25.ObjectUpdate)4 PropertyFilterUpdate (com.vmware.vim25.PropertyFilterUpdate)4 UpdateSet (com.vmware.vim25.UpdateSet)4