Search in sources :

Example 71 with LUNs

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

the class BackendStorageDomainsResource method getLunsWithInitializedStorageType.

private List<StorageServerConnections> getLunsWithInitializedStorageType(List<LUNs> luns, StorageType storageType) {
    List<StorageServerConnections> existingStorageServerConnections = new ArrayList<>();
    for (LUNs lun : luns) {
        for (StorageServerConnections storageServerConnection : lun.getLunConnections()) {
            storageServerConnection.setStorageType(storageType);
            existingStorageServerConnections.add(storageServerConnection);
        }
    }
    return existingStorageServerConnections;
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 72 with LUNs

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

the class AttachStorageConnectionToStorageDomainCommand method executeCommand.

@Override
protected void executeCommand() {
    // Create a dummy lun
    LUNs dummyLun = createDummyLun();
    // Create storage server connection mapping
    LUNStorageServerConnectionMap connectionMapRecord = new LUNStorageServerConnectionMap(dummyLun.getLUNId(), getParameters().getStorageConnectionId());
    List<StorageServerConnections> connectionsForDomain;
    if (lunDao.get(dummyLun.getLUNId()) == null) {
        lunDao.save(dummyLun);
        // Save connection maps when creating the dummy lun for the first time
        connectionsForDomain = storageServerConnectionDao.getAllForDomain(getStorageDomainId());
        for (StorageServerConnections connection : connectionsForDomain) {
            saveConnection(new LUNStorageServerConnectionMap(dummyLun.getLUNId(), connection.getId()));
        }
    }
    // Save new connection map
    saveConnection(connectionMapRecord);
    setSucceeded(true);
}
Also used : 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)

Example 73 with LUNs

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

the class AttachStorageConnectionToStorageDomainCommand method createDummyLun.

private LUNs createDummyLun() {
    final LUNs dummyLun = new LUNs();
    dummyLun.setLUNId(BusinessEntitiesDefinitions.DUMMY_LUN_ID_PREFIX + getStorageDomainId());
    dummyLun.setVolumeGroupId(getStorageDomain().getStorage());
    return dummyLun;
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 74 with LUNs

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

the class ConnectAllHostsToLunCommand method connectVdsToLun.

/**
 * The following method will connect all provided lund to all running host in pool
 *
 * @param luns
 *            - the luns which should be connected
 * @return the map where the key is true/false value which means if connection successes/not successes and value is
 *         map of luns Ids -> connected hosts
 */
private Pair<Boolean, Map<String, List<Guid>>> connectVdsToLun(List<LUNs> luns) {
    Map<String, List<Guid>> resultMap = new HashMap<>();
    for (VDS vds : getAllRunningVdssInPool()) {
        // try to connect vds to luns and getDeviceList in order to refresh them
        for (LUNs lun : luns) {
            if (!connectStorageToLunByVdsId(vds, lun)) {
                log.error("Could not connect host '{}' to lun '{}'", vds.getName(), lun.getLUNId());
                setVds(vds);
                handleFailure(vds, lun);
                return new Pair<>(Boolean.FALSE, resultMap);
            } else {
                List<Guid> hosts = resultMap.get(lun.getLUNId());
                if (hosts == null) {
                    hosts = new ArrayList<>();
                    resultMap.put(lun.getLUNId(), hosts);
                }
                hosts.add(vds.getId());
            }
        }
        // Refresh all connected luns to host
        if (!validateConnectedLuns(vds, getParameters().getLunIds())) {
            return new Pair<>(Boolean.FALSE, resultMap);
        }
    }
    return new Pair<>(Boolean.TRUE, resultMap);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Guid(org.ovirt.engine.core.compat.Guid) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Pair(org.ovirt.engine.core.common.utils.Pair)

Example 75 with LUNs

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

the class VdsBrokerObjectsBuilder method buildVmLunDisksData.

public static Map<String, LUNs> buildVmLunDisksData(Map<String, Object> struct) {
    Map<String, Object> disks = (Map<String, Object>) struct.get(VdsProperties.vm_disks);
    if (disks == null) {
        return Collections.emptyMap();
    }
    Map<String, LUNs> lunsMap = new HashMap<>();
    for (Object diskAsObj : disks.values()) {
        Map<String, Object> disk = (Map<String, Object>) diskAsObj;
        String lunGuidString = assignStringValue(disk, VdsProperties.lun_guid);
        if (!StringUtils.isEmpty(lunGuidString)) {
            LUNs lun = new LUNs();
            lun.setLUNId(lunGuidString);
            if (disk.containsKey(VdsProperties.disk_true_size)) {
                long sizeInBytes = assignLongValue(disk, VdsProperties.disk_true_size);
                int sizeInGB = SizeConverter.convert(sizeInBytes, SizeConverter.SizeUnit.BYTES, SizeConverter.SizeUnit.GiB).intValue();
                lun.setDeviceSize(sizeInGB);
            }
            lunsMap.put(lunGuidString, lun);
        }
    }
    return lunsMap;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) 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