use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost in project cloudstack by apache.
the class VmwareStorageProcessor method handleDatastoreAndVmdkDetachManaged.
private void handleDatastoreAndVmdkDetachManaged(String diskUuid, String iqn, String storageHost, int storagePort) throws Exception {
if (storagePort == DEFAULT_NFS_PORT) {
VmwareContext context = hostService.getServiceContext(null);
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
// for managed NFS datastore
hyperHost.unmountDatastore(diskUuid);
} else {
handleDatastoreAndVmdkDetach(VmwareResource.getDatastoreName(iqn), iqn, storageHost, storagePort);
}
}
use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost in project cloudstack by apache.
the class VmwareStorageProcessor method handleDatastoreAndVmdkDetach.
public void handleDatastoreAndVmdkDetach(String datastoreName, String iqn, String storageHost, int storagePort) throws Exception {
VmwareContext context = hostService.getServiceContext(null);
VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
removeVmfsDatastore(hyperHost, datastoreName, storageHost, storagePort, trimIqn(iqn));
}
use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(GetStoragePoolCapabilitiesCommand cmd) {
try {
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
HostMO host = (HostMO) hyperHost;
StorageFilerTO pool = cmd.getPool();
ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
if (morDatastore == null) {
morDatastore = hyperHost.mountDatastore((pool.getType() == StoragePoolType.VMFS || pool.getType() == StoragePoolType.PreSetup || pool.getType() == StoragePoolType.DatastoreCluster), pool.getHost(), pool.getPort(), pool.getPath(), pool.getUuid().replace("-", ""), true);
}
assert (morDatastore != null);
DatastoreMO dsMo = new DatastoreMO(getServiceContext(), morDatastore);
GetStoragePoolCapabilitiesAnswer answer = new GetStoragePoolCapabilitiesAnswer(cmd);
boolean hardwareAccelerationSupportForDataStore = getHardwareAccelerationSupportForDataStore(host.getMor(), dsMo.getName());
Map<String, String> poolDetails = answer.getPoolDetails();
poolDetails.put(Storage.Capability.HARDWARE_ACCELERATION.toString(), String.valueOf(hardwareAccelerationSupportForDataStore));
answer.setPoolDetails(poolDetails);
answer.setResult(true);
return answer;
} catch (Throwable e) {
GetStoragePoolCapabilitiesAnswer answer = new GetStoragePoolCapabilitiesAnswer(cmd);
answer.setResult(false);
answer.setDetails(createLogMessageException(e, cmd));
return answer;
}
}
use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost in project cloudstack by apache.
the class VmwareResource method registerVm.
/**
* Registers the vm to the inventory given the vmx file.
*/
private void registerVm(String vmName, DatastoreMO dsMo) throws Exception {
// 1st param
VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
ManagedObjectReference dcMor = hyperHost.getHyperHostDatacenter();
DatacenterMO dataCenterMo = new DatacenterMO(getServiceContext(), dcMor);
ManagedObjectReference vmFolderMor = dataCenterMo.getVmFolder();
// 2nd param
String vmxFilePath = dsMo.searchFileInSubFolders(vmName + ".vmx", false, VmwareManager.s_vmwareSearchExcludeFolder.value());
// 5th param
ManagedObjectReference morPool = hyperHost.getHyperHostOwnerResourcePool();
ManagedObjectReference morTask = getServiceContext().getService().registerVMTask(vmFolderMor, vmxFilePath, vmName, false, morPool, hyperHost.getMor());
boolean result = getServiceContext().getVimClient().waitForTask(morTask);
if (!result) {
throw new Exception("Unable to register vm due to " + TaskMO.getTaskFailureInfo(getServiceContext(), morTask));
} else {
getServiceContext().waitForTaskProgressDone(morTask);
}
}
use of com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost in project cloudstack by apache.
the class VmwareResource method cleanupNetworkElementCommand.
private ExecutionResult cleanupNetworkElementCommand(IpAssocCommand cmd) {
VmwareContext context = getServiceContext();
try {
VmwareHypervisorHost hyperHost = getHyperHost(context);
IpAddressTO[] ips = cmd.getIpAddresses();
String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(routerName);
// the check and will try to find it within datacenter
if (vmMo == null) {
if (hyperHost instanceof HostMO) {
final DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());
vmMo = dcMo.findVm(routerName);
}
}
if (vmMo == null) {
String msg = String.format("Router %s no longer exists to execute IPAssoc command ", routerName);
s_logger.error(msg);
throw new Exception(msg);
}
final String lastIp = cmd.getAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP);
for (IpAddressTO ip : ips) {
if (ip.isAdd() || lastIp.equalsIgnoreCase("false")) {
continue;
}
Pair<VirtualDevice, Integer> nicInfo = getVirtualDevice(vmMo, ip);
if (nicInfo.second() == 2) {
return new ExecutionResult(true, "Not removing eth2 in network VR because it is the public NIC of source NAT");
}
if (nicInfo.first() == null) {
return new ExecutionResult(false, "Couldn't find NIC");
}
configureNicDevice(vmMo, nicInfo.first(), VirtualDeviceConfigSpecOperation.REMOVE, "unplugNicCommand");
}
} catch (Throwable e) {
s_logger.error("Unexpected exception: " + e.toString() + " will shortcut rest of IPAssoc commands", e);
return new ExecutionResult(false, e.toString());
}
return new ExecutionResult(true, null);
}
Aggregations