Search in sources :

Example 6 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainsResource method getLunIds.

private Set<String> getLunIds(HostStorage storage, StorageType storageType, Guid hostId) {
    List<LogicalUnit> logicalUnits = new ArrayList<>();
    if (storage.isSetLogicalUnits() && storage.getLogicalUnits().isSetLogicalUnits()) {
        logicalUnits = storage.getLogicalUnits().getLogicalUnits();
    } else if (storage.isSetVolumeGroup() && storage.getVolumeGroup().isSetLogicalUnits() && storage.getVolumeGroup().getLogicalUnits().isSetLogicalUnits()) {
        logicalUnits = storage.getVolumeGroup().getLogicalUnits().getLogicalUnits();
    }
    Set<String> lunIds = new HashSet<>();
    for (LogicalUnit unit : logicalUnits) {
        validateParameters(unit, 4, "id");
        // to the target.
        if ((storageType == StorageType.ISCSI) && !isConnectionAssumed(unit)) {
            connectStorageToHost(hostId, storageType, unit);
        }
        lunIds.add(unit.getId());
    }
    refreshHostStorage(hostId);
    return !lunIds.isEmpty() ? lunIds : null;
}
Also used : LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 7 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainResource method reduceLuns.

@Override
public Response reduceLuns(Action action) {
    List<LogicalUnit> reducedLuns = action.getLogicalUnits().getLogicalUnits();
    List<String> lunIds = reducedLuns.stream().map(LogicalUnit::getId).collect(toList());
    ReduceSANStorageDomainDevicesCommandParameters parameters = new ReduceSANStorageDomainDevicesCommandParameters(guid, lunIds);
    return performAction(ActionType.ReduceSANStorageDomainDevices, parameters);
}
Also used : LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) ReduceSANStorageDomainDevicesCommandParameters(org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters)

Example 8 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendVmDisksResourceTest method createIscsiLunDisk.

private Disk createIscsiLunDisk() {
    Disk model = getModel();
    model.setLunStorage(new HostStorage());
    model.getLunStorage().setType(StorageType.ISCSI);
    model.getLunStorage().setLogicalUnits(new LogicalUnits());
    model.getLunStorage().getLogicalUnits().getLogicalUnits().add(new LogicalUnit());
    model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setId(GUIDS[0].toString());
    model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setAddress(ISCSI_SERVER_ADDRESS);
    model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setTarget(ISCSI_SERVER_TARGET);
    model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setPort(ISCSI_SERVER_CONNECTION_PORT);
    model.setProvisionedSize(null);
    return model;
}
Also used : LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) HostStorage(org.ovirt.engine.api.model.HostStorage) Disk(org.ovirt.engine.api.model.Disk)

Example 9 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class StorageLogicalUnitMapper method map.

@Mapping(from = LUNs.class, to = LogicalUnit.class)
public static LogicalUnit map(LUNs entity, LogicalUnit template) {
    LogicalUnit model = template != null ? template : new LogicalUnit();
    model.setId(entity.getLUNId());
    if (entity.getVendorId() != null && !entity.getVendorId().isEmpty()) {
        model.setVendorId(entity.getVendorId());
    }
    if (entity.getProductId() != null && !entity.getProductId().isEmpty()) {
        model.setProductId(entity.getProductId());
    }
    if (entity.getSerial() != null && !entity.getSerial().isEmpty()) {
        model.setSerial(entity.getSerial());
    }
    if (entity.getLunMapping() != null) {
        model.setLunMapping(entity.getLunMapping());
    }
    if (entity.getVolumeGroupId() != null && !entity.getVolumeGroupId().isEmpty()) {
        model.setVolumeGroupId(entity.getVolumeGroupId());
    }
    if (entity.getStorageDomainId() != null) {
        model.setStorageDomainId(entity.getStorageDomainId().toString());
    }
    if (entity.getDiskId() != null) {
        model.setDiskId(entity.getDiskId().toString());
    }
    if (entity.getStatus() != null) {
        model.setStatus(map(entity.getStatus(), null));
    }
    if (entity.getDiscardMaxSize() != null) {
        model.setDiscardMaxSize(entity.getDiscardMaxSize());
    }
    // Not supported by sysfs since kernel version 4.12, and thus deprecated.
    model.setDiscardZeroesData(false);
    model.setSize(SizeConverter.convert((long) entity.getDeviceSize(), SizeConverter.SizeUnit.GiB, SizeConverter.SizeUnit.BYTES).longValue());
    model.setPaths(entity.getPathCount());
    return model;
}
Also used : LogicalUnit(org.ovirt.engine.api.model.LogicalUnit)

Example 10 with LogicalUnit

use of org.ovirt.engine.api.model.LogicalUnit in project ovirt-engine by oVirt.

the class BackendStorageDomainsResource method mapVolumeGroupFcp.

protected void mapVolumeGroupFcp(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) {
            LogicalUnit unit = map(lun);
            vg.getLogicalUnits().getLogicalUnits().add(unit);
        }
    }
}
Also used : LogicalUnits(org.ovirt.engine.api.model.LogicalUnits) VolumeGroup(org.ovirt.engine.api.model.VolumeGroup) LogicalUnit(org.ovirt.engine.api.model.LogicalUnit) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Aggregations

LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)16 LogicalUnits (org.ovirt.engine.api.model.LogicalUnits)7 Test (org.junit.Test)4 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)4 Action (org.ovirt.engine.api.model.Action)3 VolumeGroup (org.ovirt.engine.api.model.VolumeGroup)3 ArrayList (java.util.ArrayList)2 HostStorage (org.ovirt.engine.api.model.HostStorage)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 ExtendSANStorageDomainParameters (org.ovirt.engine.core.common.action.ExtendSANStorageDomainParameters)2 ReduceSANStorageDomainDevicesCommandParameters (org.ovirt.engine.core.common.action.ReduceSANStorageDomainDevicesCommandParameters)2 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Response (javax.ws.rs.core.Response)1 Disk (org.ovirt.engine.api.model.Disk)1 Host (org.ovirt.engine.api.model.Host)1 IscsiDetailss (org.ovirt.engine.api.model.IscsiDetailss)1 StorageType (org.ovirt.engine.api.model.StorageType)1