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