Search in sources :

Example 96 with LUNs

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

the class ImportVmCommand method validateLunDisk.

private List<EngineMessage> validateLunDisk(LunDisk lunDisk) {
    DiskValidator diskValidator = getDiskValidator(lunDisk);
    LUNs lun = lunDisk.getLun();
    StorageType storageType;
    if (lun.getLunConnections() != null && !lun.getLunConnections().isEmpty()) {
        // We set the storage type based on the first connection since connections should be with the same
        // storage type
        storageType = lun.getLunConnections().get(0).getStorageType();
    } else {
        storageType = StorageType.FCP;
    }
    if (storageType == StorageType.ISCSI) {
        ValidationResult connectionsInLunResult = diskValidator.validateConnectionsInLun(storageType);
        if (!connectionsInLunResult.isValid()) {
            return connectionsInLunResult.getMessages();
        }
    }
    ValidationResult lunAlreadyInUseResult = diskValidator.validateLunAlreadyInUse();
    if (!lunAlreadyInUseResult.isValid()) {
        return lunAlreadyInUseResult.getMessages();
    }
    DiskVmElementValidator diskVmElementValidator = new DiskVmElementValidator(lunDisk, lunDisk.getDiskVmElementForVm(getVmId()));
    ValidationResult virtIoScsiResult = isVirtIoScsiValid(getVm(), diskVmElementValidator);
    if (!virtIoScsiResult.isValid()) {
        return virtIoScsiResult.getMessages();
    }
    ValidationResult diskInterfaceResult = diskVmElementValidator.isDiskInterfaceSupported(getVm());
    if (!diskInterfaceResult.isValid()) {
        return diskInterfaceResult.getMessages();
    }
    Guid vdsId = vdsCommandsHelper.getHostForExecution(getStoragePoolId());
    if (vdsId == null || !validateLunExistsAndInitDeviceData(lun, storageType, vdsId)) {
        return Arrays.asList(EngineMessage.ACTION_TYPE_FAILED_DISK_LUN_INVALID);
    }
    ValidationResult usingScsiReservationResult = diskValidator.isUsingScsiReservationValid(getVm(), lunDisk.getDiskVmElementForVm(getVmId()), lunDisk);
    if (!usingScsiReservationResult.isValid()) {
        return usingScsiReservationResult.getMessages();
    }
    return Collections.emptyList();
}
Also used : DiskValidator(org.ovirt.engine.core.bll.validator.storage.DiskValidator) StorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType) DiskStorageType(org.ovirt.engine.core.common.businessentities.storage.DiskStorageType) DiskVmElementValidator(org.ovirt.engine.core.bll.validator.storage.DiskVmElementValidator) Guid(org.ovirt.engine.core.compat.Guid) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 97 with LUNs

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

the class UpdateStorageServerConnectionCommandTest method updateConnectionOfLunDisks.

@Test
public void updateConnectionOfLunDisks() {
    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);
    List<LUNs> luns = Arrays.asList(lun1, lun2);
    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.Paused);
    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();
    List<String> messages = ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_STORAGE_CONNECTION_UNSUPPORTED_ACTION_FOR_RUNNING_VMS);
    assertTrue(messages.contains("$vmNames vm1,vm2"));
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HashMap(java.util.HashMap) VM(org.ovirt.engine.core.common.businessentities.VM) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 98 with LUNs

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

the class UpdateStorageServerConnectionCommandTest method updateConnectionOfDomains.

@Test
public void updateConnectionOfDomains() {
    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.setStorageDomainName("storagedomain4");
    Guid storageDomainId = Guid.newGuid();
    lun1.setStorageDomainId(storageDomainId);
    lun1.setVolumeGroupId(Guid.newGuid().toString());
    List<LUNs> luns = Collections.singletonList(lun1);
    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_UNSUPPORTED_ACTION_DOMAIN_MUST_BE_IN_MAINTENANCE_OR_UNATTACHED);
    assertTrue(messages.contains("$domainNames storagedomain4"));
}
Also used : StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StoragePoolIsoMap(org.ovirt.engine.core.common.businessentities.StoragePoolIsoMap) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 99 with LUNs

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

the class AttachStorageServerConnectionToStorageDomainCommandTest method executeCommandNotFirstDummyLun.

@Test
public void executeCommandNotFirstDummyLun() {
    LUNs dummyLun = new LUNs();
    dummyLun.setLUNId(BusinessEntitiesDefinitions.DUMMY_LUN_ID_PREFIX + domain.getId());
    when(lunDao.get(dummyLun.getLUNId())).thenReturn(dummyLun);
    List<StorageServerConnections> connectionsForDomain = new ArrayList<>();
    StorageServerConnections connection = new StorageServerConnections();
    connection.setId(Guid.newGuid().toString());
    connection.setStorageType(StorageType.ISCSI);
    connection.setIqn("iqn.1.2.3.4.com");
    connection.setConnection("123.345.266.255");
    connectionsForDomain.add(connection);
    when(connectionDao.getAllForDomain(domain.getId())).thenReturn(connectionsForDomain);
    // dummy lun already exists, thus no need to save
    verify(lunDao, never()).save(dummyLun);
    verify(lunMapDao, never()).save(new LUNStorageServerConnectionMap());
    command.executeCommand();
    CommandAssertUtils.checkSucceeded(command, true);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) LUNStorageServerConnectionMap(org.ovirt.engine.core.common.businessentities.storage.LUNStorageServerConnectionMap) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 100 with LUNs

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

the class DetachStorageConnectionFromStorageDomainCommandTest method executeCommand.

@Test
public void executeCommand() {
    LUNs lun1 = new LUNs();
    lun1.setLUNId(Guid.newGuid().toString());
    lun1.setStorageDomainId(domain.getId());
    LUNs lun2 = new LUNs();
    lun2.setLUNId(Guid.newGuid().toString());
    lun2.setStorageDomainId(domain.getId());
    LUNs lun3 = new LUNs();
    lun3.setLUNId(Guid.newGuid().toString());
    lun3.setStorageDomainId(domain.getId());
    List<LUNs> lunsForConnection = new ArrayList<>();
    lunsForConnection.add(lun1);
    lunsForConnection.add(lun2);
    lunsForConnection.add(lun3);
    List<LUNs> lunsForVG = new ArrayList<>();
    lunsForVG.add(lun1);
    lunsForVG.add(lun2);
    when(lunDao.getAllForStorageServerConnection(connectionId.toString())).thenReturn(lunsForConnection);
    when(lunDao.getAllForVolumeGroup(domain.getStorage())).thenReturn(lunsForVG);
    when(lunDao.get(lun1.getLUNId())).thenReturn(lun1);
    when(lunDao.get(lun2.getLUNId())).thenReturn(lun2);
    command.executeCommand();
    verify(lunDao, times(1)).remove(lun1.getLUNId());
    verify(lunDao, times(1)).remove(lun2.getLUNId());
    CommandAssertUtils.checkSucceeded(command, true);
}
Also used : ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

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