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();
}
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());
}
}
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);
}
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());
}
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());
}
Aggregations