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; }
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(); } }
/** * if user added new LUNs - extend the storage domain. */ private void extendStorageDomain(StorageDomain incoming, StorageDomain storageDomain) { if (incoming.getStorage() == null) { // LUNs info was not supplied in the request so no need to check whether to extend return; } List<LogicalUnit> existingLuns; if (storageDomain.isSetStorage() && storageDomain.getStorage().isSetVolumeGroup() && storageDomain.getStorage().getVolumeGroup().isSetLogicalUnits()) { existingLuns = storageDomain.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits(); } else { existingLuns = Collections.emptyList(); } List<LogicalUnit> incomingLuns = getIncomingLuns(incoming.getStorage()); List<LogicalUnit> newLuns = findNewLuns(existingLuns, incomingLuns); boolean overrideLuns = incoming.getStorage().isSetOverrideLuns() ? incoming.getStorage().isOverrideLuns() : false; if (!newLuns.isEmpty()) { // If there are new LUNs, this means the user wants to extend the storage domain. addLunsToStorageDomain(newLuns, overrideLuns); // Remove the new LUNs from the incoming LUns before update, since they have already been dealt with. incomingLuns.removeAll(newLuns); } }
to.setVfsType(from.getVfsType()); if (from.isSetVolumeGroup()) { to.setVolumeGroup(adaptOut(from.getVolumeGroup()));