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