/** * Create an instance of {@link HostStorage } * */ public HostStorage createHostStorage() { return new HostStorage(); }
@Override protected Disk postPopulate(Disk model) { model.setFormat(DiskFormat.COW); model.setStatus(DiskStatus.LOCKED); model.setLunStorage(new HostStorage()); return model; }
@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; }
@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; }
private Disk createIscsiLunDisk() { Disk model = getModel(); model.setLunStorage(new HostStorage()); model.getLunStorage().setType(StorageType.ISCSI); model.getLunStorage().setLogicalUnits(new LogicalUnits()); model.getLunStorage().getLogicalUnits().getLogicalUnits().add(new LogicalUnit()); model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setId(GUIDS[0].toString()); model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setAddress(ISCSI_SERVER_ADDRESS); model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setTarget(ISCSI_SERVER_TARGET); model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setPort(ISCSI_SERVER_CONNECTION_PORT); model.setProvisionedSize(null); return model; }
@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()); }
@Test public void testStorageLinks() { HostStorage storage = new HostStorage(); storage.setId(STORAGE_ID); storage.setHost(new Host()); storage.getHost().setId(HOST_ID); LinkHelper.addLinks(storage); assertEquals(STORAGE_HREF, storage.getHref()); assertEquals(HOST_HREF, storage.getHost().getHref()); }
model.setExternalStatus(ExternalStatusMapper.map(entity.getExternalStatus())); model.setStorage(new HostStorage()); model.getStorage().setType(map(entity.getStorageType(), null)); if (entity.getStorageType() == org.ovirt.engine.core.common.businessentities.storage.StorageType.ISCSI ||
@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"); }
@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"); }
model.setDescription(getSafeEntry(POSIX_IDX, DESCRIPTIONS)); model.setType(getSafeEntry(POSIX_IDX, TYPES)); model.setStorage(new HostStorage()); model.setHost(new Host()); model.getHost().setId(GUIDS[0].toString());
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; }
@Mapping(from = org.ovirt.engine.core.common.businessentities.storage.Disk.class, to = Disk.class) public static Disk map(org.ovirt.engine.core.common.businessentities.storage.Disk entity, Disk template) { Disk model = template != null ? template : new Disk(); // name is depreciated, use alias instead. model.setName(entity.getDiskAlias()); model.setAlias(entity.getDiskAlias()); if (entity.getId() != null) { model.setId(entity.getId().toString()); } model.setPropagateErrors(PropagateErrors.On == entity.getPropagateErrors()); model.setWipeAfterDelete(entity.isWipeAfterDelete()); model.setShareable(entity.isShareable()); model.setDescription(entity.getDiskDescription()); model.setLogicalName(entity.getLogicalName()); model.setStorageType(map(entity.getDiskStorageType())); if (entity.getDiskStorageType() == org.ovirt.engine.core.common.businessentities.storage.DiskStorageType.IMAGE || entity.getDiskStorageType() == org.ovirt.engine.core.common.businessentities.storage.DiskStorageType.CINDER || entity.getDiskStorageType() == org.ovirt.engine.core.common.businessentities.storage.DiskStorageType.MANAGED_BLOCK_STORAGE) { mapDiskImageToDiskFields((DiskImage) entity, model); } else { model.setLunStorage(StorageLogicalUnitMapper.map(((LunDisk) entity).getLun(), new HostStorage())); if (entity.getSgio() != null) { model.setSgio(map(entity.getSgio(), null)); } } model.setContentType(mapDiskContentType(entity.getContentType())); return model; }
@Override public HostStorage adapt(V3Storage from) { HostStorage to = new HostStorage(); if (from.isSetLinks()) { to.getLinks().addAll(adaptIn(from.getLinks()));
@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()); }