use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.
the class FCPStorageHelper method runConnectionStorageToDomain.
@Override
protected Pair<Boolean, EngineFault> runConnectionStorageToDomain(StorageDomain storageDomain, Guid vdsId, int type, LUNs lun, Guid storagePoolId) {
VDSReturnValue returnValue = backend.getResourceManager().runVdsCommand(VDSCommandType.forValue(type), new StorageServerConnectionManagementVDSParameters(vdsId, storagePoolId, StorageType.FCP, Collections.singletonList(getFCPConnection())));
boolean isSuccess = returnValue.getSucceeded();
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.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.
the class RunVmCommandTest method connectAllTargets.
@Test
public void connectAllTargets() {
command.setVm(new VM());
// create 2 lun disks
LunDisk lunDisk1 = new LunDisk();
LUNs lun1 = new LUNs();
lun1.setLUNId("id1");
lunDisk1.setLun(lun1);
LunDisk lunDisk2 = new LunDisk();
LUNs lun2 = new LUNs();
lun2.setLUNId("id2");
lunDisk2.setLun(lun2);
// add luns to the vm
command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk2);
List<StorageServerConnections> connections1 = new ArrayList<>();
List<StorageServerConnections> connections2 = new ArrayList<>();
// luns have the separate backing targets
connections1.add(new StorageServerConnections("/path/to/con1", "id1", null, null, StorageType.ISCSI, null, null, null));
connections2.add(new StorageServerConnections("/path/to/con2", "id2", null, null, StorageType.ISCSI, null, null, null));
when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(connections1);
when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(connections2);
ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
doReturn(succesfull()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
// for different targets, make sure all of them are connected
verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
assertThat(captor.getValue().getConnectionList().size(), is(2));
assertTrue(connectSucceeded);
}
use of org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters in project ovirt-engine by oVirt.
the class RunVmCommandTest method skipIdenticalTargets.
@Test
public void skipIdenticalTargets() {
command.setVm(new VM());
// create 2 lun disks
LunDisk lunDisk1 = new LunDisk();
LUNs lun1 = new LUNs();
lun1.setLUNId("id1");
lunDisk1.setLun(lun1);
LunDisk lunDisk2 = new LunDisk();
LUNs lun2 = new LUNs();
lun2.setLUNId("id2");
lunDisk2.setLun(lun2);
// add luns to the vm
command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk2);
List<StorageServerConnections> connections = new ArrayList<>();
// luns have the same backing targets
connections.add(new StorageServerConnections("/path/to/con1", "id1", null, null, StorageType.ISCSI, null, null, null));
when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(connections);
when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(connections);
ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
doReturn(succesfull()).when(command).runVdsCommand(eq(ConnectStorageServer), any(StorageServerConnectionManagementVDSParameters.class));
boolean connectSucceeded = command.connectLunDisks(Guid.newGuid());
// for same targets, connect only once
verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
assertThat(captor.getValue().getConnectionList().size(), is(1));
assertTrue(connectSucceeded);
}
Aggregations