private StorageConnections mapCollection(List<StorageServerConnections> entities) { StorageConnections conns = new StorageConnections(); for (StorageServerConnections entity : entities) { StorageConnection conn = StorageDomainMapper.map(entity, null); conns.getStorageConnections().add(addLinks(populate(conn, entity))); } return conns; } }
StorageDomainMapper.map(NfsVersion.V3, null)); assertEquals(org.ovirt.engine.core.common.businessentities.NfsVersion.V4, StorageDomainMapper.map(NfsVersion.V4, null)); assertEquals(org.ovirt.engine.core.common.businessentities.NfsVersion.AUTO, StorageDomainMapper.map(NfsVersion.AUTO, null)); assertEquals(NfsVersion.V3, StorageDomainMapper.map(org.ovirt.engine.core.common .businessentities.NfsVersion.V3, null)); assertEquals(NfsVersion.V4, StorageDomainMapper.map(org.ovirt.engine.core.common .businessentities.NfsVersion.V4, null)); assertEquals(NfsVersion.AUTO, StorageDomainMapper.map(org.ovirt.engine.core.common .businessentities.NfsVersion.AUTO, null));
@Override public Response add(StorageConnection conn) { StorageServerConnections entity = StorageDomainMapper.map(conn, null); IscsiBond iscsiBond = getIscsiBond(); iscsiBond.getStorageConnectionIds().add(entity.getId()); return performAction(ActionType.EditIscsiBond, new EditIscsiBondParameters(iscsiBond)); }
model.setDescription(entity.getDescription()); model.setComment(entity.getComment()); model.setType(map(entity.getStorageDomainType(), null)); model.setWarningLowSpaceIndicator(entity.getWarningLowSpaceIndicator()); model.setCriticalSpaceActionBlocker(entity.getCriticalSpaceActionBlocker()); model.getStorage().setType(map(entity.getStorageType(), null)); if (entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI || entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.FCP) {
@Mapping(from = HostStorage.class, to = org.ovirt.engine.core.common.businessentities.StorageDomain.class) public static org.ovirt.engine.core.common.businessentities.StorageDomain map(HostStorage model, org.ovirt.engine.core.common.businessentities.StorageDomain template) { org.ovirt.engine.core.common.businessentities.StorageDomain entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.StorageDomain(); entity.setStorage(model.getId()); if (model.isSetType()) { entity.setStorageType(StorageDomainMapper.map(model.getType(), null)); } return entity; } }
@Mapping(from = LUNs.class, to = HostStorage.class) public static HostStorage map(LUNs entity, HostStorage template) { HostStorage model = template != null ? template : new HostStorage(); model.setId(entity.getLUNId()); model.setType(StorageDomainMapper.map(entity.getLunType(), null)); model.setLogicalUnits(new LogicalUnits()); model.getLogicalUnits().getLogicalUnits().add(map(entity, (LogicalUnit) null)); return model; }
/** * 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; }
protected void mapFileDomain(StorageDomain model, org.ovirt.engine.core.common.businessentities.StorageDomain entity) { final HostStorage storage = model.getStorage(); StorageServerConnections cnx = getStorageServerConnection(entity.getStorage()); if (cnx.getConnection().startsWith("[")) { String[] parts = cnx.getConnection().split("]:"); storage.setAddress(parts[0].substring(1)); storage.setPath(parts[1]); } else if (cnx.getConnection().contains(":")) { String[] parts = cnx.getConnection().split(":"); storage.setAddress(parts[0]); storage.setPath(parts[1]); } else { storage.setPath(cnx.getConnection()); } storage.setMountOptions(cnx.getMountOptions()); storage.setVfsType(cnx.getVfsType()); if (entity.getStorageType() == StorageType.NFS) { if (cnx.getNfsRetrans() != null) { storage.setNfsRetrans(cnx.getNfsRetrans().intValue()); } if (cnx.getNfsTimeo() != null) { storage.setNfsTimeo(cnx.getNfsTimeo().intValue()); } if (cnx.getNfsVersion() != null) { storage.setNfsVersion(StorageDomainMapper.map(cnx.getNfsVersion(), null)); } } }
private Response addExistingSAN(StorageDomain model, StorageType storageType, Guid hostId) { getEntity(VDS.class, QueryType.GetVdsByVdsId, new IdQueryParameters(hostId), "Host: id=" + hostId); List<LUNs> existingLuns = getDeviceList(hostId, storageType); List<StorageServerConnections> existingStorageServerConnections = getLunsWithInitializedStorageType(existingLuns, storageType); List<org.ovirt.engine.core.common.businessentities.StorageDomain> existingStorageDomains = getExistingBlockStorageDomain(hostId, storageType, existingStorageServerConnections); StorageDomainStatic storageDomainToImport = getMatchingStorageDomain(asGuid(model.getId()), existingStorageDomains); if (storageDomainToImport == null) { throw new WebFaultException(new WebApplicationException(), "Storage Domain id " + model.getId() + " Does not exists", Status.NOT_FOUND); } StorageDomainMapper.map(model, storageDomainToImport); StorageDomainManagementParameter parameters = new StorageDomainManagementParameter(storageDomainToImport); parameters.setVdsId(hostId); return performCreate(ActionType.AddExistingBlockStorageDomain, parameters, ID_RESOLVER); }
@Test public void testMemory() { org.ovirt.engine.core.common.businessentities.StorageDomain entity = new org.ovirt.engine.core.common.businessentities.StorageDomain(); entity.setAvailableDiskSize(3); entity.setUsedDiskSize(4); entity.setCommittedDiskSize(5); StorageDomain model = StorageDomainMapper.map(entity, null); assertEquals(Long.valueOf(3221225472L), model.getAvailable()); assertEquals(Long.valueOf(4294967296L), model.getUsed()); assertEquals(Long.valueOf(5368709120L), model.getCommitted()); }
@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; }
StorageConnection model = template != null ? template : new StorageConnection(); model.setId(entity.getId()); model.setType(map(entity.getStorageType(), null)); if (entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI) { model.setAddress(entity.getConnection()); model.setNfsVersion(map(entity.getNfsVersion(), null));
connection); if (existing != null) { StorageDomainMapper.map(model, existing.getStorageStaticData()); entity = existing.getStorageStaticData(); action = ActionType.AddExistingFileStorageDomain;
@Test public void checkPosixStorageConnectionsMappingsToBll() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.POSIXFS); connection.setConnection("1.2.135.255:/myshare/data"); connection.setVfsType("nfs"); connection.setMountOptions("timeo=30"); StorageConnection RESTConnection = new StorageConnection(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.POSIXFS); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setPath("/myshare/data"); RESTConnection.setVfsType("nfs"); RESTConnection.setMountOptions("timeo=30"); StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null); assertEquals(connection.getId(), mappedResult.getId()); assertEquals(connection.getStorageType(), mappedResult.getStorageType()); assertEquals(connection.getConnection(), mappedResult.getConnection()); assertEquals(connection.getVfsType(), mappedResult.getVfsType()); assertEquals(connection.getMountOptions(), mappedResult.getMountOptions()); }
@Test public void checkPosixStorageConnectionsMappings() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.POSIXFS); connection.setConnection("1.2.135.255:/myshare/data"); connection.setVfsType("nfs"); connection.setMountOptions("timeo=30"); HostStorage RESTConnection = new HostStorage(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.POSIXFS); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setPath("/myshare/data"); RESTConnection.setVfsType("nfs"); RESTConnection.setMountOptions("timeo=30"); StorageConnection mappedResult = StorageDomainMapper.map(connection, null); assertEquals(RESTConnection.getId(), mappedResult.getId()); assertEquals(RESTConnection.getType(), mappedResult.getType()); assertEquals(RESTConnection.getAddress(), mappedResult.getAddress()); assertEquals(RESTConnection.getVfsType(), mappedResult.getVfsType()); assertEquals(RESTConnection.getPath(), mappedResult.getPath()); assertEquals(RESTConnection.getMountOptions(), mappedResult.getMountOptions()); }
@Test public void checkISCSIStorageConnectionsMappings() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setIqn("iqn.my.target1"); connection.setPort("3260"); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI); connection.setConnection("1.2.135.255"); connection.setUserName("myuser1"); connection.setPassword("123"); HostStorage RESTConnection = new HostStorage(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.ISCSI); RESTConnection.setPort(3260); RESTConnection.setTarget("iqn.my.target1"); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setUsername("myuser1"); StorageConnection mappedResult = StorageDomainMapper.map(connection, null); assertEquals(RESTConnection.getId(), mappedResult.getId()); // Although password was set on StorageServerConnections object, it should not be returned via REST // thus testing here that it remains empty. assertEquals(RESTConnection.getPassword(), mappedResult.getPassword()); assertEquals(RESTConnection.getType(), mappedResult.getType()); assertEquals(RESTConnection.getAddress(), mappedResult.getAddress()); assertEquals(RESTConnection.getUsername(), mappedResult.getUsername()); assertEquals(RESTConnection.getTarget(), mappedResult.getTarget()); }
@Test public void checkISCSISStorageConnectionsMappingsToBll() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setIqn("iqn.my.target1"); connection.setPort("3260"); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI); connection.setConnection("1.2.135.255"); connection.setUserName("myuser1"); connection.setPassword("123"); StorageConnection RESTConnection = new StorageConnection(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.ISCSI); RESTConnection.setPort(3260); RESTConnection.setTarget("iqn.my.target1"); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setUsername("myuser1"); RESTConnection.setPassword("123"); StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null); assertEquals(mappedResult.getId(), mappedResult.getId()); assertEquals(mappedResult.getStorageType(), mappedResult.getStorageType()); assertEquals(mappedResult.getConnection(), mappedResult.getConnection()); assertEquals(mappedResult.getIqn(), mappedResult.getIqn()); assertEquals(mappedResult.getUserName(), mappedResult.getUserName()); assertEquals(mappedResult.getPassword(), mappedResult.getPassword()); assertEquals(mappedResult.getPort(), mappedResult.getPort()); }
@Test public void checkNFSStorageConnectionsMappingsToBll() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.NFS); connection.setConnection("1.2.135.255:/myshare/data"); connection.setNfsRetrans((short) 200); connection.setNfsTimeo((short) 400); connection.setNfsVersion(org.ovirt.engine.core.common.businessentities.NfsVersion.V3); connection.setMountOptions("tcp"); StorageConnection RESTConnection = new StorageConnection(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.NFS); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setPath("/myshare/data"); RESTConnection.setNfsRetrans(200); RESTConnection.setNfsTimeo(400); RESTConnection.setNfsVersion(NfsVersion.V3); RESTConnection.setMountOptions("tcp"); StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null); assertEquals(connection.getId(), mappedResult.getId()); assertEquals(connection.getStorageType(), mappedResult.getStorageType()); assertEquals(connection.getConnection(), mappedResult.getConnection()); assertEquals(connection.getNfsRetrans(), mappedResult.getNfsRetrans()); assertEquals(connection.getNfsTimeo(), mappedResult.getNfsTimeo()); assertEquals(connection.getNfsVersion(), mappedResult.getNfsVersion()); assertEquals(connection.getMountOptions(), mappedResult.getMountOptions()); }
@Test public void checkNFSStorageConnectionsMappings() { StorageServerConnections connection = new StorageServerConnections(); Guid connId = Guid.newGuid(); connection.setId(connId.toString()); connection.setStorageType(org.ovirt.engine.core.common.businessentities.storage.StorageType.NFS); connection.setConnection("1.2.135.255:/myshare/data"); connection.setNfsRetrans((short) 200); connection.setNfsTimeo((short) 400); connection.setNfsVersion(org.ovirt.engine.core.common.businessentities.NfsVersion.V3); connection.setMountOptions("tcp"); HostStorage RESTConnection = new HostStorage(); RESTConnection.setId(connId.toString()); RESTConnection.setType(StorageType.NFS); RESTConnection.setAddress("1.2.135.255"); RESTConnection.setPath("/myshare/data"); RESTConnection.setNfsRetrans(200); RESTConnection.setNfsTimeo(400); RESTConnection.setNfsVersion(NfsVersion.V3); RESTConnection.setMountOptions("tcp"); StorageConnection mappedResult = StorageDomainMapper.map(connection, null); assertEquals(RESTConnection.getId(), mappedResult.getId()); assertEquals(RESTConnection.getType(), mappedResult.getType()); assertEquals(RESTConnection.getAddress(), mappedResult.getAddress()); assertEquals(RESTConnection.getPath(), mappedResult.getPath()); assertEquals(RESTConnection.getNfsRetrans(), mappedResult.getNfsRetrans()); assertEquals(RESTConnection.getNfsTimeo(), mappedResult.getNfsTimeo()); assertEquals(RESTConnection.getNfsVersion(), mappedResult.getNfsVersion()); assertEquals(RESTConnection.getMountOptions(), mappedResult.getMountOptions()); }