use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class ISCSIStorageHelper method runConnectionStorageToDomain.
@SuppressWarnings("unchecked")
@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type, LUNs lun, Guid storagePoolId) {
boolean isSuccess = true;
VDSReturnValue returnValue = null;
List<StorageServerConnections> list = (lun == null) ? storageServerConnectionDao.getAllForVolumeGroup(storageDomain.getStorage()) : lun.getLunConnections();
if (list.size() != 0) {
if (VDSCommandType.forValue(type) == VDSCommandType.DisconnectStorageServer) {
list = filterConnectionsUsedByOthers(list, storageDomain.getStorage(), lun != null ? lun.getLUNId() : "");
} else if (VDSCommandType.forValue(type) == VDSCommandType.ConnectStorageServer) {
list = updateIfaces(list, vdsId);
}
Guid poolId = storagePoolId;
if (storageDomain != null && storageDomain.getStoragePoolId() != null) {
poolId = storageDomain.getStoragePoolId();
}
returnValue = backend.getResourceManager().runVdsCommand(VDSCommandType.forValue(type), new StorageServerConnectionManagementVDSParameters(vdsId, poolId, StorageType.ISCSI, list));
isSuccess = returnValue.getSucceeded();
if (isSuccess && VDSCommandType.forValue(type) == VDSCommandType.ConnectStorageServer) {
isSuccess = isConnectSucceeded((Map<String, String>) returnValue.getReturnValue(), list);
}
}
EngineFault engineFault = null;
if (!isSuccess && returnValue.getVdsError() != null) {
engineFault = new EngineFault();
engineFault.setError(returnValue.getVdsError().getCode());
}
return new Pair<>(isSuccess, engineFault);
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class MapVnicsFlowTest method testCases.
@Parameterized.Parameters
public static Collection<Object[]> testCases() {
Pair nullMappingsAndNullOvfs = testNullMappingsAndNullOvfs();
Pair nullMappingsAndEmptyOvfs = testNullMappingsAndEmptyOvfs();
Pair emptyMappingsAndEmptyOvfs = testEmptyMappingsAndEmptyOvfs();
Pair emptyMappingsAndNullOvfs = testEmptyMappingsAndNullOvfs();
Pair someMappingsAndNullOvfs = testSomeMappingsAndNullOvfs();
return Arrays.asList(new Object[][] { { nullMappingsAndNullOvfs.getFirst(), nullMappingsAndNullOvfs.getSecond() }, { nullMappingsAndEmptyOvfs.getFirst(), nullMappingsAndEmptyOvfs.getSecond() }, { emptyMappingsAndEmptyOvfs.getFirst(), emptyMappingsAndEmptyOvfs.getSecond() }, { emptyMappingsAndNullOvfs.getFirst(), emptyMappingsAndNullOvfs.getSecond() }, { someMappingsAndNullOvfs.getFirst(), someMappingsAndNullOvfs.getSecond() } });
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class LibvirtVmXmlBuilder method writeDisks.
private void writeDisks(List<VmDevice> devices) {
Map<VmDeviceId, VmDevice> deviceIdToDevice = devices.stream().collect(Collectors.toMap(VmDevice::getId, dev -> dev));
Map<Integer, Map<VmDevice, Integer>> vmDeviceSpaprVscsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForSpaprScsiDisks(vm);
Map<Integer, Map<VmDevice, Integer>> vmDeviceVirtioScsiUnitMap = vmInfoBuildUtils.getVmDeviceUnitMapForVirtioScsiDisks(vm);
int hdIndex = -1;
int sdIndex = -1;
int vdIndex = -1;
int pinnedDriveIndex = 0;
Map<Disk, VmDevice> vmDisksToDevices = vm.getDiskMap().values().stream().map(d -> new Pair<>(d, deviceIdToDevice.get(new VmDeviceId(d.getId(), vm.getId())))).filter(p -> p.getSecond() != null && p.getSecond().isManaged()).collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
for (Entry<Disk, VmDevice> diskAndDevice : vmInfoBuildUtils.getSortedDisks(vmDisksToDevices, vm.getId())) {
Disk disk = diskAndDevice.getKey();
VmDevice device = diskAndDevice.getValue();
DiskVmElement dve = disk.getDiskVmElementForVm(vm.getId());
DiskInterface diskInterface = dve.getDiskInterface();
int index = 0;
int pinTo = 0;
switch(diskInterface) {
case IDE:
index = hdIndex = skipCdIndices(++hdIndex, diskInterface);
break;
case VirtIO:
pinTo = vmInfoBuildUtils.pinToIoThreads(vm, pinnedDriveIndex++);
index = vdIndex = skipCdIndices(++vdIndex, diskInterface);
break;
case SPAPR_VSCSI:
case VirtIO_SCSI:
vmInfoBuildUtils.calculateAddressForScsiDisk(vm, disk, device, vmDeviceSpaprVscsiUnitMap, vmDeviceVirtioScsiUnitMap);
case SATA:
index = sdIndex = skipCdIndices(++sdIndex, diskInterface);
break;
}
String dev = vmInfoBuildUtils.makeDiskName(dve.getDiskInterface().getName(), index);
writeDisk(device, disk, dve, dev, pinTo);
}
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class ManageGlusterServiceCommand method getCallableVdsCmdList.
private List<Callable<Pair<VDS, VDSReturnValue>>> getCallableVdsCmdList() {
List<VDS> servers = glusterUtil.getAllUpServers(getClusterId());
final List<String> serviceList = getServiceList();
List<Callable<Pair<VDS, VDSReturnValue>>> commandList = new ArrayList<>();
for (final VDS upServer : servers) {
commandList.add(() -> {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.ManageGlusterService, new GlusterServiceVDSParameters(upServer.getId(), serviceList, getParameters().getActionType()));
Pair<VDS, VDSReturnValue> pairRetVal = new Pair<>(upServer, returnValue);
if (returnValue.getSucceeded()) {
updateService(upServer.getId(), (List<GlusterServerService>) returnValue.getReturnValue());
} else {
errors.add(returnValue.getVdsError().getMessage());
}
return pairRetVal;
});
}
return commandList;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class RemoveGlusterHookCommand method executeCommand.
@Override
protected void executeCommand() {
entity = getGlusterHook();
addCustomValue(GlusterConstants.HOOK_NAME, entity.getName());
List<Callable<Pair<VDS, VDSReturnValue>>> taskList = new ArrayList<>();
for (final VDS server : getServersInCluster()) {
taskList.add(() -> {
VDSReturnValue returnValue;
returnValue = runVdsCommand(VDSCommandType.RemoveGlusterHook, new GlusterHookVDSParameters(server.getId(), entity.getGlusterCommand(), entity.getStage(), entity.getName()));
return new Pair<>(server, returnValue);
});
}
if (!taskList.isEmpty()) {
List<Pair<VDS, VDSReturnValue>> pairResults = ThreadPoolUtil.invokeAll(taskList);
for (Pair<VDS, VDSReturnValue> pairResult : pairResults) {
VDSReturnValue retValue = pairResult.getSecond();
if (!retValue.getSucceeded()) {
errors.add(retValue.getVdsError().getMessage());
}
}
}
if (errors.size() > 0) {
setSucceeded(false);
errorType = AuditLogType.GLUSTER_HOOK_REMOVE_FAILED;
handleVdsErrors(getAuditLogTypeValue(), errors);
addCustomValue(GlusterConstants.FAILURE_MESSAGE, StringUtils.join(errors, System.lineSeparator()));
} else {
setSucceeded(true);
}
if (getSucceeded()) {
entity.removeMissingConflict();
glusterHooksDao.remove(entity.getId());
}
}
Aggregations