Search in sources :

Example 31 with VmDynamic

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

the class VmDynamicDaoTest method testUpdateAll.

@Test
public void testUpdateAll() throws Exception {
    VmDynamic existingVm2 = dao.get(FixturesTool.VM_RHEL5_POOL_51);
    existingEntity.setStatus(VMStatus.Down);
    existingVm2.setIp("111");
    existingVm2.setFqdn("localhost.localdomain");
    dao.updateAll(Arrays.asList(existingEntity, existingVm2));
    assertEquals(existingEntity, dao.get(existingEntity.getId()));
    assertEquals(existingVm2, dao.get(existingVm2.getId()));
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) Test(org.junit.Test)

Example 32 with VmDynamic

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

the class VmDynamicDaoTest method generateNewEntity.

/**
 * Test the {@link VmDynamicDao#save(BusinessEntity)} method by adding a vm_dynamic record to a template.
 * While this doesn't make any sense from a business logic perspective, it's perfectly legal from a database
 * perspective, and helps avoid dependencies on the {@link VmDynamicDao#remove(Guid)} method.
 */
@Override
protected VmDynamic generateNewEntity() {
    VmDynamic newEntity = new VmDynamic();
    newEntity.setId(FixturesTool.VM_TEMPLATE_RHEL5);
    newEntity.setStatus(VMStatus.NotResponding);
    return newEntity;
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic)

Example 33 with VmDynamic

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

the class VdsDaoTest method setupHostedEngineTests.

private void setupHostedEngineTests(boolean isHostedEngineVm, int vmCount) {
    // create the VmStatic instance
    VmStatic vmStatic = new VmStatic();
    vmStatic.setId(newVmId);
    vmStatic.setOrigin(isHostedEngineVm ? OriginType.MANAGED_HOSTED_ENGINE : OriginType.RHEV);
    dbFacade.getVmStaticDao().save(vmStatic);
    // create the VmDynamic instance
    VmDynamic vmDynamic = new VmDynamic();
    vmDynamic.setId(newVmId);
    vmDynamic.setStatus(VMStatus.Up);
    vmDynamic.setRunOnVds(existingVds.getId());
    dbFacade.getVmDynamicDao().save(vmDynamic);
    // update the VDS instance
    existingVds.setVmCount(vmCount);
    dbFacade.getVdsDynamicDao().update(existingVds.getDynamicData());
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic)

Example 34 with VmDynamic

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

the class SetVmStatusVDSCommand method executeVDSCommand.

@Override
protected void executeVDSCommand() {
    VmDynamic vmDynamic = vmDynamicDao.get(getParameters().getVmId());
    resourceManager.removeAsyncRunningVm(getParameters().getVmId());
    resourceManager.internalSetVmStatus(vmDynamic, getParameters().getStatus(), getParameters().getExitStatus());
    resourceManager.getVmManager(getParameters().getVmId()).update(new VmStatistics(getParameters().getVmId()));
    // TODO: update network statistics
    resourceManager.getVmManager(getParameters().getVmId()).update(vmDynamic);
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VmStatistics(org.ovirt.engine.core.common.businessentities.VmStatistics)

Example 35 with VmDynamic

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

the class HibernateVDSCommand method executeVmCommand.

@Override
protected void executeVmCommand() {
    VDSReturnValue vdsReturnValue = resourceManager.runVdsCommand(VDSCommandType.HibernateBroker, getParameters());
    if (vdsReturnValue.getSucceeded()) {
        VmDynamic vmDynamic = vmDynamicDao.get(getParameters().getVmId());
        vmDynamic.setStatus(VMStatus.SavingState);
        vmManager.update(vmDynamic);
    } else {
        log.error("Failed to hibernate VM '{}' in VDS = '{}' : error = '{}'", getParameters().getVmId(), getParameters().getVdsId(), vdsReturnValue.getExceptionString());
        getVDSReturnValue().setSucceeded(false);
        getVDSReturnValue().setExceptionString(vdsReturnValue.getExceptionString());
        getVDSReturnValue().setExceptionObject(vdsReturnValue.getExceptionObject());
        getVDSReturnValue().setVdsError(vdsReturnValue.getVdsError());
    }
}
Also used : VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)54 Test (org.junit.Test)13 Guid (org.ovirt.engine.core.compat.Guid)12 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)8 VM (org.ovirt.engine.core.common.businessentities.VM)7 VmStatistics (org.ovirt.engine.core.common.businessentities.VmStatistics)6 Vm (org.ovirt.engine.api.model.Vm)4 Date (java.util.Date)3 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)2 VdsmVm (org.ovirt.engine.core.vdsbroker.monitoring.VdsmVm)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Set (java.util.Set)1