use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class ClusterMO method findDatastoreByExportPath.
@Override
public ManagedObjectReference findDatastoreByExportPath(String exportPath) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath(). target MOR: " + _mor.getValue() + ", exportPath: " + exportPath);
ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] { "info" });
if (ocs != null && ocs.length > 0) {
for (ObjectContent oc : ocs) {
DatastoreInfo dsInfo = (DatastoreInfo) oc.getPropSet().get(0).getVal();
if (dsInfo != null && dsInfo instanceof NasDatastoreInfo) {
NasDatastoreInfo info = (NasDatastoreInfo) dsInfo;
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)) {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath() done(successfully)");
return oc.getObj();
}
}
}
}
}
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - findDatastoreByExportPath() done(failed)");
return null;
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class ClusterMO method getRestartPriorityForVM.
private String getRestartPriorityForVM(VirtualMachineMO vmMo) throws Exception {
if (vmMo == null) {
s_logger.debug("Failed to get restart priority for VM, invalid VM object reference");
return null;
}
ManagedObjectReference vmMor = vmMo.getMor();
if (vmMor == null || !vmMor.getType().equals("VirtualMachine")) {
s_logger.debug("Failed to get restart priority for VM: " + vmMo.getName() + ", invalid VM object reference");
return null;
}
ClusterConfigInfoEx configInfo = getClusterConfigInfo();
if (configInfo == null) {
s_logger.debug("Failed to get restart priority for VM: " + vmMo.getName() + ", no cluster config information");
return null;
}
List<ClusterDasVmConfigInfo> dasVmConfig = configInfo.getDasVmConfig();
for (int dasVmConfigIndex = 0; dasVmConfigIndex < dasVmConfig.size(); dasVmConfigIndex++) {
ClusterDasVmConfigInfo dasVmConfigInfo = dasVmConfig.get(dasVmConfigIndex);
if (dasVmConfigInfo != null && dasVmConfigInfo.getKey().getValue().equals(vmMor.getValue())) {
DasVmPriority dasVmPriority = dasVmConfigInfo.getRestartPriority();
if (dasVmPriority != null) {
return dasVmPriority.value();
} else {
//VM uses cluster restart priority when DasVmPriority for the VM is null.
return ClusterDasVmSettingsRestartPriority.CLUSTER_RESTART_PRIORITY.value();
}
}
}
s_logger.debug("VM: " + vmMo.getName() + " uses default restart priority in the cluster: " + getName());
return null;
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class HostMO method getDatastoreMountsOnHost.
public List<Pair<ManagedObjectReference, String>> getDatastoreMountsOnHost() throws Exception {
List<Pair<ManagedObjectReference, String>> mounts = new ArrayList<Pair<ManagedObjectReference, String>>();
ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] { String.format("host[\"%s\"].mountInfo.path", _mor.getValue()) });
if (ocs != null) {
for (ObjectContent oc : ocs) {
Pair<ManagedObjectReference, String> mount = new Pair<ManagedObjectReference, String>(oc.getObj(), oc.getPropSet().get(0).getVal().toString());
mounts.add(mount);
}
}
return mounts;
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class HostMO method setRestartPriorityForVM.
@Override
public void setRestartPriorityForVM(VirtualMachineMO vmMo, String priority) throws Exception {
ManagedObjectReference morParent = getParentMor();
if (morParent.getType().equals("ClusterComputeResource")) {
ClusterMO clusterMo = new ClusterMO(_context, morParent);
clusterMo.setRestartPriorityForVM(vmMo, priority);
}
}
use of com.vmware.vim25.ManagedObjectReference in project cloudstack by apache.
the class HostMO method getHostFirewallSystemMO.
public HostFirewallSystemMO getHostFirewallSystemMO() throws Exception {
HostConfigManager configMgr = getHostConfigManager();
ManagedObjectReference morFirewall = configMgr.getFirewallSystem();
// only ESX hosts have firewall manager
if (morFirewall != null)
return new HostFirewallSystemMO(_context, morFirewall);
return null;
}
Aggregations