private boolean isOnSupportedHypevisorForMigration(VMInstanceVO vm) { return (vm.getHypervisorType().equals(HypervisorType.XenServer) || vm.getHypervisorType().equals(HypervisorType.VMware) || vm.getHypervisorType().equals(HypervisorType.KVM) || vm.getHypervisorType().equals(HypervisorType.Ovm) || vm.getHypervisorType().equals(HypervisorType.Hyperv) || vm.getHypervisorType().equals(HypervisorType.LXC) || vm.getHypervisorType().equals(HypervisorType.Simulator) || vm.getHypervisorType().equals(HypervisorType.Ovm3)); }
private HypervisorType getHypervisorType(Volume volume) { Long instanceId = volume.getInstanceId(); VMInstanceVO vmInstance = _vmInstanceDao.findById(instanceId); if (vmInstance != null) { return vmInstance.getHypervisorType(); } return null; }
private void checkDestinationHypervisorType(StoragePool destPool, VMInstanceVO vm) { HypervisorType destHypervisorType = destPool.getHypervisor(); if (destHypervisorType == null) { destHypervisorType = _clusterDao.findById( destPool.getClusterId()).getHypervisorType(); } if (vm.getHypervisorType() != destHypervisorType && destHypervisorType != HypervisorType.Any) { throw new InvalidParameterValueException("hypervisor is not compatible: dest: " + destHypervisorType.toString() + ", vm: " + vm.getHypervisorType().toString()); } }
private void orchestrateStorageMigration(final String vmUuid, final StoragePool destPool) { final VMInstanceVO vm = _vmDao.findByUuid(vmUuid); preStorageMigrationStateCheck(destPool, vm); try { if(s_logger.isDebugEnabled()) { s_logger.debug(String.format("Offline migration of %s vm %s with volumes", vm.getHypervisorType().toString(), vm.getInstanceName())); } migrateThroughHypervisorOrStorage(destPool, vm); } catch (ConcurrentOperationException | InsufficientCapacityException // possibly InsufficientVirtualNetworkCapacityException or InsufficientAddressCapacityException | StorageUnavailableException e) { String msg = String.format("Failed to migrate VM: %s", vmUuid); s_logger.debug(msg); throw new CloudRuntimeException(msg, e); } finally { try { stateTransitTo(vm, Event.AgentReportStopped, null); } catch (final NoTransitionException e) { String anotherMEssage = String.format("failed to change vm state of VM: %s", vmUuid); s_logger.debug(anotherMEssage); throw new CloudRuntimeException(anotherMEssage, e); } } }
private Answer[] attemptHypervisorMigration(StoragePool destPool, VMInstanceVO vm) { final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType()); // OfflineVmwareMigration: in case of vmware call vcenter to do it for us. // OfflineVmwareMigration: should we check the proximity of source and destination // OfflineVmwareMigration: if we are in the same cluster/datacentre/pool or whatever? // OfflineVmwareMigration: we are checking on success to optionally delete an old vm if we are not List<Command> commandsToSend = hvGuru.finalizeMigrate(vm, destPool); Long hostId = vm.getHostId(); // OfflineVmwareMigration: probably this is null when vm is stopped if(hostId == null) { hostId = vm.getLastHostId(); if (s_logger.isDebugEnabled()) { s_logger.debug(String.format("host id is null, using last host id %d", hostId) ); } } if(CollectionUtils.isNotEmpty(commandsToSend)) { Commands commandsContainer = new Commands(Command.OnError.Stop); commandsContainer.addCommands(commandsToSend); try { // OfflineVmwareMigration: change to the call back variety? // OfflineVmwareMigration: getting a Long seq to be filled with _agentMgr.send(hostId, commandsContainer, this) return _agentMgr.send(hostId, commandsContainer); } catch (AgentUnavailableException | OperationTimedoutException e) { throw new CloudRuntimeException(String.format("Failed to migrate VM: %s", vm.getUuid()),e); } } return null; }
/** * Delete vm snapshots depending on vm's hypervisor type. For Vmware, vm snapshots removal is delegated to vm cleanup thread * to reduce tasks sent to hypervisor (one tasks to delete vm snapshots and vm itself * instead of one task for each vm snapshot plus another for the vm) * @param vm vm * @param expunge indicates if vm should be expunged */ private void deleteVMSnapshots(VMInstanceVO vm, boolean expunge) { if (! vm.getHypervisorType().equals(HypervisorType.VMware)) { if (!_vmSnapshotMgr.deleteAllVMSnapshots(vm.getId(), null)) { s_logger.debug("Unable to delete all snapshots for " + vm); throw new CloudRuntimeException("Unable to delete vm snapshots for " + vm); } } else { if (expunge) { _vmSnapshotMgr.deleteVMSnapshotsFromDB(vm.getId()); } } }
private void afterStorageMigrationCleanup(StoragePool destPool, VMInstanceVO vm, HostVO srcHost, Long srcClusterId) throws InsufficientCapacityException { setDestinationPoolAndReallocateNetwork(destPool, vm); //when start the vm next time, don;'t look at last_host_id, only choose the host based on volume/storage pool vm.setLastHostId(null); vm.setPodIdToDeployIn(destPool.getPodId()); // If VM was cold migrated between clusters belonging to two different VMware DCs, // unregister the VM from the source host and cleanup the associated VM files. if (vm.getHypervisorType().equals(HypervisorType.VMware)) { afterStorageMigrationVmwareVMcleanup(destPool, vm, srcHost, srcClusterId); } }
if (!vm.getHypervisorType().equals(HypervisorType.XenServer) && !vm.getHypervisorType().equals(HypervisorType.VMware) && !vm.getHypervisorType().equals(HypervisorType.KVM) && !vm.getHypervisorType().equals(HypervisorType.Ovm) && !vm.getHypervisorType().equals(HypervisorType.Hyperv) && !vm.getHypervisorType().equals(HypervisorType.LXC) && !vm.getHypervisorType().equals(HypervisorType.Simulator) && !vm.getHypervisorType().equals(HypervisorType.Ovm3)) { if (s_logger.isDebugEnabled()) { s_logger.debug(vm + " is not XenServer/VMware/KVM/Ovm/Hyperv/Ovm3, cannot migrate this VM."); if (vm.getType().equals(VirtualMachine.Type.User) && vm.getHypervisorType().equals(HypervisorType.LXC)) { throw new InvalidParameterValueException("Unsupported Hypervisor Type for User VM migration, we support XenServer/VMware/KVM/Ovm/Hyperv/Ovm3 only");
case Migrating: s_logger.info("VM " + vm.getInstanceName() + " is at " + vm.getState() + " and we received a power-off report while there is no pending jobs on it"); if(vm.isHaEnabled() && vm.getState() == State.Running && HaVmRestartHostUp.value() && vm.getHypervisorType() != HypervisorType.VMware && vm.getHypervisorType() != HypervisorType.Hyperv) { s_logger.info("Detected out-of-band stop of a HA enabled VM " + vm.getInstanceName() + ", will schedule restart"); if(!_haMgr.hasPendingHaWork(vm.getId())) {
final Hypervisor.HypervisorType hypervisorType = vmInstance.getHypervisorType();
!HypervisorType.VMware.equals(vm.getHypervisorType())) { throw new InvalidParameterValueException("Data disks attached to the vm, can not migrate. Need to detach data disks first");
final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType());
if (vm.getHypervisorType() == HypervisorType.VMware || vm.getHypervisorType() == HypervisorType.Hyperv) { s_logger.info("Skip HA for VMware VM or Hyperv VM" + vm.getInstanceName()); return; if (vm.getHypervisorType() == HypervisorType.VMware) { s_logger.info("Skip HA for VMware VM " + vm.getInstanceName()); return;
@Override @ActionEvent(eventType = EventTypes.EVENT_VM_UPGRADE, eventDescription = "Upgrading system VM", async = true) public VirtualMachine upgradeSystemVM(final ScaleSystemVMCmd cmd) throws ResourceUnavailableException, ManagementServerException, VirtualMachineMigrationException, ConcurrentOperationException { final VMInstanceVO vmInstance = _vmInstanceDao.findById(cmd.getId()); if (vmInstance.getHypervisorType() == HypervisorType.XenServer && vmInstance.getState().equals(State.Running)) { throw new InvalidParameterValueException("Dynamic Scaling operation is not permitted for this hypervisor on system vm"); } final boolean result = _userVmMgr.upgradeVirtualMachine(cmd.getId(), cmd.getServiceOfferingId(), cmd.getDetails()); if (result) { final VirtualMachine vm = _vmInstanceDao.findById(cmd.getId()); return vm; } else { throw new CloudRuntimeException("Failed to upgrade System VM"); } }
if (vmInstance.getHypervisorType() != HypervisorType.XenServer && vmInstance.getHypervisorType() != HypervisorType.VMware && vmInstance.getHypervisorType() != HypervisorType.Simulator) { s_logger.info("Scaling the VM dynamically is not supported for VMs running on Hypervisor "+vmInstance.getHypervisorType()); throw new InvalidParameterValueException("Scaling the VM dynamically is not supported for VMs running on Hypervisor "+vmInstance.getHypervisorType());
s_logger.debug(vm + " is not XenServer/VMware/KVM/Ovm/Hyperv, cannot migrate this VM form hypervisor type " + vm.getHypervisorType()); if (vm.getType().equals(VirtualMachine.Type.User) && vm.getHypervisorType().equals(HypervisorType.LXC)) { throw new InvalidParameterValueException("Unsupported Hypervisor Type for User VM migration, we support XenServer/VMware/KVM/Ovm/Hyperv/Ovm3 only");
cmds.addCommand(new RebootCommand(vm.getInstanceName(), getExecuteInSequence(vm.getHypervisorType()))); _agentMgr.send(host.getId(), cmds);
throw new InvalidParameterValueException("Creating snapshot failed due to vm:" + vmId + " doesn't exist"); if (! HypervisorType.KVM.equals(vm.getHypervisorType())) { throw new InvalidParameterValueException("Unsupported hypervisor type " + vm.getHypervisorType() + ". This supports KVM only");
if(vm.getHypervisorType().equals(HypervisorType.VMware)) { final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType()); Map<String, String> details = null; details = hvGuru.getClusterSettings(vm.getId());
final HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vm.getHypervisorType()); final VirtualMachineTO to = hvGuru.implement(profile);