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)); } } }
@Test public void testStorageDomainLinks() { StorageDomain storageDomain = new StorageDomain(); storageDomain.setId(STORAGE_DOMAIN_ID); storageDomain.setStorage(new HostStorage()); storageDomain.getStorage().setPath("foo"); LinkHelper.addLinks(storageDomain); assertEquals(STORAGE_DOMAIN_HREF, storageDomain.getHref()); assertNull(storageDomain.getStorage().getHref()); }
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; }
@Test public void testAddIncompleteNfsStorageParameters() { StorageDomain model = getModel(0); model.setName(NAMES[0]); model.setHost(new Host()); model.getHost().setId(GUIDS[0].toString()); model.setStorage(new HostStorage()); model.getStorage().setType(StorageType.NFS); model.getStorage().setPath(PATHS[0]); setUriInfo(setUpBasicUriExpectations()); verifyIncompleteException( assertThrows(WebApplicationException.class, () -> collection.add(model)), "HostStorage", "add", "address"); }
@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.setPath(from.getPath());
@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 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()); }