Search in sources :

Example 41 with LUNs

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

the class AddSANStorageDomainCommand method proceedVGLunsInDb.

protected void proceedVGLunsInDb() {
    final ArrayList<LUNs> luns = (ArrayList<LUNs>) runVdsCommand(VDSCommandType.GetVGInfo, new GetVGInfoVDSCommandParameters(getVds().getId(), getStorageDomain().getStorage())).getReturnValue();
    TransactionSupport.executeInNewTransaction(() -> {
        for (LUNs lun : luns) {
            lunHelper.proceedLUNInDb(lun, getStorageDomain().getStorageType(), getStorageDomain().getStorage());
        }
        return null;
    });
}
Also used : GetVGInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 42 with LUNs

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

the class ExtendSANStorageDomainCommand method updateLunsList.

@SuppressWarnings("unchecked")
private void updateLunsList() {
    VDS spmVds = getAllRunningVdssInPool().stream().filter(vds -> vds.getSpmStatus() == VdsSpmStatus.SPM).findFirst().orElse(null);
    if (spmVds == null) {
        log.error("Could not update LUNs' information of storage domain with VG ID '{}' in the DB.", getStorageDomain().getStorage());
        return;
    }
    try {
        ArrayList<LUNs> upToDateLuns = (ArrayList<LUNs>) runVdsCommand(VDSCommandType.GetVGInfo, new GetVGInfoVDSCommandParameters(spmVds.getId(), getStorageDomain().getStorage())).getReturnValue();
        getParameters().setLunsList(upToDateLuns);
    } catch (RuntimeException e) {
        log.error("Could not get the information for VG ID '{}'; the LUNs' information will not be updated.", getStorageDomain().getStorage());
        log.debug("Exception", e);
    }
}
Also used : GetVGInfoVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.GetVGInfoVDSCommandParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 43 with LUNs

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

the class ImagesHandler method removeLunDisk.

public void removeLunDisk(LunDisk lunDisk) {
    vmDeviceDao.remove(new VmDeviceId(lunDisk.getId(), null));
    LUNs lun = lunDisk.getLun();
    diskLunMapDao.remove(new DiskLunMapId(lunDisk.getId(), lun.getLUNId()));
    baseDiskDao.remove(lunDisk.getId());
    lun.setLunConnections(new ArrayList<>(storageServerConnectionDao.getAllForLun(lun.getLUNId())));
    if (!lun.getLunConnections().isEmpty()) {
        storageHelperDirector.getItem(lun.getLunConnections().get(0).getStorageType()).removeLun(lun);
    } else {
        // if there are no connections then the lun is fcp.
        storageHelperDirector.getItem(StorageType.FCP).removeLun(lun);
    }
}
Also used : DiskLunMapId(org.ovirt.engine.core.common.businessentities.storage.DiskLunMapId) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 44 with LUNs

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

the class LunDaoTest method testGetAllForVolumeGroup.

/**
 * Ensures the right set of LUNs are returned.
 */
@Test
public void testGetAllForVolumeGroup() {
    List<LUNs> result = dao.getAllForVolumeGroup(existingEntity.getVolumeGroupId());
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (LUNs lun : result) {
        assertEquals(existingEntity.getVolumeGroupId(), lun.getVolumeGroupId());
    }
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 45 with LUNs

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

the class BackendStorageDomainsResource method mapVolumeGroupIscsi.

protected void mapVolumeGroupIscsi(StorageDomain model, org.ovirt.engine.core.common.businessentities.StorageDomain entity) {
    VolumeGroup vg = model.getStorage().getVolumeGroup();
    List<LUNs> luns = getLunsByVgId(vg.getId());
    if (luns != null && !luns.isEmpty()) {
        vg.setLogicalUnits(new LogicalUnits());
        for (LUNs lun : luns) {
            List<StorageServerConnections> lunConnections = lun.getLunConnections();
            if (lunConnections != null) {
                for (StorageServerConnections cnx : lunConnections) {
                    LogicalUnit unit = map(lun);
                    unit = map(cnx, unit);
                    vg.getLogicalUnits().getLogicalUnits().add(unit);
                }
            }
        }
    }
}
Also used : LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) VolumeGroup(org.ovirt.engine.api.model.VolumeGroup) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

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