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(); } }
protected void mapVolumeGroupFcp(StorageDomain model, org.ovirt.engine.core.common.businessentities.StorageDomain entity) { VolumeGroup vg = model.getStorage().getVolumeGroup(); List<LUNs> luns = getLunsByVgId(vg.getId()); if (luns != null && !luns.isEmpty()) { vg.setLogicalUnits(new LogicalUnits()); for (LUNs lun : luns) { LogicalUnit unit = map(lun); vg.getLogicalUnits().getLogicalUnits().add(unit); } } }
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; }
protected void mapVolumeGroupIscsi(StorageDomain model, org.ovirt.engine.core.common.businessentities.StorageDomain entity) { VolumeGroup vg = model.getStorage().getVolumeGroup(); List<LUNs> luns = getLunsByVgId(vg.getId()); if (luns != null && !luns.isEmpty()) { vg.setLogicalUnits(new LogicalUnits()); for (LUNs lun : luns) { List<StorageServerConnections> lunConnections = lun.getLunConnections(); if (lunConnections != null) { for (StorageServerConnections cnx : lunConnections) { LogicalUnit unit = map(lun); unit = map(cnx, unit); vg.getLogicalUnits().getLogicalUnits().add(unit); } } } } }
/** * 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); } }
@Override protected void verify(HostStorage model, HostStorage transform) { assertNotNull(transform); assertEquals(model.getId(), transform.getId()); assertEquals(model.getType(), transform.getType()); assertNotNull(model.getVolumeGroup()); assertEquals(model.getVolumeGroup().getId(), model.getVolumeGroup().getId()); } }
protected StorageDomain getIscsi() { StorageDomain model = getModel(0); model.getStorage().setType(StorageType.ISCSI); model.getStorage().setAddress(null); model.getStorage().setPath(null); model.getStorage().setVolumeGroup(new VolumeGroup()); model.getStorage().getVolumeGroup().setLogicalUnits(new LogicalUnits()); model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().add(new LogicalUnit()); model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setId(LUN); model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setTarget(TARGET); model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setAddress(ADDRESSES[0]); model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits().get(0).setPort(PORT); model.getStorage().setOverrideLuns(false); return model; }
@Override protected HostStorage postPopulate(HostStorage from) { from.setType(StorageType.FCP); from.setVolumeGroup(new VolumeGroup()); from.getVolumeGroup().setId(from.getId()); return from; }
@Mapping(from = org.ovirt.engine.core.common.businessentities.StorageDomain.class, to = HostStorage.class) public static HostStorage map(org.ovirt.engine.core.common.businessentities.StorageDomain entity, HostStorage template) { HostStorage model = template != null ? template : new HostStorage(); model.setId(entity.getStorage()); model.setType(StorageDomainMapper.map(entity.getStorageType(), null)); model.setVolumeGroup(new VolumeGroup()); model.getVolumeGroup().setId(entity.getStorage()); return model; }
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); } }
host.setId(GUIDS[0].toString()); model.setHost(host); for (LogicalUnit lun : model.getStorage().getVolumeGroup().getLogicalUnits().getLogicalUnits()) { lun.setAddress(null); lun.setTarget(null);
entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.FCP) { model.getStorage().setVolumeGroup(new VolumeGroup()); model.getStorage().getVolumeGroup().setId(entity.getStorage());
to.setVolumeGroup(adaptOut(from.getVolumeGroup()));