use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class VmwareHelper method findSnapshotInTree.
public static ManagedObjectReference findSnapshotInTree(List<VirtualMachineSnapshotTree> snapTree, String findName) {
assert (findName != null);
ManagedObjectReference snapMor = null;
if (snapTree == null)
return snapMor;
for (int i = 0; i < snapTree.size() && snapMor == null; i++) {
VirtualMachineSnapshotTree node = snapTree.get(i);
if (node.getName().equals(findName)) {
snapMor = node.getSnapshot();
} else {
List<VirtualMachineSnapshotTree> childTree = node.getChildSnapshotList();
snapMor = findSnapshotInTree(childTree, findName);
}
}
return snapMor;
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class ClusterMO method getClusterHosts.
public List<Pair<ManagedObjectReference, String>> getClusterHosts() throws Exception {
List<Pair<ManagedObjectReference, String>> hosts = new ArrayList<Pair<ManagedObjectReference, String>>();
ObjectContent[] ocs = getHostPropertiesOnCluster(new String[] { "name" });
if (ocs != null) {
for (ObjectContent oc : ocs) {
ManagedObjectReference morHost = oc.getObj();
String name = (String) oc.getPropSet().get(0).getVal();
hosts.add(new Pair<ManagedObjectReference, String>(morHost, name));
}
}
return hosts;
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class ClusterMO method getHyperHostResourceSummary.
@Override
public VmwareHypervisorHostResourceSummary getHyperHostResourceSummary() throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostResourceSummary(). target MOR: " + _mor.getValue());
VmwareHypervisorHostResourceSummary summary = new VmwareHypervisorHostResourceSummary();
ComputeResourceSummary vmwareSummary = (ComputeResourceSummary) _context.getVimClient().getDynamicProperty(_mor, "summary");
// TODO, need to use traversal to optimize retrieve of
int cpuNumInCpuThreads = 1;
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
HostHardwareSummary hardwareSummary = hostMo.getHostHardwareSummary();
if (hardwareSummary.getNumCpuCores() * hardwareSummary.getNumCpuThreads() > cpuNumInCpuThreads)
cpuNumInCpuThreads = hardwareSummary.getNumCpuCores() * hardwareSummary.getNumCpuThreads();
}
}
summary.setCpuCount(cpuNumInCpuThreads);
summary.setCpuSpeed(vmwareSummary.getTotalCpu());
summary.setMemoryBytes(vmwareSummary.getTotalMemory());
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostResourceSummary() done");
return summary;
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class HostDatastoreBrowserMO method searchDatastoreSubFolders.
@SuppressWarnings("unchecked")
public ArrayList<HostDatastoreBrowserSearchResults> searchDatastoreSubFolders(String datastorePath, HostDatastoreBrowserSearchSpec searchSpec) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - searchDatastoreSubFolders(). target mor: " + _mor.getValue() + ", file datastore path: " + datastorePath);
try {
ManagedObjectReference morTask = _context.getService().searchDatastoreSubFoldersTask(_mor, datastorePath, searchSpec);
boolean result = _context.getVimClient().waitForTask(morTask);
if (result) {
_context.waitForTaskProgressDone(morTask);
return (ArrayList<HostDatastoreBrowserSearchResults>) _context.getVimClient().getDynamicProperty(morTask, "info.result");
} else {
s_logger.error("VMware searchDaastoreSubFolders_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
} finally {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - searchDatastore() done");
}
return null;
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class HostDatastoreSystemMO method findDatastoreByExportPath.
// TODO this is a hacking helper method, when we can pass down storage pool info along with volume
// we should be able to find the datastore by name
public ManagedObjectReference findDatastoreByExportPath(String exportPath) throws Exception {
assert (exportPath != null);
List<ManagedObjectReference> datastores = getDatastores();
if (datastores != null && datastores.size() > 0) {
for (ManagedObjectReference morDatastore : datastores) {
DatastoreMO dsMo = new DatastoreMO(_context, morDatastore);
if (dsMo.getInventoryPath().equals(exportPath))
return morDatastore;
NasDatastoreInfo info = getNasDatastoreInfo(morDatastore);
if (info != null) {
String vmwareUrl = info.getUrl();
if (vmwareUrl.charAt(vmwareUrl.length() - 1) == '/')
vmwareUrl = vmwareUrl.substring(0, vmwareUrl.length() - 1);
URI uri = new URI(vmwareUrl);
if (uri.getPath().equals("/" + exportPath))
return morDatastore;
}
}
}
return null;
}
Aggregations