Search in sources :

Example 6 with LUNs

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

the class RunVmCommandTest method dontConnectFCLuns.

@Test
public void dontConnectFCLuns() {
    // FC luns are connected physically, they don't have StorageServerConnection set.
    // Make sure if we have an FC lun connection we don't try to connect
    // otherwise NPE will be thrown.
    command.setVm(new VM());
    // create 2 FC lun disks
    LunDisk fcLunDisk = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    fcLunDisk.setLun(lun1);
    LunDisk isciDisk = new LunDisk();
    LUNs lun2 = new LUNs();
    lun2.setLUNId("id2");
    isciDisk.setLun(lun2);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), fcLunDisk);
    command.getVm().getDiskMap().put(Guid.newGuid(), isciDisk);
    List<StorageServerConnections> iscsiLunConnections = new ArrayList<>();
    iscsiLunConnections.add(new StorageServerConnections("path/to/iscsi/connection", "id1", null, null, StorageType.ISCSI, null, null, null));
    when(storageServerConnectionDao.getAllForLun("id1")).thenReturn(Collections.emptyList());
    when(storageServerConnectionDao.getAllForLun("id2")).thenReturn(iscsiLunConnections);
    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 we connect all but not FC.
    verify(command).runVdsCommand(eq(ConnectStorageServer), captor.capture());
    assertThat(captor.getValue().getConnectionList().size(), is(1));
    assertEquals(captor.getValue().getStorageType(), StorageType.ISCSI);
    assertTrue(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 7 with LUNs

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

the class RunVmCommandTest method oneConnectFailed.

@Test
public void oneConnectFailed() {
    command.setVm(new VM());
    // create 2 lun disks
    LunDisk lunDisk1 = new LunDisk();
    LUNs lun1 = new LUNs();
    lun1.setLUNId("id1");
    lunDisk1.setLun(lun1);
    // add luns to the vm
    command.getVm().getDiskMap().put(Guid.newGuid(), lunDisk1);
    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);
    ArgumentCaptor<StorageServerConnectionManagementVDSParameters> captor = ArgumentCaptor.forClass(StorageServerConnectionManagementVDSParameters.class);
    doReturn(new VDSReturnValue()).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));
    assertFalse(connectSucceeded);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageServerConnectionManagementVDSParameters(org.ovirt.engine.core.common.vdscommands.StorageServerConnectionManagementVDSParameters) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Test(org.junit.Test)

Example 8 with LUNs

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

the class BlockStorageDiscardFunctionalityHelperTest method testGetLunsThatBreakPassDiscardFunctionalityPassDiscardBreaks.

@Test
public void testGetLunsThatBreakPassDiscardFunctionalityPassDiscardBreaks() {
    createVmDiskOnSd(false, false);
    // This disk requires pass discard support.
    createVmDiskOnSd(false, true);
    LUNs lunThatBreaksDiscardSupport = createLunWithDiscardSupport(0L);
    assertGetLunsThatBreakPassDiscardFunctionalityContainsExpectedLuns(Arrays.asList(createLunWithDiscardSupport(1024L), lunThatBreaksDiscardSupport), Collections.singletonList(lunThatBreaksDiscardSupport));
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 9 with LUNs

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

the class BlockStorageDiscardFunctionalityHelperTest method createLunWithDiscardSupport.

private LUNs createLunWithDiscardSupport(Long discardMaxSize) {
    LUNs lun = new LUNs();
    lun.setDiscardMaxSize(discardMaxSize);
    return lun;
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 10 with LUNs

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

the class AbstractSyncLunsCommandTest method testGetDeviceListWithDeviceListAndLunsIds.

@Test
public void testGetDeviceListWithDeviceListAndLunsIds() {
    LUNs lun1 = new LUNs();
    lun1.setId("lun1");
    LUNs lun2 = new LUNs();
    lun2.setId("lun2");
    parameters.setDeviceList(Arrays.asList(lun1, lun2));
    Set<String> lunsIds = Collections.singleton("lun2");
    assertEquals(command.getDeviceList(lunsIds), Collections.singletonList(lun2));
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Aggregations

LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)105 ArrayList (java.util.ArrayList)40 Test (org.junit.Test)33 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)26 Guid (org.ovirt.engine.core.compat.Guid)18 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)17 List (java.util.List)16 HashMap (java.util.HashMap)14 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)13 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 VM (org.ovirt.engine.core.common.businessentities.VM)7 StorageType (org.ovirt.engine.core.common.businessentities.storage.StorageType)7 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)7 Map (java.util.Map)6 LUNStorageServerConnectionMap (org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)6 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)5 Pair (org.ovirt.engine.core.common.utils.Pair)5 GetDeviceListVDSCommandParameters (org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters)5 HashSet (java.util.HashSet)4