private static String getLogicalUnitId(Disk disk) { if (disk.getLunStorage() != null && disk.getLunStorage().getLogicalUnits() != null && disk.getLunStorage().getLogicalUnits().getLogicalUnits().size() > 0) { return disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).getId(); } // In case no LUN id was found we return empty GUID to avoid null key initialization in the map. return Guid.Empty.toString(); }
/** * This mapping exists for adding a lun-disk, and assumes that 'storage' entity contains exactly one lun. */ @Mapping(from = HostStorage.class, to = LUNs.class) public static LUNs map(HostStorage model, LUNs template) { LUNs entity = template != null ? template : new LUNs(); if (model.isSetLogicalUnits() && model.getLogicalUnits().isSetLogicalUnits()) { LogicalUnit logicalUnit = model.getLogicalUnits().getLogicalUnits().get(0); entity.setLUNId(logicalUnit.getId()); ArrayList<StorageServerConnections> connections = new ArrayList<>(); connections.add(map(logicalUnit, null)); entity.setLunConnections(connections); } if (model.isSetType()) { entity.setLunType(StorageDomainMapper.map(model.getType(), null)); } return entity; }
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"); // if the address and target were not supplied, we understand from this that // the user assumes that the host is already logged-in to the target of this lun. // so in this case we do not need (and do not have the required information) to login // to the target. if ((storageType == StorageType.ISCSI) && !isConnectionAssumed(unit)) { connectStorageToHost(hostId, storageType, unit); } lunIds.add(unit.getId()); } refreshHostStorage(hostId); return !lunIds.isEmpty() ? lunIds : null; }
@Override protected void verify(HostStorage model, HostStorage transform) { assertNotNull(transform); assertEquals(model.getId(), transform.getId()); assertEquals(model.getType(), transform.getType()); assertEquals(model.getLogicalUnits().getLogicalUnits().size(), model.getLogicalUnits().getLogicalUnits().size()); for (int i = 0; i < model.getLogicalUnits().getLogicalUnits().size(); i++) { assertEquals(model.getLogicalUnits().getLogicalUnits().get(i).getId(), transform.getLogicalUnits().getLogicalUnits().get(i).getId()); } }
@Override protected void verifyModel(HostStorage model, int index) { assertEquals(StorageType.ISCSI, model.getType()); assertEquals(GUIDS[index].toString(), model.getId()); assertEquals(1, model.getLogicalUnits().getLogicalUnits().size()); assertEquals(GUIDS[index].toString(), model.getLogicalUnits().getLogicalUnits().get(0).getId()); verifyLinks(model); }
&& disk.getLunStorage()!=null && disk.getLunStorage().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits().size() > 0 && disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).getTarget()!=null && disk.getLunStorage()!=null && disk.getLunStorage().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits().size() > 0 && disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).getPort()!=null && disk.getLunStorage()!=null && disk.getLunStorage().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits().size() > 0 && disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).getId()!=null && disk.getLunStorage()!=null && disk.getLunStorage().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits()!=null && disk.getLunStorage().getLogicalUnits().getLogicalUnits().size() > 0 && disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).getAddress()!=null && disk.getLunStorage()!=null && disk.getLunStorage().getType()!=null
&& storageDomain.getStorage()!=null && storageDomain.getStorage().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().size() > 0 && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().get(0).getTarget()!=null && storageDomain.getStorage()!=null && storageDomain.getStorage().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().size() > 0 && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().get(0).getPort()!=null && storageDomain.getStorage()!=null && storageDomain.getStorage().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().size() > 0 && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().get(0).getId()!=null && storageDomain.getStorage()!=null && storageDomain.getStorage().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits()!=null && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().size() > 0 && storageDomain.getStorage().getLogicalUnits().getLogicalUnits().get(0).getAddress()!=null ) {
protected void verifyIscsi(StorageDomain model) { assertEquals(GUIDS[0].toString(), model.getId()); assertEquals(NAMES[0], model.getName()); assertEquals(TYPES[0], model.getType()); assertNotNull(model.getStorage()); assertEquals(StorageType.ISCSI, model.getStorage().getType()); assertNotNull(model.getStorage().getVolumeGroup()); assertEquals(GUIDS[GUIDS.length - 1].toString(), model.getStorage().getVolumeGroup().getId()); assertTrue(model.getStorage().getVolumeGroup().isSetLogicalUnits()); assertNotNull(model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0)); assertEquals(LUN, model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).getId()); assertEquals(TARGET, model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).getTarget()); assertEquals(ADDRESSES[0], model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).getAddress()); assertEquals(PORT, model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).getPort()); assertEquals(7, model.getLinks().size()); assertNotNull(getLinkByName(model, "permissions")); assertNotNull(model.getLinks().get(0).getHref()); verifyLinks(model); } }
to.setId(from.getId());