Search in sources :

Example 36 with LUNs

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

the class UpdateStorageServerConnectionCommandTest method updateConnectionOfDomainsAndLunDisks.

@Test
public void updateConnectionOfDomainsAndLunDisks() {
    StorageServerConnections iscsiConnection = createISCSIConnection("10.35.16.25", StorageType.ISCSI, "iqn.2013-04.myhat.com:aaa-target1", "3260", "user1", "mypassword123");
    LUNs lun1 = new LUNs();
    lun1.setLUNId("3600144f09dbd05000000517e730b1212");
    lun1.setVolumeGroupId("");
    lun1.setDiskAlias("disk1");
    Guid diskId1 = Guid.newGuid();
    lun1.setDiskId(diskId1);
    LUNs lun2 = new LUNs();
    lun2.setLUNId("3600144f09dbd05000000517e730b1212");
    lun2.setVolumeGroupId("");
    lun2.setDiskAlias("disk2");
    Guid diskId2 = Guid.newGuid();
    lun2.setDiskId(diskId2);
    LUNs lun3 = new LUNs();
    lun3.setLUNId("3600144f09dbd05000000517e730b1212");
    lun3.setStorageDomainName("storagedomain4");
    Guid storageDomainId = Guid.newGuid();
    lun3.setStorageDomainId(storageDomainId);
    lun3.setVolumeGroupId(Guid.newGuid().toString());
    List<LUNs> luns = Arrays.asList(lun1, lun2, lun3);
    Map<Boolean, List<VM>> vmsMap = new HashMap<>();
    VM vm1 = new VM();
    vm1.setName("vm1");
    vm1.setStatus(VMStatus.Up);
    VM vm2 = new VM();
    vm2.setName("vm2");
    vm2.setStatus(VMStatus.Down);
    VM vm3 = new VM();
    vm3.setName("vm3");
    vm3.setStatus(VMStatus.Up);
    List<VM> pluggedVms = Arrays.asList(vm1, vm2);
    List<VM> unPluggedVms = Collections.singletonList(vm3);
    vmsMap.put(Boolean.FALSE, unPluggedVms);
    vmsMap.put(Boolean.TRUE, pluggedVms);
    when(vmDao.getForDisk(diskId1, true)).thenReturn(vmsMap);
    parameters.setStorageServerConnection(iscsiConnection);
    when(storageConnDao.get(iscsiConnection.getId())).thenReturn(iscsiConnection);
    doReturn(luns).when(command).getLuns();
    StorageDomain domain1 = new StorageDomain();
    domain1.setStorage(iscsiConnection.getConnection());
    domain1.setStatus(StorageDomainStatus.Active);
    domain1.setStorageDomainSharedStatus(StorageDomainSharedStatus.Active);
    domain1.setId(storageDomainId);
    domain1.setStorageName("storagedomain4");
    when(storageDomainDao.get(storageDomainId)).thenReturn(domain1);
    when(storagePoolIsoMapDao.getAllForStorage(storageDomainId)).thenReturn(Collections.singletonList(new StoragePoolIsoMap(storageDomainId, Guid.newGuid(), StorageDomainStatus.Active)));
    List<String> messages = ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS_AND_DOMAINS_STATUS);
    assertTrue(messages.contains("$vmNames vm1"));
    assertTrue(messages.contains("$domainNames storagedomain4"));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HashMap(java.util.HashMap) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) VM(org.ovirt.engine.core.common.businessentities.VM) List(java.util.List) Test(org.junit.Test)

Example 37 with LUNs

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

the class AddDiskCommandTest method testLunDiskValid.

@Test
public void testLunDiskValid() {
    VDS vds = mockVds();
    LunDisk disk = createISCSILunDisk();
    command.getParameters().setDiskInfo(disk);
    command.getParameters().setVdsId(vds.getId());
    command.setVds(vds);
    mockVm();
    mockMaxPciSlots();
    mockInterfaceList();
    List<LUNs> luns = Collections.singletonList(disk.getLun());
    doReturn(luns).when(command).executeGetDeviceList(any(), any(), any());
    ValidateTestUtils.runAndAssertValidateSuccess(command);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 38 with LUNs

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

the class AddDiskCommandTest method testGetLunDiskSucceeds.

@Test
public void testGetLunDiskSucceeds() {
    VDS vds = mockVds();
    LunDisk disk = createISCSILunDisk();
    List<LUNs> luns = Collections.singletonList(disk.getLun());
    initializeCommand(Guid.newGuid());
    doReturn(luns).when(command).executeGetDeviceList(any(), any(), any());
    assertEquals(disk.getLun(), command.getLunDisk(disk.getLun(), vds));
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 39 with LUNs

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

the class OvfOvirtReader method readLunDisk.

@Override
protected void readLunDisk(XmlNode node, LunDisk lun) {
    lun.setDiskVmElements(Collections.singletonList(new DiskVmElement(lun.getId(), fullEntityOvfData.getVmBase().getId())));
    LUNs luns = new LUNs();
    consumeReadXmlAttribute(node, OVF_PREFIX + COLON + LUN_ID, val -> luns.setLUNId(val));
    ArrayList<StorageServerConnections> lunConnections = new ArrayList<>();
    for (XmlNode connNode : selectNodes(node, LUN_CONNECTION)) {
        StorageServerConnections conn = new StorageServerConnections();
        consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_CONNECTION, val -> conn.setConnection(val));
        consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_IQN, val -> conn.setIqn(val));
        consumeReadXmlAttribute(connNode, OVF_PREFIX + COLON + LUNS_PORT, val -> conn.setPort(val));
        consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_STORAGE_TYPE, val -> conn.setStorageType(StorageType.valueOf(val)));
        consumeReadXmlAttribute(connNode, XSI_PREFIX + COLON + LUNS_PORTAL, val -> conn.setPortal(val));
        lunConnections.add(conn);
    }
    luns.setLunConnections(lunConnections);
    lun.setLun(luns);
    DiskVmElement dve = lun.getDiskVmElementForVm(fullEntityOvfData.getVmBase().getId());
    initGeneralDiskAttributes(node, lun, dve);
}
Also used : XmlNode(org.ovirt.engine.core.utils.ovf.xml.XmlNode) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) DiskVmElement(org.ovirt.engine.core.common.businessentities.storage.DiskVmElement) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 40 with LUNs

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

the class GetLunsByVgIdQuery method getStorageType.

private StorageType getStorageType(List<LUNs> luns) {
    StorageType storageType = null;
    if (!luns.isEmpty()) {
        LUNs lun = luns.get(0);
        List<LUNStorageServerConnectionMap> lunConnections = storageServerConnectionLunMapDao.getAll(lun.getLUNId());
        if (!lunConnections.isEmpty()) {
            StorageServerConnections connection = storageServerConnectionDao.get(lunConnections.get(0).getStorageServerConnection());
            storageType = connection.getStorageType();
        } else {
            storageType = StorageType.FCP;
        }
    }
    return storageType;
}
Also used : StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap)

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