use of com.vmware.vim25.mo.ManagedEntity in project photon-model by vmware.
the class Finder method ancestrySet.
private List<ObjectContent> ancestrySet(ManagedObjectReference ref) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ObjectSpec ospec = new ObjectSpec();
ospec.setObj(ref);
ospec.setSkip(false);
TraversalSpec tspec = new TraversalSpec();
tspec.setSkip(false);
tspec.setPath("parent");
tspec.setType("ManagedEntity");
tspec.setName("traverseParent");
SelectionSpec selSpec = new SelectionSpec();
selSpec.setName("traverseParent");
tspec.getSelectSet().add(selSpec);
ospec.getSelectSet().add(tspec);
PropertySpec pspec = new PropertySpec();
pspec.setType("ManagedEntity");
pspec.getPathSet().add("name");
pspec.getPathSet().add("parent");
PropertyFilterSpec filter = new PropertyFilterSpec();
filter.getObjectSet().add(ospec);
filter.getPropSet().add(pspec);
return this.connection.getVimPort().retrieveProperties(this.connection.getServiceContent().getPropertyCollector(), Collections.singletonList(filter));
}
use of com.vmware.vim25.mo.ManagedEntity in project vsphere-cloud-plugin by jenkinsci.
the class VSphere method folderExists.
/*
Check if folder exists along all the vSphere folders
*/
public Boolean folderExists(String folderPath) throws VSphereException {
try {
String[] folderHierarchy = folderPath.split("/");
ManagedEntity folder = null;
for (int i = 0; i < folderHierarchy.length; i++) {
if (i == 0) {
folder = new InventoryNavigator(getServiceInstance().getRootFolder()).searchManagedEntity("Folder", folderHierarchy[i]);
} else {
folder = new InventoryNavigator(folder).searchManagedEntity(null, folderHierarchy[i]);
}
if (folder == null) {
return false;
}
}
return true;
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Failed while checking if folder exists");
throw new VSphereException(e);
}
}
use of com.vmware.vim25.mo.ManagedEntity in project coprhd-controller by CoprHD.
the class VCenterAPI method searchManagedEntities.
/**
* Searches from the given parent for managed entities of the given type.
*
* @param parent the parent entity.
* @param type the desired type.
* @param recurse whether to recurse.
* @return the list of managed entities.
*
* @throws VMWareException if an error occurs.
*/
protected <T extends ManagedEntity> List<T> searchManagedEntities(ManagedEntity parent, Class<T> type, boolean recurse) throws VMWareException {
String typeName = type.getSimpleName();
List<T> results = Lists.newArrayList();
for (ManagedEntity entity : searchManagedEntities(parent, typeName, recurse)) {
results.add((T) entity);
}
return results;
}
use of com.vmware.vim25.mo.ManagedEntity in project coprhd-controller by CoprHD.
the class VCenterAPI method searchManagedEntity.
/**
* Searches from the given parent for a single managed entity with the specified type and name.
*
* @param type the type name.
* @param name the entity name.
* @return the managed entity.
*
* @throws VMWareException if an error occurs.
*/
public <T extends ManagedEntity> T searchManagedEntity(ManagedEntity parent, String type, String name) throws VMWareException {
try {
InventoryNavigator navigator = new InventoryNavigator(parent);
ManagedEntity entity = navigator.searchManagedEntity(type, name);
return (T) entity;
} catch (InvalidProperty e) {
throw new VMWareException(e);
} catch (RuntimeFault e) {
throw new VMWareException(e);
} catch (RemoteException e) {
throw new VMWareException(e);
}
}
use of com.vmware.vim25.mo.ManagedEntity in project coprhd-controller by CoprHD.
the class VCenterAPI method searchManagedEntities.
/**
* Searches from the given parent for managed entities of the specified type.
*
* @param parent the parent entity.
* @param type the type name.
* @param recurse whether to recurse.
* @return the managed entities.
*
* @throws VMWareException if an error occurs.
*/
public ManagedEntity[] searchManagedEntities(ManagedEntity parent, String type, boolean recurse) throws VMWareException {
try {
String[][] typeInfo = new String[][] { new String[] { type, "name" } };
InventoryNavigator navigator = new InventoryNavigator(parent);
ManagedEntity[] entities = navigator.searchManagedEntities(typeInfo, recurse);
return entities;
} catch (InvalidProperty e) {
throw new VMWareException(e);
} catch (RuntimeFault e) {
throw new VMWareException(e);
} catch (RemoteException e) {
throw new VMWareException(e);
}
}
Aggregations