Search in sources :

Example 16 with LUNs

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

the class SanStorageModelBase method applyData.

/**
 * Creates model items from the provided list of business entities.
 */
public void applyData(List<LUNs> source, boolean isIncluded, Collection<EntityModel<?>> selectedItems, boolean isInMaintenance, Set<String> metadataDevices) {
    ArrayList<LunModel> newItems = new ArrayList<>();
    for (LUNs a : source) {
        if (a.getLunType() == getType() || a.getLunType() == StorageType.UNKNOWN) {
            ArrayList<SanTargetModel> targets = createTargetModelList(a);
            LunModel lunModel = new LunModel();
            lunModel.setLunId(a.getLUNId());
            lunModel.setVendorId(a.getVendorId());
            lunModel.setProductId(a.getProductId());
            lunModel.setSerial(a.getSerial());
            lunModel.setMultipathing(a.getPathCount());
            lunModel.setTargets(targets);
            lunModel.setSize(a.getDeviceSize());
            lunModel.setAdditionalAvailableSize(getAdditionalAvailableSize(a));
            lunModel.setAdditionalAvailableSizeSelected(false);
            lunModel.setRemoveLunSelected(false);
            lunModel.setIsAccessible(a.getAccessible());
            lunModel.setStatus(a.getStatus());
            lunModel.setIsIncluded(lunModel.getIsIncluded() || isIncluded);
            lunModel.setIsSelected(containsLun(lunModel, selectedItems, isIncluded));
            lunModel.setEntity(a);
            // Add LunModel
            newItems.add(lunModel);
            // Update isGrayedOut and grayedOutReason properties
            updateGrayedOut(isInMaintenance, metadataDevices, lunModel);
            // Remember included LUNs to prevent their removal while updating items.
            if (isIncluded) {
                includedLUNs.add(lunModel);
            }
        }
    }
    initializeItems(newItems, null);
    proposeDiscover();
    updateRemovableLuns();
    getContainer().stopProgress();
}
Also used : ArrayList(java.util.ArrayList) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 17 with LUNs

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

the class SanStorageModelBase method updateGrayedOut.

private void updateGrayedOut(boolean isInMaintenance, Set<String> metadataDevices, LunModel lunModel) {
    UIConstants constants = ConstantsManager.getInstance().getConstants();
    UIMessages messages = ConstantsManager.getInstance().getMessages();
    LUNs lun = lunModel.getEntity();
    boolean nonEmpty = lun.getStorageDomainId() != null || lun.getDiskId() != null || lun.getStatus() == LunStatus.Unusable;
    // Graying out LUNs
    lunModel.setIsGrayedOut(isIgnoreGrayedOut() ? lun.getDiskId() != null : nonEmpty);
    // Adding 'GrayedOutReasons'
    if (lun.getDiskId() != null) {
        lunModel.getGrayedOutReasons().add(messages.lunUsedByDiskWarning(lun.getDiskAlias()));
    } else if (lun.getStorageDomainId() != null && !isInMaintenance) {
        lunModel.getGrayedOutReasons().add(messages.lunAlreadyPartOfStorageDomainWarning(lun.getStorageDomainName()));
    } else if (isInMaintenance && metadataDevices.contains(lun.getId())) {
        lunModel.getGrayedOutReasons().add(messages.lunIsMetadataDevice(lun.getStorageDomainName()));
    } else if (lun.getStatus() == LunStatus.Unusable) {
        lunModel.getGrayedOutReasons().add(constants.lunUnusable());
    }
}
Also used : UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 18 with LUNs

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

the class GetDeviceListVDSCommandTest method testDiscardFieldParsing.

private void testDiscardFieldParsing(Version poolCompatibilityVersion, Long expectedDiscardMaxSize) {
    Map<String, Object> xlun = new HashMap<>();
    xlun.put("discard_max_bytes", 1024L);
    LUNs lun = GetDeviceListVDSCommand.parseLun(xlun, poolCompatibilityVersion);
    assertEquals(lun.getDiscardMaxSize(), expectedDiscardMaxSize);
}
Also used : HashMap(java.util.HashMap) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs)

Example 19 with LUNs

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

the class GetDeviceListVDSCommandTest method parseLunPathStatus.

@Test
public void parseLunPathStatus() throws Exception {
    int numActivePaths = 1 + RandomUtils.instance().nextInt(3);
    int numNonActivePaths = 2 + RandomUtils.instance().nextInt(3);
    int numPaths = numActivePaths + numNonActivePaths;
    // Randomize some devices
    String physicalDevicePrefix = "physical";
    List<Map<String, Object>> paths = new ArrayList<>(numPaths);
    for (int i = 0; i < numPaths; ++i) {
        Map<String, Object> path = new HashMap<>();
        path.put(GetDeviceListVDSCommand.LUN_FIELD, String.valueOf(i));
        path.put(GetDeviceListVDSCommand.PHYSICAL_DEVICE_FIELD, physicalDevicePrefix + i);
        path.put(GetDeviceListVDSCommand.DEVICE_STATE_FIELD, i < numActivePaths ? GetDeviceListVDSCommand.DEVICE_ACTIVE_VALUE : RandomUtils.instance().nextString(10));
        paths.add(path);
    }
    Map<String, Object> xlun = new HashMap<>();
    xlun.put(GetDeviceListVDSCommand.PATHSTATUS, paths.toArray(new Map[paths.size()]));
    // Parse lun
    LUNs lun = GetDeviceListVDSCommand.parseLun(xlun, Version.v4_1);
    // Go over the directory
    assertEquals("wrong number of paths", numPaths, lun.getPathCount());
    Map<String, Boolean> pathDir = new HashMap<>(lun.getPathsDictionary());
    for (int i = 0; i < numPaths; ++i) {
        // Assert for each device
        String device = physicalDevicePrefix + i;
        Boolean isActive = pathDir.remove(device);
        assertNotNull("Device " + device + " isn't in the device map", isActive);
        assertEquals("Device " + device + " has the wrong state ", i < numActivePaths, isActive);
    }
    // After remove all the expected devices, the directory should be empty
    assertTrue("Wrong devices in the device map", pathDir.isEmpty());
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) LUNs(org.ovirt.engine.core.common.businessentities.storage.LUNs) Test(org.junit.Test)

Example 20 with LUNs

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

the class GetDeviceListVDSCommandTest method testParseLunForDevtypeField.

/**
 * Test that parseLun parses the {@link GetDeviceListVDSCommand#DEVTYPE_FIELD} correctly.
 *
 * @param expectedStorageType
 *            The storage type expected to return.
 * @param mockDevtype
 *            The value that the XML RPC will hold.
 */
private static void testParseLunForDevtypeField(StorageType expectedStorageType, String mockDevtype) {
    Map<String, Object> xlun = new HashMap<>();
    xlun.put(GetDeviceListVDSCommand.DEVTYPE_FIELD, mockDevtype);
    LUNs lun = GetDeviceListVDSCommand.parseLun(xlun, Version.v4_1);
    assertEquals(expectedStorageType, lun.getLunType());
}
Also used : 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