use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class GetUnregisteredBlockStorageDomainsQuery method getStorageDomainById.
/**
* Retrieve a storage domain using a specified storage domain ID.
*
* @param storageDomainId the domain's ID
* @return the storage domain
*/
@SuppressWarnings("unchecked")
protected StorageDomain getStorageDomainById(Guid storageDomainId) {
VDSReturnValue returnValue;
try {
returnValue = executeHSMGetStorageDomainInfo(new HSMGetStorageDomainInfoVDSCommandParameters(getParameters().getVdsId(), storageDomainId));
} catch (RuntimeException e) {
log.error("Could not get info for storage domain ID: '{}': {}", storageDomainId, e.getMessage());
log.debug("Exception", e);
return null;
}
Pair<StorageDomainStatic, SANState> result = (Pair<StorageDomainStatic, SANState>) returnValue.getReturnValue();
StorageDomainStatic storageDomainStatic = result.getFirst();
storageDomainStatic.setStorageType(getParameters().getStorageType());
StorageDomain storageDomain = new StorageDomain();
storageDomain.setStorageStaticData(storageDomainStatic);
return storageDomain;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class DiskValidatorTest method testDiskAttachedToAnyNonDownVMWithProblems.
private void testDiskAttachedToAnyNonDownVMWithProblems(boolean checkOnlyPlugged, String expectedNames) {
VM vmPausedPlugged = createVM();
vmPausedPlugged.setName("vmPausedPlugged");
vmPausedPlugged.setStatus(VMStatus.Paused);
VmDevice device1 = new VmDevice();
device1.setPlugged(true);
Pair<VM, VmDevice> pair1 = new Pair<>(vmPausedPlugged, device1);
VM vmDownPlugged = createVM();
vmDownPlugged.setName("vmDownPlugged");
VmDevice device2 = new VmDevice();
device2.setPlugged(true);
Pair<VM, VmDevice> pair2 = new Pair<>(vmDownPlugged, device2);
VM vmRunningUnplugged = createVM();
vmRunningUnplugged.setName("vmRunningUnplugged");
vmRunningUnplugged.setStatus(VMStatus.Up);
VmDevice device3 = new VmDevice();
device3.setPlugged(false);
Pair<VM, VmDevice> pair3 = new Pair<>(vmRunningUnplugged, device3);
VM anotherPausedPlugged = createVM();
anotherPausedPlugged.setName("anotherPausedPlugged");
anotherPausedPlugged.setStatus(VMStatus.Paused);
VmDevice device4 = new VmDevice();
device4.setPlugged(true);
Pair<VM, VmDevice> pair4 = new Pair<>(anotherPausedPlugged, device4);
VM runningSnapshotPlugged = createVM();
runningSnapshotPlugged.setName("runningSnapshotPlugged");
runningSnapshotPlugged.setStatus(VMStatus.Up);
VmDevice device5 = new VmDevice();
device5.setPlugged(true);
device5.setSnapshotId(Guid.newGuid());
Pair<VM, VmDevice> pair5 = new Pair<>(runningSnapshotPlugged, device5);
List<Pair<VM, VmDevice>> vmList = Arrays.asList(pair1, pair2, pair3, pair4, pair5);
when(vmDao.getVmsWithPlugInfo(any())).thenReturn(vmList);
String[] expectedReplacements = { ReplacementUtils.createSetVariableString(DiskValidator.DISK_NAME_VARIABLE, disk.getDiskAlias()), ReplacementUtils.createSetVariableString(DiskValidator.VM_LIST, expectedNames) };
assertThat(validator.isDiskPluggedToAnyNonDownVm(checkOnlyPlugged), failsWith(EngineMessage.ACTION_TYPE_FAILED_DISK_PLUGGED_TO_NON_DOWN_VMS, expectedReplacements));
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class DiskValidatorTest method prepareForCheckingIfDiskPluggedToVmsThatAreNotDown.
public List<Pair<VM, VmDevice>> prepareForCheckingIfDiskPluggedToVmsThatAreNotDown() {
VM vm1 = createVM();
VM vm2 = createVM();
VmDevice device1 = createVmDeviceForDisk(vm1, disk);
VmDevice device2 = createVmDeviceForDisk(vm1, disk);
List<Pair<VM, VmDevice>> vmsInfo = new LinkedList<>();
vmsInfo.add(new Pair<>(vm1, device1));
vmsInfo.add(new Pair<>(vm2, device2));
return vmsInfo;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class VmDevicesMonitoringTest method testUpdateVmFromFullList.
@Test
public void testUpdateVmFromFullList() {
initDevices();
initDumpXmls();
VmDevicesMonitoring.Change change = vmDevicesMonitoring.createChange(VDS_ID, 1L);
Map<String, Object> vmInfo = getDumpXmls(VM_ID, getDeviceInfo(null, "balloon", "memballoon", null), getDeviceInfo(null, "controller", "virtio-serial", SERIAL_DEVICE_ADDRESS), getDeviceInfo(VIDEO_DEVICE_ID, "video", "cirrus", VIDEO_DEVICE_ADDRESS), getDeviceInfo(CDROM_DEVICE_ID, "disk", "cdrom", CDROM_DEVICE_ADDRESS));
change.updateVmFromFullList(vmInfo);
change.flush();
change = vmDevicesMonitoring.createChange(VDS_ID, 1L);
change.updateVm(VM_ID, INITIAL_HASH);
change.flush();
verify(resourceManager, never()).runVdsCommand(eq(VDSCommandType.FullList), any());
verify(vmDeviceDao, never()).updateAllInBatch(any());
verify(vmDeviceDao, never()).removeAll(any());
verify(vmDeviceDao, times(1)).saveAll(any());
ArgumentCaptor<List> updateHashesCaptor = ArgumentCaptor.forClass(List.class);
verify(vmDynamicDao, times(2)).updateDevicesHashes(updateHashesCaptor.capture());
List<List> values = updateHashesCaptor.getAllValues();
List updatedHashes = values.get(0);
assertEquals(1, updatedHashes.size());
Pair<Guid, String> hashInfo = (Pair<Guid, String>) updatedHashes.get(0);
assertEquals(VM_ID, hashInfo.getFirst());
assertEquals(VmDevicesMonitoring.UPDATE_HASH, hashInfo.getSecond());
updatedHashes = values.get(1);
assertEquals(1, updatedHashes.size());
hashInfo = (Pair<Guid, String>) updatedHashes.get(0);
assertEquals(VM_ID, hashInfo.getFirst());
assertEquals(INITIAL_HASH, hashInfo.getSecond());
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class SpmStopVDSCommand method retrieveVdsExecutionLock.
private EngineLock retrieveVdsExecutionLock() {
if (lock == null) {
Map<String, Pair<String, String>> exsluciveLock = Collections.singletonMap(getParameters().getVdsId().toString(), new Pair<>(LockingGroup.VDS_EXECUTION.toString(), EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED.toString()));
lock = new EngineLock(exsluciveLock, null);
}
return lock;
}
Aggregations