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);
}
}
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);
}
}
}
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));
}
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");
}
}
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);
}
Aggregations