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)); } } }
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; }
model.getStorage().setAddress(null); model.setHost(new Host()); model.getHost().setId(GUIDS[0].toString());
@Test public void testAddIncompleteDomainParameters() { StorageDomain model = getModel(0); model.setName(NAMES[0]); model.setHost(new Host()); model.getHost().setId(GUIDS[0].toString()); model.setStorage(new HostStorage()); model.getStorage().setAddress(ADDRESSES[0]); model.getStorage().setPath(PATHS[0]); setUriInfo(setUpBasicUriExpectations()); verifyIncompleteException( assertThrows(WebApplicationException.class, () -> collection.add(model)), "StorageDomain", "add", "storage.type"); }
static StorageDomain getModel(int index) { StorageDomain model = new StorageDomain(); model.setName(getSafeEntry(index, NAMES)); model.setDescription(getSafeEntry(index, DESCRIPTIONS)); model.setType(getSafeEntry(index, TYPES)); model.setStorage(new HostStorage()); model.getStorage().setType(getSafeEntry(index, STORAGE_TYPES)); model.getStorage().setAddress(getSafeEntry(index, ADDRESSES)); model.getStorage().setPath(getSafeEntry(index, PATHS)); model.getStorage().setMountOptions(getSafeEntry(index, MOUNT_OPTIONS)); model.getStorage().setVfsType(getSafeEntry(index, VFS_TYPES)); return model; }
to.setAddress(from.getAddress());
@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 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()); }