Search in sources :

Example 1 with SubjectEntity

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

the class JobSubjectEntityDaoImpl method getJobSubjectEntityByJobId.

@Override
public Map<Guid, VdcObjectType> getJobSubjectEntityByJobId(Guid jobId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("job_id", jobId);
    List<SubjectEntity> list = getCallsHandler().executeReadList("GetJobSubjectEntityByJobId", jobSubjectEntityRowMapper, parameterSource);
    Map<Guid, VdcObjectType> entityMap = new HashMap<>();
    for (SubjectEntity jobSubjectEntity : list) {
        entityMap.put(jobSubjectEntity.getEntityId(), jobSubjectEntity.getEntityType());
    }
    return entityMap;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) SubjectEntity(org.ovirt.engine.core.common.businessentities.SubjectEntity) HashMap(java.util.HashMap) Guid(org.ovirt.engine.core.compat.Guid) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType)

Example 2 with SubjectEntity

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

the class StepMapper method mapStepSubjectEntities.

private static void mapStepSubjectEntities(org.ovirt.engine.core.common.job.Step entity, Step model) {
    if (entity.getSubjectEntities() != null) {
        for (SubjectEntity subjectEntity : entity.getSubjectEntities()) {
            if (subjectEntity.getEntityType() == VdcObjectType.EXECUTION_HOST) {
                model.setExecutionHost(new Host());
                model.getExecutionHost().setId(subjectEntity.getEntityId().toString());
                break;
            }
        }
    }
}
Also used : SubjectEntity(org.ovirt.engine.core.common.businessentities.SubjectEntity) Host(org.ovirt.engine.api.model.Host)

Example 3 with SubjectEntity

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

the class StepDaoTest method startedStepsByStepSubjectEntityOtherStatuses.

@Test
public void startedStepsByStepSubjectEntityOtherStatuses() {
    StepSubjectEntity subjectEntity = prepareStartedStepsByStepSubjectEntityTest();
    Step step = dao.get(FixturesTool.STEP_ID);
    Arrays.stream(JobExecutionStatus.values()).filter(status -> status != JobExecutionStatus.STARTED).forEach(status -> {
        step.setStatus(status);
        dao.update(step);
        assertNoStartedStepsForSubjectEntity(subjectEntity);
    });
}
Also used : BaseDisk(org.ovirt.engine.core.common.businessentities.storage.BaseDisk) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) Arrays(java.util.Arrays) StepEnum(org.ovirt.engine.core.common.job.StepEnum) Assert.assertNotNull(org.junit.Assert.assertNotNull) Date(java.util.Date) Guid(org.ovirt.engine.core.compat.Guid) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) ExternalSystemType(org.ovirt.engine.core.common.job.ExternalSystemType) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) Assert.assertThat(org.junit.Assert.assertThat) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.emptyCollectionOf(org.hamcrest.Matchers.emptyCollectionOf) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) SubjectEntity(org.ovirt.engine.core.common.businessentities.SubjectEntity) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Step(org.ovirt.engine.core.common.job.Step) Step(org.ovirt.engine.core.common.job.Step) StepSubjectEntity(org.ovirt.engine.core.common.job.StepSubjectEntity) Test(org.junit.Test)

Example 4 with SubjectEntity

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

the class MaintenanceNumberOfVdssCommand method validateNoRunningJobs.

private boolean validateNoRunningJobs(VDS vds) {
    List<Step> steps = stepDao.getStartedStepsByStepSubjectEntity(new SubjectEntity(VdcObjectType.EXECUTION_HOST, vds.getId()));
    if (!steps.isEmpty()) {
        List<String> replacements = new ArrayList<>(2);
        replacements.add(ReplacementUtils.createSetVariableString("host", vds.getName()));
        replacements.addAll(ReplacementUtils.replaceWith("jobs", steps.stream().map(s -> s.getDescription()).collect(Collectors.toList())));
        return failValidation(EngineMessage.VDS_CANNOT_MAINTENANCE_HOST_WITH_RUNNING_OPERATIONS, replacements);
    }
    return true;
}
Also used : SetVdsStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SetVdsStatusVDSCommandParameters) ClusterDao(org.ovirt.engine.core.dao.ClusterDao) StringUtils(org.apache.commons.lang.StringUtils) AsyncTaskDao(org.ovirt.engine.core.dao.AsyncTaskDao) StepDao(org.ovirt.engine.core.dao.StepDao) CancelMigrationVDSParameters(org.ovirt.engine.core.vdsbroker.vdsbroker.CancelMigrationVDSParameters) VmDynamicDao(org.ovirt.engine.core.dao.VmDynamicDao) AsyncTask(org.ovirt.engine.core.common.businessentities.AsyncTask) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) HostedEngineHelper(org.ovirt.engine.core.bll.hostedengine.HostedEngineHelper) ActionType(org.ovirt.engine.core.common.action.ActionType) VdsDao(org.ovirt.engine.core.dao.VdsDao) Map(java.util.Map) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) MaintenanceVdsParameters(org.ovirt.engine.core.common.action.MaintenanceVdsParameters) Set(java.util.Set) NetworkDao(org.ovirt.engine.core.dao.network.NetworkDao) Collectors(java.util.stream.Collectors) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) VmDao(org.ovirt.engine.core.dao.VmDao) VdsDynamicDao(org.ovirt.engine.core.dao.VdsDynamicDao) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) SubjectEntity(org.ovirt.engine.core.common.businessentities.SubjectEntity) Guid(org.ovirt.engine.core.compat.Guid) ReplacementUtils(org.ovirt.engine.core.utils.ReplacementUtils) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ExecutionHandler(org.ovirt.engine.core.bll.job.ExecutionHandler) AffinityGroupDao(org.ovirt.engine.core.dao.scheduling.AffinityGroupDao) NetworkClusterHelper(org.ovirt.engine.core.bll.network.cluster.NetworkClusterHelper) Network(org.ovirt.engine.core.common.businessentities.network.Network) Pair(org.ovirt.engine.core.common.utils.Pair) LockingGroup(org.ovirt.engine.core.common.locks.LockingGroup) Iterator(java.util.Iterator) MultipleVmsValidator(org.ovirt.engine.core.bll.validator.MultipleVmsValidator) VM(org.ovirt.engine.core.common.businessentities.VM) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) ImageTransfer(org.ovirt.engine.core.common.businessentities.storage.ImageTransfer) VDSCommandType(org.ovirt.engine.core.common.vdscommands.VDSCommandType) GlusterHostValidator(org.ovirt.engine.core.bll.gluster.GlusterHostValidator) MigrationSupport(org.ovirt.engine.core.common.businessentities.MigrationSupport) ImageTransferDao(org.ovirt.engine.core.dao.ImageTransferDao) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) MaintenanceNumberOfVdssParameters(org.ovirt.engine.core.common.action.MaintenanceNumberOfVdssParameters) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) Step(org.ovirt.engine.core.common.job.Step) SubjectEntity(org.ovirt.engine.core.common.businessentities.SubjectEntity) ArrayList(java.util.ArrayList) Step(org.ovirt.engine.core.common.job.Step)

Aggregations

SubjectEntity (org.ovirt.engine.core.common.businessentities.SubjectEntity)4 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)3 Guid (org.ovirt.engine.core.compat.Guid)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Step (org.ovirt.engine.core.common.job.Step)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang.StringUtils)1 Matchers.emptyCollectionOf (org.hamcrest.Matchers.emptyCollectionOf)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1