@Override public void advanceExpunge(final String vmUuid) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { final VMInstanceVO vm = _vmDao.findByUuid(vmUuid); advanceExpunge(vm); }
@Override public void reboot(final String vmUuid, final Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException { try { advanceReboot(vmUuid, params); } catch (final ConcurrentOperationException e) { throw new CloudRuntimeException("Unable to reboot a VM due to concurrent operation", e); } }
@Override public void advanceStart(final String vmUuid, final Map<VirtualMachineProfile.Param, Object> params, final DeploymentPlanner planner) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { advanceStart(vmUuid, params, null, planner); }
final VirtualMachineGuru vmGuru = getVmGuru(vm); final Ternary<VMInstanceVO, ReservationContext, ItWorkVO> start = changeToStartState(vmGuru, vm, caller, account); if (start == null) { return; areAffinityGroupsAssociated(vmProfile)); if (!changeState(vm, Event.OperationRetry, destHostId, work, Step.Prepare)) { throw new ConcurrentOperationException("Unable to update the state of the Virtual Machine "+vm.getUuid()+" oldstate: "+vm.getState()+ "Event :"+Event.OperationRetry); handlePath(vmTO.getDisks(), vm.getHypervisorType()); cmds.addCommand(new StartCommand(vmTO, dest.getHost(), getExecuteInSequence(vm.getHypervisorType()))); addExtraConfig(vmTO); handlePath(vmTO.getDisks(), startAnswer.getIqnToData()); syncDiskChainChange(startAnswer); if (!changeState(vm, Event.OperationSucceeded, destHostId, work, Step.Done)) { s_logger.error("Unable to transition to a new state. VM uuid: "+vm.getUuid()+ "VM oldstate:"+vm.getState()+"Event:"+Event.OperationSucceeded); throw new ConcurrentOperationException("Failed to deploy VM"+ vm.getUuid()); for (int retries = 3; retries > 0; retries--) { try { setupAgentSecurity(vmHost, sshAccessDetails, vm); return;
advanceStop(vm.getUuid(), false); vm = _vmDao.findByUuid(vm.getUuid()); if (!stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, vm.getHostId())) { s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); throw new CloudRuntimeException("Unable to destroy " + vm); List<Map<String, String>> targets = getTargets(hostId, vm.getId()); removeDynamicTargets(hostId, targets); final VirtualMachineGuru guru = getVmGuru(vm); guru.finalizeExpunge(vm);
private void migrateThroughHypervisorOrStorage(StoragePool destPool, VMInstanceVO vm) throws StorageUnavailableException, InsufficientCapacityException { final VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); final Long srchostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId(); final HostVO srcHost = _hostDao.findById(srchostId); final Long srcClusterId = srcHost.getClusterId(); Answer[] hypervisorMigrationResults = attemptHypervisorMigration(destPool, vm); boolean migrationResult = false; if (hypervisorMigrationResults == null) { // OfflineVmwareMigration: if the HypervisorGuru can't do it, let the volume manager take care of it. migrationResult = volumeMgr.storageMigration(profile, destPool); if (migrationResult) { afterStorageMigrationCleanup(destPool, vm, srcHost, srcClusterId); } else { s_logger.debug("Storage migration failed"); } } else { afterHypervisorMigrationCleanup(destPool, vm, srcHost, srcClusterId, hypervisorMigrationResults); } }
placeHolder = createPlaceHolderWork(vm.getId()); try { return orchestrateAddVmToNetwork(vm, network, requested); } finally { if (placeHolder != null) { final Outcome<VirtualMachine> outcome = addVmToNetworkThroughJobQueue(vm, network, requested);
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); } }
advanceStop(vmUuid, VmDestroyForcestop.value()); deleteVMSnapshots(vm, expunge);
migrate(vm, srcHostId, dest); return; } catch (final ResourceUnavailableException e) { advanceStop(vmUuid, true); throw new CloudRuntimeException("Unable to migrate " + vm); } catch (final ResourceUnavailableException e) {
private void orchestrateStop(final String vmUuid, final boolean cleanUpEvenIfUnableToStop) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException { final VMInstanceVO vm = _vmDao.findByUuid(vmUuid); advanceStop(vm, cleanUpEvenIfUnableToStop); }
@Override public void allocate(final String vmInstanceName, final VirtualMachineTemplate template, final ServiceOffering serviceOffering, final LinkedHashMap<? extends Network, List<? extends NicProfile>> networks, final DeploymentPlan plan, final HypervisorType hyperType) throws InsufficientCapacityException { allocate(vmInstanceName, template, serviceOffering, new DiskOfferingInfo(serviceOffering), new ArrayList<DiskOfferingInfo>(), networks, plan, hyperType, null, null); }
@Override public void stop(final String vmUuid) throws ResourceUnavailableException { try { advanceStop(vmUuid, false); } catch (final OperationTimedoutException e) { throw new AgentUnavailableException("Unable to stop vm because the operation to stop timed out", e.getAgentId(), e); } catch (final ConcurrentOperationException e) { throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e); } }
@Override public void stopForced(String vmUuid) throws ResourceUnavailableException { try { advanceStop(vmUuid, true); } catch (final OperationTimedoutException e) { throw new AgentUnavailableException("Unable to stop vm because the operation to stop timed out", e.getAgentId(), e); } catch (final ConcurrentOperationException e) { throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e); } }
@Override public void expunge(final String vmUuid) throws ResourceUnavailableException { try { advanceExpunge(vmUuid); } catch (final OperationTimedoutException e) { throw new CloudRuntimeException("Operation timed out", e); } catch (final ConcurrentOperationException e) { throw new CloudRuntimeException("Concurrent operation ", e); } }
@Override public void start(final String vmUuid, final Map<VirtualMachineProfile.Param, Object> params, final DeploymentPlan planToDeploy, final DeploymentPlanner planner) { try { advanceStart(vmUuid, params, planToDeploy, planner); } catch (final ConcurrentOperationException e) { throw new CloudRuntimeException("Unable to start a VM due to concurrent operation", e).add(VirtualMachine.class, vmUuid); } catch (final InsufficientCapacityException e) { throw new CloudRuntimeException("Unable to start a VM due to insufficient capacity", e).add(VirtualMachine.class, vmUuid); } catch (final ResourceUnavailableException e) { if(e.getScope() != null && e.getScope().equals(VirtualRouter.class)){ throw new CloudRuntimeException("Network is unavailable. Please contact administrator", e).add(VirtualMachine.class, vmUuid); } throw new CloudRuntimeException("Unable to start a VM due to unavailable resources", e).add(VirtualMachine.class, vmUuid); } }