Search in sources :

Example 1 with CommandEntity

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

the class HostUpgradeCallback method isMaintenanceCommandExecuted.

private boolean isMaintenanceCommandExecuted(List<Guid> childCmdIds) {
    Guid maintenanceCommandId = getMaintenanceCmdId(childCmdIds);
    CommandEntity maintenanceCmd = commandCoordinatorUtil.getCommandEntity(maintenanceCommandId);
    return maintenanceCmd != null && maintenanceCmd.isExecuted();
}
Also used : CommandEntity(org.ovirt.engine.core.common.businessentities.CommandEntity) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with CommandEntity

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

the class CommandEntityDaoTest method testRemove.

@Test
public void testRemove() {
    CommandEntity cmd = dbFacade.getCommandEntityDao().get(getExistingEntityId());
    assertNotNull(cmd);
    dbFacade.getCommandEntityDao().remove(getExistingEntityId());
    CommandEntity cmdAfterRemoval = dbFacade.getCommandEntityDao().get(getExistingEntityId());
    assertNull(cmdAfterRemoval);
}
Also used : CommandEntity(org.ovirt.engine.core.common.businessentities.CommandEntity) Test(org.junit.Test)

Example 3 with CommandEntity

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

the class CommandEntityDaoTest method testGetAllInsertAsyncTaskEntitities.

@Test
public void testGetAllInsertAsyncTaskEntitities() {
    CommandEntity cmdEntity = generateNewEntity();
    dao.save(cmdEntity);
    Set<CommandAssociatedEntity> cocoCmdEntities = new HashSet<>();
    cocoCmdEntities.add(new CommandAssociatedEntity(cmdEntity.getId(), VdcObjectType.Storage, Guid.newGuid()));
    cocoCmdEntities.add(new CommandAssociatedEntity(cmdEntity.getId(), VdcObjectType.Disk, Guid.newGuid()));
    dao.insertCommandAssociatedEntities(cocoCmdEntities);
    List<CommandAssociatedEntity> entities = dao.getAllCommandAssociatedEntities(cmdEntity.getId());
    assertNotNull(entities);
    assertEquals(2, entities.size());
    assertThat(entities, hasItems(cocoCmdEntities.toArray(new CommandAssociatedEntity[cocoCmdEntities.size()])));
}
Also used : CommandAssociatedEntity(org.ovirt.engine.core.common.businessentities.CommandAssociatedEntity) CommandEntity(org.ovirt.engine.core.common.businessentities.CommandEntity) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with CommandEntity

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

the class CommandBase method setCommandExecuted.

public void setCommandExecuted() {
    Transaction transaction = TransactionSupport.suspend();
    try {
        CommandEntity cmdEntity = commandCoordinatorUtil.getCommandEntity(getCommandId());
        if (cmdEntity != null) {
            CommandEntity executedCmdEntity = buildCommandEntity(cmdEntity.getRootCommandId(), cmdEntity.isCallbackEnabled());
            executedCmdEntity.setWaitingForEvent(cmdEntity.isCallbackEnabled() ? callbackTriggeredByEvent() : false);
            commandCoordinatorUtil.persistCommand(executedCmdEntity, getContext());
            commandCoordinatorUtil.updateCommandExecuted(getCommandId());
        }
    } finally {
        if (transaction != null) {
            TransactionSupport.resume(transaction);
        }
    }
}
Also used : Transaction(javax.transaction.Transaction) CommandEntity(org.ovirt.engine.core.common.businessentities.CommandEntity)

Example 5 with CommandEntity

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

the class CommandBase method persistCommand.

public void persistCommand(ActionType parentCommand, CommandContext cmdContext, boolean enableCallback, boolean callbackWaitingForEvent) {
    Transaction transaction = TransactionSupport.suspend();
    try {
        CommandEntity commandEntity = buildCommandEntity(getParentParameters(parentCommand).getCommandId(), enableCallback);
        commandEntity.setWaitingForEvent(callbackWaitingForEvent);
        commandCoordinatorUtil.persistCommand(commandEntity, cmdContext);
    } finally {
        if (transaction != null) {
            TransactionSupport.resume(transaction);
        }
    }
}
Also used : Transaction(javax.transaction.Transaction) CommandEntity(org.ovirt.engine.core.common.businessentities.CommandEntity)

Aggregations

CommandEntity (org.ovirt.engine.core.common.businessentities.CommandEntity)25 Guid (org.ovirt.engine.core.compat.Guid)7 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Transaction (javax.transaction.Transaction)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 CommandAssociatedEntity (org.ovirt.engine.core.common.businessentities.CommandAssociatedEntity)2 Serializable (java.io.Serializable)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 CommandCallback (org.ovirt.engine.core.bll.tasks.interfaces.CommandCallback)1 HostJobCommandParameters (org.ovirt.engine.core.common.action.HostJobCommandParameters)1 AsyncTask (org.ovirt.engine.core.common.businessentities.AsyncTask)1 HostJobInfo (org.ovirt.engine.core.common.businessentities.HostJobInfo)1 HostJobStatus (org.ovirt.engine.core.common.businessentities.HostJobInfo.HostJobStatus)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 CommandStatus (org.ovirt.engine.core.compat.CommandStatus)1