public static boolean isLunDisk(Disk disk) { return disk.isSetLunStorage() && disk.getLunStorage().isSetLogicalUnits() && disk.getLunStorage().getLogicalUnits().isSetLogicalUnits(); } }
private List<LogicalUnit> getIncomingLuns(HostStorage storage) { // user may pass the LUNs under Storage, or Storage-->VolumeGroup; both are supported. if (!storage.isSetLogicalUnits() || !storage.getLogicalUnits().isSetLogicalUnits()) { if (storage.isSetVolumeGroup() && storage.getVolumeGroup().isSetLogicalUnits() && storage.getVolumeGroup().getLogicalUnits().isSetLogicalUnits()) { return storage.getVolumeGroup().getLogicalUnits().getLogicalUnits(); } else { return new ArrayList<>(); } } else { return storage.getLogicalUnits().getLogicalUnits(); } }
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; }
/** * 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 void validateDiskForCreation(Disk disk) { if (DiskResourceUtils.isLunDisk(disk)) { validateParameters(disk.getLunStorage(), 2, "type"); // when creating a LUN disk, user must specify type. StorageType storageType = disk.getLunStorage().getType(); if (storageType != null && storageType == StorageType.ISCSI) { validateParameters(disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0), 3, "address", "target", "port", "id"); } } else if (disk.isSetLunStorage() && (!disk.getLunStorage().isSetLogicalUnits() || !disk.getLunStorage().getLogicalUnits().isSetLogicalUnits())) { // TODO: Implement nested entity existence validation infra for validateParameters() throw new WebFaultException( null, localize(Messages.INCOMPLETE_PARAMS_REASON), localize(Messages.INCOMPLETE_PARAMS_DETAIL_TEMPLATE, "LogicalUnit", "", "add"), Response.Status.BAD_REQUEST ); } else { validateParameters(disk, 2, "provisionedSize|size", "format"); // Non lun disks require size and format } }
protected void validateDiskForCreation(Disk disk) { if (DiskResourceUtils.isLunDisk(disk)) { validateParameters(disk.getLunStorage(), 2, "type"); // when creating a LUN disk, user must specify type. StorageType storageType = disk.getLunStorage().getType(); if (storageType != null && storageType == StorageType.ISCSI) { validateParameters(disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0), 3, "address", "target", "port", "id"); } } else if (disk.isSetLunStorage() && (!disk.getLunStorage().isSetLogicalUnits() || !disk.getLunStorage().getLogicalUnits().isSetLogicalUnits())) { // TODO: Implement nested entity existence validation infra for validateParameters() throw new WebFaultException(null, localize(Messages.INCOMPLETE_PARAMS_REASON), localize(Messages.INCOMPLETE_PARAMS_DETAIL_TEMPLATE, "LogicalUnit", "", "add"), Response.Status.BAD_REQUEST); } else { validateParameters(disk, 2, "provisionedSize", "format"); // Non lun disks require size and format } }
protected void validateDiskForCreation(Disk disk) { validateParameters(disk); if (DiskResourceUtils.isLunDisk(disk)) { validateParameters(disk.getLunStorage(), 4, "type"); // when creating a LUN disk, user must specify type. StorageType storageType = disk.getLunStorage().getType(); if (storageType != null && storageType == StorageType.ISCSI) { validateParameters(disk.getLunStorage().getLogicalUnits().getLogicalUnits().get(0), 4, "address", "target", "port", "id"); } } else if (disk.isSetLunStorage() && (!disk.getLunStorage().isSetLogicalUnits() || !disk.getLunStorage().getLogicalUnits().isSetLogicalUnits())) { // TODO: Implement nested entity existence validation infra for validateParameters() throw new WebFaultException(null, localize(Messages.INCOMPLETE_PARAMS_REASON), localize(Messages.INCOMPLETE_PARAMS_DETAIL_TEMPLATE, "LogicalUnit", "", "add"), Response.Status.BAD_REQUEST); } else { validateParameters(disk, 4, "provisionedSize|size", "format"); // Non lun disks require size and format } }