Search in sources :

Example 26 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project CloudStack-archive by CloudStack-extras.

the class HostDatastoreSystemMO method getDatastorePropertiesOnHostDatastoreSystem.

public ObjectContent[] getDatastorePropertiesOnHostDatastoreSystem(String[] propertyPaths) throws Exception {
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("Datastore");
    pSpec.setPathSet(propertyPaths);
    TraversalSpec hostDsSys2DatastoreTraversal = new TraversalSpec();
    hostDsSys2DatastoreTraversal.setType("HostDatastoreSystem");
    hostDsSys2DatastoreTraversal.setPath("datastore");
    hostDsSys2DatastoreTraversal.setName("hostDsSys2DatastoreTraversal");
    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(_mor);
    oSpec.setSkip(Boolean.TRUE);
    oSpec.setSelectSet(new SelectionSpec[] { hostDsSys2DatastoreTraversal });
    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.setPropSet(new PropertySpec[] { pSpec });
    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
    return _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec)

Example 27 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project CloudStack-archive by CloudStack-extras.

the class ClusterMO method getHostPropertiesOnCluster.

private ObjectContent[] getHostPropertiesOnCluster(String[] propertyPaths) throws Exception {
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - retrieveProperties() on Host properties. target MOR: " + _mor.get_value() + ", properties: " + new Gson().toJson(propertyPaths));
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("HostSystem");
    pSpec.setPathSet(propertyPaths);
    TraversalSpec cluster2HostTraversal = new TraversalSpec();
    cluster2HostTraversal.setType("ClusterComputeResource");
    cluster2HostTraversal.setPath("host");
    cluster2HostTraversal.setName("cluster2HostTraversal");
    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(_mor);
    oSpec.setSkip(Boolean.TRUE);
    oSpec.setSelectSet(new SelectionSpec[] { cluster2HostTraversal });
    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.setPropSet(new PropertySpec[] { pSpec });
    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
    ObjectContent[] properties = _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - retrieveProperties() done");
    return properties;
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectContent(com.vmware.vim25.ObjectContent) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec) Gson(com.google.gson.Gson)

Example 28 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project CloudStack-archive by CloudStack-extras.

the class DatacenterMO method getHostPropertiesOnDatacenterHostFolder.

public ObjectContent[] getHostPropertiesOnDatacenterHostFolder(String[] propertyPaths) throws Exception {
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("HostSystem");
    pSpec.setPathSet(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.setSelectSet(new SelectionSpec[] { recurseFolders, computeResource2HostTraversal });
    TraversalSpec dc2HostFolderTraversal = new TraversalSpec();
    dc2HostFolderTraversal.setType("Datacenter");
    dc2HostFolderTraversal.setPath("hostFolder");
    dc2HostFolderTraversal.setName("dc2HostFolderTraversal");
    dc2HostFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity });
    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(_mor);
    oSpec.setSkip(Boolean.TRUE);
    oSpec.setSelectSet(new SelectionSpec[] { dc2HostFolderTraversal });
    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.setPropSet(new PropertySpec[] { pSpec });
    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
    return _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec) SelectionSpec(com.vmware.vim25.SelectionSpec)

Example 29 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project CloudStack-archive by CloudStack-extras.

the class DatastoreMO method getOwnerDatacenter.

public Pair<DatacenterMO, String> getOwnerDatacenter() throws Exception {
    if (_ownerDc != null)
        return _ownerDc;
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("Datacenter");
    pSpec.setPathSet(new String[] { "name" });
    TraversalSpec folderParentTraversal = new TraversalSpec();
    folderParentTraversal.setType("Folder");
    folderParentTraversal.setPath("parent");
    folderParentTraversal.setName("folderParentTraversal");
    folderParentTraversal.setSelectSet(new SelectionSpec[] { new SelectionSpec(null, null, "folderParentTraversal") });
    TraversalSpec dsParentTraversal = new TraversalSpec();
    dsParentTraversal.setType("Datastore");
    dsParentTraversal.setPath("parent");
    dsParentTraversal.setName("dsParentTraversal");
    dsParentTraversal.setSelectSet(new SelectionSpec[] { folderParentTraversal });
    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(getMor());
    oSpec.setSkip(Boolean.TRUE);
    oSpec.setSelectSet(new SelectionSpec[] { dsParentTraversal });
    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.setPropSet(new PropertySpec[] { pSpec });
    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
    ObjectContent[] ocs = _context.getService().retrieveProperties(_context.getServiceContent().getPropertyCollector(), new PropertyFilterSpec[] { pfSpec });
    assert (ocs != null);
    assert (ocs[0].getObj() != null);
    assert (ocs[0].getPropSet() != null);
    String dcName = ocs[0].getPropSet()[0].getVal().toString();
    _ownerDc = new Pair<DatacenterMO, String>(new DatacenterMO(_context, ocs[0].getObj()), dcName);
    return _ownerDc;
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectContent(com.vmware.vim25.ObjectContent) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec) SelectionSpec(com.vmware.vim25.SelectionSpec)

Example 30 with PropertyFilterSpec

use of com.vmware.vim25.PropertyFilterSpec in project cloudstack by apache.

the class HostMO method getVmPropertiesOnHyperHost.

@Override
public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getValue() + ", properties: " + new Gson().toJson(propertyPaths));
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("VirtualMachine");
    pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
    TraversalSpec host2VmTraversal = new TraversalSpec();
    host2VmTraversal.setType("HostSystem");
    host2VmTraversal.setPath("vm");
    host2VmTraversal.setName("host2VmTraversal");
    ObjectSpec oSpec = new ObjectSpec();
    oSpec.setObj(_mor);
    oSpec.setSkip(Boolean.TRUE);
    oSpec.getSelectSet().add(host2VmTraversal);
    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
    pfSpec.getPropSet().add(pSpec);
    pfSpec.getObjectSet().add(oSpec);
    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
    pfSpecArr.add(pfSpec);
    List<ObjectContent> properties = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
    if (s_logger.isTraceEnabled())
        s_logger.trace("vCenter API trace - retrieveProperties() done");
    return properties.toArray(new ObjectContent[properties.size()]);
}
Also used : PropertyFilterSpec(com.vmware.vim25.PropertyFilterSpec) ObjectContent(com.vmware.vim25.ObjectContent) ObjectSpec(com.vmware.vim25.ObjectSpec) PropertySpec(com.vmware.vim25.PropertySpec) TraversalSpec(com.vmware.vim25.TraversalSpec) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson)

Aggregations

ObjectSpec (com.vmware.vim25.ObjectSpec)45 PropertyFilterSpec (com.vmware.vim25.PropertyFilterSpec)45 PropertySpec (com.vmware.vim25.PropertySpec)45 TraversalSpec (com.vmware.vim25.TraversalSpec)38 ObjectContent (com.vmware.vim25.ObjectContent)35 ArrayList (java.util.ArrayList)26 DynamicProperty (com.vmware.vim25.DynamicProperty)16 Gson (com.google.gson.Gson)10 SelectionSpec (com.vmware.vim25.SelectionSpec)9 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)7 Pair (com.cloud.utils.Pair)4 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)2 CustomFieldStringValue (com.vmware.vim25.CustomFieldStringValue)2 DVPortgroupConfigInfo (com.vmware.vim25.DVPortgroupConfigInfo)2 VirtualMachineFileInfo (com.vmware.vim25.VirtualMachineFileInfo)2 InvalidPropertyFaultMsg (com.vmware.vim25.InvalidPropertyFaultMsg)1 ObjectUpdate (com.vmware.vim25.ObjectUpdate)1 PropertyChange (com.vmware.vim25.PropertyChange)1 PropertyFilterUpdate (com.vmware.vim25.PropertyFilterUpdate)1 RuntimeFaultFaultMsg (com.vmware.vim25.RuntimeFaultFaultMsg)1