Search in sources :

Example 1 with VdsSpmIdMap

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

the class JsonObjectSerializationEntitiesTest method data.

@Parameterized.Parameters
public static Object[] data() {
    RandomUtils random = RandomUtils.instance();
    VdsStatic vdsStatic = new VdsStatic(random.nextString(10), random.nextString(10), random.nextInt(), random.nextInt(), random.nextString(10), Guid.newGuid(), Guid.newGuid(), random.nextString(10), random.nextBoolean(), random.nextEnum(VDSType.class), Guid.newGuid());
    return new Object[] { vdsStatic, randomVdsDynamic(), randomVdsStatistics(), new VdsSpmIdMap(Guid.newGuid(), Guid.newGuid(), random.nextInt()), randomStorageDomainStatic(), new StorageDomainDynamic(random.nextInt(), Guid.newGuid(), random.nextInt()), randomStoragePool(), new StoragePoolIsoMap(Guid.newGuid(), Guid.newGuid(), random.nextEnum(StorageDomainStatus.class)), randomRole(), new IdContainerClass<>(new VdsSpmIdMap(Guid.newGuid(), Guid.newGuid(), random.nextInt())), new IdContainerClass<>(Guid.newGuid()) };
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) RandomUtils(org.ovirt.engine.core.utils.RandomUtils) VDSType(org.ovirt.engine.core.common.businessentities.VDSType) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) StorageDomainDynamic(org.ovirt.engine.core.common.businessentities.StorageDomainDynamic) StorageDomainStatus(org.ovirt.engine.core.common.businessentities.StorageDomainStatus)

Example 2 with VdsSpmIdMap

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

the class AddVdsSpmIdCommandTest method insertSpmIdToDb.

private void insertSpmIdToDb(int expected, int... given) {
    List<VdsSpmIdMap> list = Arrays.stream(given).mapToObj(i -> new VdsSpmIdMap(spId, vdsId, i)).collect(Collectors.toList());
    cmd.insertSpmIdToDb(list);
    verify(vdsSpmIdMapDao).save(new VdsSpmIdMap(spId, vdsId, expected));
}
Also used : InjectMocks(org.mockito.InjectMocks) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Arrays(java.util.Arrays) Mock(org.mockito.Mock) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsSpmIdMapDao(org.ovirt.engine.core.dao.VdsSpmIdMapDao) Before(org.junit.Before) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap)

Example 3 with VdsSpmIdMap

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

the class VdsSpmIdMapDaoTest method testGetVdsSpmIdMapForStoragePoolAndVdsId.

@Test
public void testGetVdsSpmIdMapForStoragePoolAndVdsId() {
    VdsSpmIdMap result = dao.get(existingEntity.getStoragePoolId(), existingEntity.getVdsSpmId());
    assertNotNull(result);
    assertEquals(existingEntity, result);
}
Also used : VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Test(org.junit.Test)

Example 4 with VdsSpmIdMap

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

the class IrsProxy method handleSpmStatusResult.

private SpmStatusResult handleSpmStatusResult(Guid curVdsId, List<VDS> vdsByPool, final StoragePool storagePool, RefObject<VDS> selectedVds, SpmStatusResult spmStatus) {
    if (spmStatus.getSpmStatus() == SpmStatus.Free) {
        int vdsSpmIdToFence = -1;
        boolean startSpm = true;
        if (spmStatus.getSpmId() != -1 && !wasVdsManuallyFenced(spmStatus.getSpmId())) {
            int spmId = spmStatus.getSpmId();
            Guid spmVdsId = Guid.Empty;
            VDS spmVds = null;
            if (selectedVds.argvalue.getVdsSpmId() == spmId) {
                spmVdsId = selectedVds.argvalue.getId();
            } else {
                for (VDS tempVds : vdsByPool) {
                    if (tempVds.getVdsSpmId() == spmId) {
                        log.info("Found spm host '{}', host name: '{}', according to spmId: '{}'.", tempVds.getId(), tempVds.getName(), spmId);
                        spmVds = tempVds;
                        break;
                    }
                }
                // non operational we want to find it as well
                if (spmVds == null) {
                    List<VDS> nonOperationalVds = vdsDao.getAllForStoragePoolAndStatus(storagePoolId, VDSStatus.NonOperational);
                    for (VDS tempVds : nonOperationalVds) {
                        if (tempVds.getVdsSpmId() == spmId) {
                            spmVds = tempVds;
                            break;
                        }
                    }
                }
                if (spmVds != null) {
                    spmVdsId = spmVds.getId();
                } else if (!curVdsId.equals(Guid.Empty)) {
                    VDS currentVds = vdsDao.get(curVdsId);
                    if (currentVds != null && currentVds.getStatus() == VDSStatus.Up && currentVds.getVdsSpmId() != null && currentVds.getVdsSpmId().equals(spmId)) {
                        spmVdsId = curVdsId;
                        spmVds = currentVds;
                    }
                }
            }
            try {
                if (!spmVdsId.equals(Guid.Empty)) {
                    SpmStatusResult destSpmStatus = (SpmStatusResult) resourceManager.runVdsCommand(VDSCommandType.SpmStatus, new SpmStatusVDSCommandParameters(spmVdsId, storagePoolId)).getReturnValue();
                    log.info("SpmStatus on vds '{}': '{}'", spmVdsId, destSpmStatus == null ? "NULL" : destSpmStatus.getSpmStatus());
                    // intentionally unreachable code
                    if (destSpmStatus != null && destSpmStatus.getSpmStatus() == SpmStatus.SPM) {
                        if (!spmVdsId.equals(selectedVds.argvalue.getId()) && spmVds != null && spmVds.getStatus() == VDSStatus.Up) {
                            selectedVds.argvalue = spmVds;
                            startSpm = false;
                            log.info("Using old spm server: '{}', no start needed", spmVds.getName());
                            return destSpmStatus;
                        } else // VDS is non-operational and SPM
                        {
                            log.warn("Host reports to be SPM '{}', but is not up.", spmVdsId);
                            vdsSpmIdToFence = spmStatus.getSpmId();
                        }
                    } else // it is not SPM and continue.
                    if (destSpmStatus == null || (destSpmStatus.getSpmStatus() != SpmStatus.Free && destSpmStatus.getSpmStatus() != SpmStatus.Unknown_Pool)) {
                        vdsSpmIdToFence = spmStatus.getSpmId();
                    }
                } else {
                    log.error("SPM Init: could not find reported vds or not up - pool: '{}' vds_spm_id: '{}'", storagePool.getName(), spmStatus.getSpmId());
                    vdsSpmIdToFence = spmStatus.getSpmId();
                }
            } catch (Exception ex) {
                vdsSpmIdToFence = spmStatus.getSpmId();
            }
        }
        if (startSpm) {
            VdsSpmIdMap map = vdsSpmIdMapDao.get(storagePoolId, vdsSpmIdToFence);
            if (map != null) {
                VDS vdsToFenceObject = vdsDao.get(map.getId());
                if (vdsToFenceObject != null) {
                    log.info("SPM selection - vds seems as spm '{}'", vdsToFenceObject.getName());
                    if (vdsToFenceObject.getStatus() == VDSStatus.NonResponsive) {
                        log.warn("spm vds is non responsive, stopping spm selection.");
                        selectedVds.argvalue = null;
                        return spmStatus;
                    } else {
                        // try to stop spm
                        VDSReturnValue spmStopReturnValue = resourceManager.runVdsCommand(VDSCommandType.SpmStop, new SpmStopVDSCommandParameters(vdsToFenceObject.getId(), storagePoolId));
                        // continue with spm selection
                        if (spmStopReturnValue != null && spmStopReturnValue.getSucceeded()) {
                            log.info("spm stop succeeded, continuing with spm selection");
                        } else // if spm stop failed for any reason we stop spm
                        // selection
                        {
                            log.warn("spm stop on spm failed, stopping spm selection!");
                            selectedVds.argvalue = null;
                            return spmStatus;
                        }
                    }
                }
            }
            spmStatus = startSpm(storagePool, selectedVds.argvalue, spmStatus.getSpmId(), spmStatus.getSpmLVER(), vdsSpmIdToFence);
        }
    }
    return spmStatus;
}
Also used : SpmStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters) SpmStatusResult(org.ovirt.engine.core.common.businessentities.SpmStatusResult) VDS(org.ovirt.engine.core.common.businessentities.VDS) VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) SpmStopVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters) Guid(org.ovirt.engine.core.compat.Guid) VDSNetworkException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 5 with VdsSpmIdMap

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

the class VdsSpmIdMapDaoTest method testGetAll.

@Test
public void testGetAll() {
    List<VdsSpmIdMap> result = dao.getAll(FixturesTool.DATA_CENTER);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (VdsSpmIdMap mapping : result) {
        assertEquals(FixturesTool.DATA_CENTER, mapping.getStoragePoolId());
    }
}
Also used : VdsSpmIdMap(org.ovirt.engine.core.common.businessentities.VdsSpmIdMap) Test(org.junit.Test)

Aggregations

VdsSpmIdMap (org.ovirt.engine.core.common.businessentities.VdsSpmIdMap)7 Test (org.junit.Test)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 Guid (org.ovirt.engine.core.compat.Guid)2 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Before (org.junit.Before)1 InjectMocks (org.mockito.InjectMocks)1 Mock (org.mockito.Mock)1 Mockito.verify (org.mockito.Mockito.verify)1 VdsActionParameters (org.ovirt.engine.core.common.action.VdsActionParameters)1 SpmStatusResult (org.ovirt.engine.core.common.businessentities.SpmStatusResult)1 StorageDomainDynamic (org.ovirt.engine.core.common.businessentities.StorageDomainDynamic)1 StorageDomainStatus (org.ovirt.engine.core.common.businessentities.StorageDomainStatus)1 StoragePoolIsoMap (org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap)1 VDSType (org.ovirt.engine.core.common.businessentities.VDSType)1 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)1 SpmStatusVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.SpmStatusVDSCommandParameters)1 SpmStopVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.SpmStopVDSCommandParameters)1