Search in sources :

Example 6 with HostStorage

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;
}
Also used : DiskStatus(org.ovirt.engine.api.model.DiskStatus) HostStorage(org.ovirt.engine.api.model.HostStorage) DiskFormat(org.ovirt.engine.api.model.DiskFormat)

Example 7 with HostStorage

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());
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 8 with HostStorage

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());
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 9 with HostStorage

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));
        }
    }
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage)

Example 10 with HostStorage

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;
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) Response(javax.ws.rs.core.Response) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) HostStorage(org.ovirt.engine.api.model.HostStorage) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

HostStorage (org.ovirt.engine.api.model.HostStorage)20 Test (org.junit.Test)8 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)7 StorageDomain (org.ovirt.engine.api.model.StorageDomain)6 Host (org.ovirt.engine.api.model.Host)4 Guid (org.ovirt.engine.core.compat.Guid)4 LogicalUnit (org.ovirt.engine.api.model.LogicalUnit)3 LogicalUnits (org.ovirt.engine.api.model.LogicalUnits)3 StorageConnection (org.ovirt.engine.api.model.StorageConnection)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 Response (javax.ws.rs.core.Response)2 Disk (org.ovirt.engine.api.model.Disk)2 VolumeGroup (org.ovirt.engine.api.model.VolumeGroup)2 DiskFormat (org.ovirt.engine.api.model.DiskFormat)1 DiskStatus (org.ovirt.engine.api.model.DiskStatus)1 HostStorages (org.ovirt.engine.api.model.HostStorages)1 StorageType (org.ovirt.engine.api.model.StorageType)1 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)1 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)1 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)1