protected void startNsVpx(VMInstanceVO nsVpx, Map<Param, Object> params) throws StorageUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { s_logger.debug("Starting NS Vpx " + nsVpx); _itMgr.start(nsVpx.getUuid(), params, null, null); }
public Integer compareVirtualMachine(VMInstanceVO dbVm, VirtualMachine vncVm, StringBuffer syncLogMesg) { String dbVmId = dbVm.getUuid(); String vncVmId = vncVm.getUuid(); return dbVmId.compareTo(vncVmId); }
private void preStorageMigrationStateCheck(StoragePool destPool, VMInstanceVO vm) { if (destPool == null) { throw new CloudRuntimeException("Unable to migrate vm: missing destination storage pool"); } checkDestinationForTags(destPool, vm); try { stateTransitTo(vm, Event.StorageMigrationRequested, null); } catch (final NoTransitionException e) { String msg = String.format("Unable to migrate vm: %s", vm.getUuid()); s_logger.debug(msg); throw new CloudRuntimeException(msg, e); } }
public void createVirtualMachine(VMInstanceVO dbVm, StringBuffer syncLogMesg) throws IOException { syncLogMesg.append("VM# DB: " + dbVm.getInstanceName() + "/" + dbVm.getUuid() + "; VNC: none; action: create\n"); VirtualMachineModel vmModel = new VirtualMachineModel(dbVm, dbVm.getUuid()); vmModel.build(_manager.getModelController(), dbVm); buildNicResources(vmModel, dbVm, syncLogMesg); if (_rwMode) { try { vmModel.update(_manager.getModelController()); } catch (InternalErrorException ex) { s_logger.warn("create virtual-machine", ex); return; } _manager.getDatabase().getVirtualMachines().add(vmModel); syncLogMesg.append("VM# VNC: " + dbVm.getUuid() + " created\n"); } }
private SecondaryStorageVmVO stopSecondaryStorageVm(final VMInstanceVO systemVm, final boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { _itMgr.advanceStop(systemVm.getUuid(), isForced); return _secStorageVmDao.findById(systemVm.getId()); }
@Override public boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller, boolean expunge) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException { VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid()); _itMgr.destroy(vm.getUuid(), expunge); return true; }
private ConsoleProxyVO stopConsoleProxy(final VMInstanceVO systemVm, final boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { _itMgr.advanceStop(systemVm.getUuid(), isForced); return _consoleProxyDao.findById(systemVm.getId()); }
private boolean doDisableAccount(long accountId) throws ConcurrentOperationException, ResourceUnavailableException { List<VMInstanceVO> vms = _vmDao.listByAccountId(accountId); boolean success = true; for (VMInstanceVO vm : vms) { try { try { _itMgr.advanceStop(vm.getUuid(), false); } catch (OperationTimedoutException ote) { s_logger.warn("Operation for stopping vm timed out, unable to stop vm " + vm.getHostName(), ote); success = false; } } catch (AgentUnavailableException aue) { s_logger.warn("Agent running on host " + vm.getHostId() + " is unavailable, unable to stop vm " + vm.getHostName(), aue); success = false; } } return success; }
protected List<Long> getAffectedVmsForVmStart(VMInstanceVO vm) { List<Long> affectedVms = new ArrayList<Long>(); affectedVms.add(vm.getId()); List<SecurityGroupVMMapVO> groupsForVm = _securityGroupVMMapDao.listByInstanceId(vm.getId()); // For each group, find the security rules that allow the group for (SecurityGroupVMMapVO mapVO : groupsForVm) {// FIXME: use custom sql in the dao //Add usage events for security group assign UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SECURITY_GROUP_ASSIGN, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), mapVO.getSecurityGroupId(), vm .getClass().getName(), vm.getUuid()); List<SecurityGroupRuleVO> allowingRules = _securityGroupRuleDao.listByAllowedSecurityGroupId(mapVO.getSecurityGroupId()); // For each security rule that allows a group that the vm belongs to, find the group it belongs to affectedVms.addAll(getAffectedVmsForSecurityRules(allowingRules)); } return affectedVms; }
protected List<Long> getAffectedVmsForVmStop(VMInstanceVO vm) { List<Long> affectedVms = new ArrayList<Long>(); List<SecurityGroupVMMapVO> groupsForVm = _securityGroupVMMapDao.listByInstanceId(vm.getId()); // For each group, find the security rules rules that allow the group for (SecurityGroupVMMapVO mapVO : groupsForVm) {// FIXME: use custom sql in the dao //Add usage events for security group remove UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SECURITY_GROUP_REMOVE, vm.getAccountId(), vm.getDataCenterId(), vm.getId(), mapVO.getSecurityGroupId(), vm .getClass().getName(), vm.getUuid()); List<SecurityGroupRuleVO> allowingRules = _securityGroupRuleDao.listByAllowedSecurityGroupId(mapVO.getSecurityGroupId()); // For each security rule that allows a group that the vm belongs to, find the group it belongs to affectedVms.addAll(getAffectedVmsForSecurityRules(allowingRules)); } return affectedVms; }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateMigrateAway(final VmWorkMigrateAway work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; try { orchestrateMigrateAway(vm.getUuid(), work.getSrcHostId(), null); } catch (final InsufficientServerCapacityException e) { s_logger.warn("Failed to deploy vm " + vm.getId() + " with original planner, sending HAPlanner"); orchestrateMigrateAway(vm.getUuid(), work.getSrcHostId(), _haMgr.getHAPlanner()); } return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateReboot(final VmWorkReboot work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; orchestrateReboot(vm.getUuid(), work.getParams()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateMigrate(final VmWorkMigrate work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; orchestrateMigrate(vm.getUuid(), work.getSrcHostId(), work.getDeployDestination()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateStorageMigration(final VmWorkStorageMigration work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; final StoragePool pool = (PrimaryDataStoreInfo)dataStoreMgr.getPrimaryDataStore(work.getDestStoragePoolId()); orchestrateStorageMigration(vm.getUuid(), pool); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateStop(final VmWorkStop work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); throw new CloudRuntimeException("Unable to find VM id=" + work.getVmId()); } orchestrateStop(vm.getUuid(), work.isCleanup()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateMigrateWithStorage(final VmWorkMigrateWithStorage work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; orchestrateMigrateWithStorage(vm.getUuid(), work.getSrcHostId(), work.getDestHostId(), work.getVolumeToPool()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateMigrateForScale(final VmWorkMigrateForScale work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; orchestrateMigrateForScale(vm.getUuid(), work.getSrcHostId(), work.getDeployDestination(), work.getNewServiceOfferringId()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateReconfigure(final VmWorkReconfigure work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; final ServiceOffering newServiceOffering = _offeringDao.findById(vm.getId(), work.getNewServiceOfferingId()); reConfigureVm(vm.getUuid(), newServiceOffering, work.isSameHost()); return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }
@ReflectionUse private Pair<JobInfo.Status, String> orchestrateStart(final VmWorkStart work) throws Exception { final VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, work.getVmId()); if (vm == null) { s_logger.info("Unable to find vm " + work.getVmId()); } assert vm != null; try{ orchestrateStart(vm.getUuid(), work.getParams(), work.getPlan(), _dpMgr.getDeploymentPlannerByName(work.getDeploymentPlanner())); } catch (CloudRuntimeException e){ e.printStackTrace(); s_logger.info("Caught CloudRuntimeException, returning job failed " + e); CloudRuntimeException ex = new CloudRuntimeException("Unable to start VM instance"); return new Pair<JobInfo.Status, String>(JobInfo.Status.FAILED, JobSerializerHelper.toObjectSerializedString(ex)); } return new Pair<JobInfo.Status, String>(JobInfo.Status.SUCCEEDED, null); }