Search in sources :

Example 86 with LUNs

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

the class SanStorageModelBase method getUsedLunsMessages.

public ArrayList<String> getUsedLunsMessages(List<LUNs> luns) {
    ArrayList<String> usedLunsMessages = new ArrayList<>();
    UIMessages messages = ConstantsManager.getInstance().getMessages();
    for (LUNs lun : luns) {
        if (lun.getStatus() == LunStatus.Used) {
            String reason = null;
            if (lun.getVolumeGroupId() != null && !lun.getVolumeGroupId().isEmpty()) {
                reason = messages.lunUsedByVG(lun.getVolumeGroupId());
            }
            usedLunsMessages.add(reason == null ? lun.getLUNId() : messages.usedLunIdReason(lun.getLUNId(), reason));
        }
    }
    return usedLunsMessages;
}
Also used : UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 87 with LUNs

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

the class SyncLunsInfoForBlockStorageDomainCommand method refreshLunsConnections.

protected void refreshLunsConnections(List<LUNs> lunsFromVgInfo) {
    for (LUNs lunFromVgInfo : lunsFromVgInfo) {
        // Update lun connections map
        for (StorageServerConnections connection : lunFromVgInfo.getLunConnections()) {
            StorageServerConnections connectionFromDb = storageServerConnectionDao.getForIqn(connection.getIqn());
            if (connectionFromDb == null) {
                // Shouldn't happen
                continue;
            }
            LUNStorageServerConnectionMap lunConnection = new LUNStorageServerConnectionMap(lunFromVgInfo.getLUNId(), connectionFromDb.getId());
            if (storageServerConnectionLunMapDao.get(lunConnection.getId()) == null) {
                storageServerConnectionLunMapDao.save(lunConnection);
            }
        }
    }
}
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 88 with LUNs

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

the class RefreshLunsSizeCommand method updateLunsInDb.

private void updateLunsInDb(List<LUNs> lunsToUpdateInDb) {
    TransactionSupport.executeInNewTransaction(() -> {
        CompensationContext context = getCompensationContext();
        context.snapshotEntities(getParameters().getLunsList());
        lunDao.updateAllInBatch(lunsToUpdateInDb);
        context.stateChanged();
        return null;
    });
    log.debug("LUNs with IDs: [" + lunsToUpdateInDb.stream().map(LUNs::getLUNId).collect(Collectors.joining(", ")) + "] were updated in the DB.");
}
Also used : CompensationContext(org.ovirt.engine.core.bll.context.CompensationContext) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 89 with LUNs

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

the class BackendStorageDomainResourceTest method setUpLuns.

protected List<LUNs> setUpLuns() {
    LUNs lun = new LUNs();
    lun.setLUNId(GUIDS[2].toString());
    List<LUNs> luns = new ArrayList<>();
    luns.add(lun);
    return luns;
}
Also used : ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 90 with LUNs

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

the class GetDeviceListVDSCommand method parseLun.

protected static LUNs parseLun(Map<String, Object> xlun, Version compatibilityVersion) {
    LUNs lun = new LUNs();
    if (xlun.containsKey("GUID")) {
        lun.setLUNId(xlun.get("GUID").toString());
    }
    if (xlun.containsKey("pvUUID")) {
        lun.setPhysicalVolumeId(xlun.get("pvUUID").toString());
    }
    if (xlun.containsKey("vgUUID")) {
        lun.setVolumeGroupId(xlun.get("vgUUID").toString());
    } else {
        lun.setVolumeGroupId("");
    }
    if (xlun.containsKey("vgName")) {
        lun.setStorageDomainId(Guid.createGuidFromString(xlun.get("vgName").toString()));
    }
    if (xlun.containsKey("serial")) {
        lun.setSerial(xlun.get("serial").toString());
    }
    if (xlun.containsKey(PATHSTATUS)) {
        Object[] temp = (Object[]) xlun.get(PATHSTATUS);
        Map<String, Object>[] pathStatus = null;
        if (temp != null) {
            lun.setPathsDictionary(new HashMap<>());
            lun.setPathsCapacity(new HashMap<>());
            pathStatus = new Map[temp.length];
            for (int i = 0; i < temp.length; i++) {
                pathStatus[i] = (Map<String, Object>) temp[i];
            }
            for (Map xcon : pathStatus) {
                if (xcon.containsKey(LUN_FIELD)) {
                    lun.setLunMapping(Integer.parseInt(xcon.get(LUN_FIELD).toString()));
                }
                if (xcon.containsKey(PHYSICAL_DEVICE_FIELD) && xcon.containsKey(DEVICE_STATE_FIELD)) {
                    // set name and state - if active true, otherwise false
                    lun.getPathsDictionary().put(xcon.get(PHYSICAL_DEVICE_FIELD).toString(), DEVICE_ACTIVE_VALUE.equals(xcon.get(DEVICE_STATE_FIELD).toString()));
                }
                if (xcon.containsKey(PHYSICAL_DEVICE_FIELD) && xcon.containsKey(DEVICE_PATH_CAPACITY_FIELD)) {
                    // set name and capacity
                    Long size = IrsBrokerCommand.assignLongValue(xcon, DEVICE_PATH_CAPACITY_FIELD);
                    if (size != null) {
                        lun.getPathsCapacity().put(xcon.get(PHYSICAL_DEVICE_FIELD).toString(), SizeConverter.convert(size, SizeConverter.SizeUnit.BYTES, SizeConverter.SizeUnit.GiB).intValue());
                    }
                }
            }
        }
    }
    if (xlun.containsKey("vendorID")) {
        lun.setVendorId(xlun.get("vendorID").toString());
    }
    if (xlun.containsKey("productID")) {
        lun.setProductId(xlun.get("productID").toString());
    }
    lun.setLunConnections(new ArrayList<>());
    if (xlun.containsKey("pathlist")) {
        Object[] temp = (Object[]) xlun.get("pathlist");
        Map[] pathList = null;
        if (temp != null) {
            pathList = new Map[temp.length];
            for (int i = 0; i < temp.length; i++) {
                pathList[i] = (Map<String, Object>) temp[i];
            }
            for (Map xcon : pathList) {
                lun.getLunConnections().add(parseConnection(xcon));
            }
        }
    }
    Long size = IrsBrokerCommand.assignLongValue(xlun, "devcapacity");
    if (size == null) {
        size = IrsBrokerCommand.assignLongValue(xlun, "capacity");
    }
    if (size != null) {
        lun.setDeviceSize((int) (size / SizeConverter.BYTES_IN_GB));
    }
    if (xlun.containsKey("pvsize")) {
        String pvSizeStr = (String) xlun.get("pvsize");
        if (!StringUtils.isEmpty(pvSizeStr)) {
            Long pvSize = IrsBrokerCommand.assignLongValue(xlun, "pvsize");
            if (pvSize != null) {
                lun.setPvSize(SizeConverter.convert(pvSize, SizeConverter.SizeUnit.BYTES, SizeConverter.SizeUnit.GiB).intValue());
            }
        }
    }
    if (xlun.containsKey("pe_count")) {
        lun.setPeCount(IrsBrokerCommand.assignLongValue(xlun, "pe_count"));
    }
    if (xlun.containsKey("pe_alloc_count")) {
        lun.setPeAllocatedCount(IrsBrokerCommand.assignLongValue(xlun, "pe_alloc_count"));
    }
    if (FeatureSupported.passDiscardSupported(compatibilityVersion)) {
        if (xlun.containsKey("discard_max_bytes")) {
            lun.setDiscardMaxSize(((Number) xlun.get("discard_max_bytes")).longValue());
        }
    }
    if (xlun.containsKey("vendorID")) {
        lun.setVendorName(xlun.get("vendorID").toString());
    }
    if (xlun.containsKey(DEVTYPE_FIELD)) {
        String devtype = xlun.get(DEVTYPE_FIELD).toString();
        if (DEVTYPE_VALUE_FCP.equalsIgnoreCase(devtype)) {
            lun.setLunType(StorageType.FCP);
        } else {
            lun.setLunType(StorageType.ISCSI);
        }
    }
    if (xlun.containsKey(STATUS)) {
        String status = xlun.get(STATUS).toString();
        lun.setStatus(EnumUtils.valueOf(LunStatus.class, status, true));
    }
    return lun;
}
Also used : LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) HashMap(java.util.HashMap) Map(java.util.Map) LunStatus(org.ovirt.engine.core.common.businessentities.storage.LunStatus)

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