Search in sources :

Example 6 with VmPool

use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.

the class RemoveVmPoolCommand method setPrestartedToZero.

private void setPrestartedToZero() {
    VmPool vmPool = getVmPool();
    if (vmPool.getPrestartedVms() > 0) {
        vmPool.setPrestartedVms(0);
        vmPoolDao.update(vmPool);
    }
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool)

Example 7 with VmPool

use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.

the class RemoveVmPoolCommandCallback method childCommandsExecutionEnded.

@Override
protected void childCommandsExecutionEnded(CommandBase<?> command, boolean anyFailed, List<Guid> childCmdIds, CommandExecutionStatus status, int completedChildren) {
    if (anyFailed) {
        setCommandEndStatus(command, true, status, childCmdIds);
    } else {
        RemoveVmPoolCommand<? extends VmPoolParametersBase> removeVmPoolCommand = (RemoveVmPoolCommand<? extends VmPoolParametersBase>) command;
        VmPool pool = DbFacade.getInstance().getVmPoolDao().get(removeVmPoolCommand.getVmPoolId());
        if (pool == null || pool.getRunningVmsCount() == 0) {
            setCommandEndStatus(command, false, status, childCmdIds);
        }
    }
}
Also used : VmPoolParametersBase(org.ovirt.engine.core.common.action.VmPoolParametersBase) VmPool(org.ovirt.engine.core.common.businessentities.VmPool)

Example 8 with VmPool

use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.

the class EntityDaoImplTest method testGetEntityNameByIdAndTypeForVmPool.

@Test
public void testGetEntityNameByIdAndTypeForVmPool() {
    VmPool vmPool = vmPoolDao.get(VM_POOL_ID);
    assertNotNull(vmPool);
    String name = vmPool.getName();
    assertEquals(name, underTest.getEntityNameByIdAndType(VM_POOL_ID, VdcObjectType.VmPool));
}
Also used : VmPool(org.ovirt.engine.core.common.businessentities.VmPool) Test(org.junit.Test)

Example 9 with VmPool

use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.

the class VmPoolMonitor method prestartVms.

/**
 * Prestarts the given amount of VMs in the given VM Pool.
 */
private void prestartVms(VmPool vmPool, int numOfVmsToPrestart) {
    int failedAttempts = 0;
    int prestartedVms = 0;
    int maxFailedAttempts = Config.<Integer>getValue(ConfigValues.VmPoolMonitorMaxAttempts);
    Map<String, Set<Guid>> failureReasons = new HashMap<>();
    Iterator<Guid> iterator = vmPoolHandler.selectNonPrestartedVms(vmPool.getVmPoolId(), (vmId, messages) -> collectVmPrestartFailureReasons(vmId, failureReasons, messages)).iterator();
    while (failedAttempts < maxFailedAttempts && prestartedVms < numOfVmsToPrestart && iterator.hasNext()) {
        Guid vmId = iterator.next();
        if (prestartVm(vmId, !vmPool.isStateful(), vmPool.getName())) {
            prestartedVms++;
            failedAttempts = 0;
        } else {
            failedAttempts++;
        }
    }
    logResultOfPrestartVms(prestartedVms, numOfVmsToPrestart, vmPool.getVmPoolId(), failureReasons);
    if (prestartedVms == 0) {
        log.info("No VMs available for prestarting");
    }
}
Also used : ScheduledFuture(java.util.concurrent.ScheduledFuture) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Guid(org.ovirt.engine.core.compat.Guid) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) Singleton(javax.inject.Singleton) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ThreadPools(org.ovirt.engine.core.utils.threadpool.ThreadPools) VmStaticDao(org.ovirt.engine.core.dao.VmStaticDao) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ActionType(org.ovirt.engine.core.common.action.ActionType) ExecutionHandler(org.ovirt.engine.core.bll.job.ExecutionHandler) Map(java.util.Map) BackendService(org.ovirt.engine.core.common.BackendService) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) ManagedScheduledExecutorService(javax.enterprise.concurrent.ManagedScheduledExecutorService) Config(org.ovirt.engine.core.common.config.Config) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) VmPoolDao(org.ovirt.engine.core.dao.VmPoolDao) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) AuditLogDirector(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) Set(java.util.Set) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) Collectors(java.util.stream.Collectors) RunVmParams(org.ovirt.engine.core.common.action.RunVmParams) VmDao(org.ovirt.engine.core.dao.VmDao) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) VM(org.ovirt.engine.core.common.businessentities.VM) Injector(org.ovirt.engine.core.di.Injector) PostConstruct(javax.annotation.PostConstruct) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid)

Example 10 with VmPool

use of org.ovirt.engine.core.common.businessentities.VmPool in project ovirt-engine by oVirt.

the class GetVmDataByPoolNameQuery method executeQueryCommand.

@Override
protected void executeQueryCommand() {
    VM vm = null;
    VmPool vmpool = vmPoolDao.getByName(getParameters().getName());
    if (vmpool != null) {
        QueryReturnValue getVmRet = backend.runInternalQuery(QueryType.GetVmDataByPoolId, new IdQueryParameters(vmpool.getVmPoolId()));
        if (getVmRet != null) {
            vm = getVmRet.getReturnValue();
        }
    }
    getQueryReturnValue().setReturnValue(vm);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VmPool(org.ovirt.engine.core.common.businessentities.VmPool) VM(org.ovirt.engine.core.common.businessentities.VM)

Aggregations

VmPool (org.ovirt.engine.core.common.businessentities.VmPool)32 Test (org.junit.Test)12 VM (org.ovirt.engine.core.common.businessentities.VM)9 ArrayList (java.util.ArrayList)8 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)7 Guid (org.ovirt.engine.core.compat.Guid)7 QueryType (org.ovirt.engine.core.common.queries.QueryType)6 List (java.util.List)5 Frontend (org.ovirt.engine.ui.frontend.Frontend)5 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)5 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)5 ActionType (org.ovirt.engine.core.common.action.ActionType)4 VmPoolParametersBase (org.ovirt.engine.core.common.action.VmPoolParametersBase)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 AddVmPoolParameters (org.ovirt.engine.core.common.action.AddVmPoolParameters)3 VmPoolType (org.ovirt.engine.core.common.businessentities.VmPoolType)3 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)3 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)3 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)3