use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class LunDiskMapperTest method postPopulate.
@Override
protected Disk postPopulate(Disk model) {
model.setFormat(MappingTestHelper.shuffle(DiskFormat.class));
model.setStatus(MappingTestHelper.shuffle(DiskStatus.class));
model.setLunStorage(new HostStorage());
return model;
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class StorageDomainMapperTest method checkPosixStorageConnectionsMappings.
@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());
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class StorageDomainMapperTest method checkISCSIStorageConnectionsMappings.
@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());
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class BackendStorageDomainsResource method mapFileDomain.
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().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));
}
}
}
use of org.ovirt.engine.api.model.HostStorage in project ovirt-engine by oVirt.
the class BackendStorageDomainsResource method add.
@Override
public Response add(StorageDomain storageDomain) {
validateParameters(storageDomain, "host.id|name", "type", "storage");
validateRange("nfs_timeio", storageDomain.getStorage().getNfsTimeo(), 0, 65535);
validateRange("nfs_retrans", storageDomain.getStorage().getNfsRetrans(), 0, 65535);
HostStorage storageConnectionFromUser = storageDomain.getStorage();
Guid hostId = getHostId(storageDomain);
StorageServerConnections cnx = null;
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain, "storage.type");
cnx = mapToCnx(storageDomain);
if (cnx.getStorageType().isFileDomain()) {
validateParameters(storageConnectionFromUser, "path");
}
} else {
cnx = getStorageServerConnection(storageConnectionFromUser.getId());
storageDomain.getStorage().setType(mapType(cnx.getStorageType()));
}
StorageDomainStatic entity = mapToStatic(storageDomain);
Response resp = null;
switch(entity.getStorageType()) {
case ISCSI:
case FCP:
if (storageDomain.isSetImport() && storageDomain.isImport()) {
validateParameters(storageDomain, "id");
resp = addExistingSAN(storageDomain, entity.getStorageType(), hostId);
} else {
resp = addSAN(storageDomain, entity.getStorageType(), entity, hostId);
}
break;
case NFS:
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain.getStorage(), "address");
}
resp = addDomain(ActionType.AddNFSStorageDomain, storageDomain, entity, hostId, cnx);
break;
case LOCALFS:
resp = addDomain(ActionType.AddLocalStorageDomain, storageDomain, entity, hostId, cnx);
break;
case POSIXFS:
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain.getStorage(), "vfsType");
}
resp = addDomain(ActionType.AddPosixFsStorageDomain, storageDomain, entity, hostId, cnx);
break;
case GLUSTERFS:
if (!storageConnectionFromUser.isSetId()) {
validateParameters(storageDomain.getStorage(), "vfsType");
}
resp = addDomain(ActionType.AddGlusterFsStorageDomain, storageDomain, entity, hostId, cnx);
break;
default:
break;
}
if (resp != null) {
addLinks((StorageDomain) resp.getEntity(), getLinksToExclude(storageDomain));
}
return resp;
}
Aggregations