Search in sources :

Example 6 with StorageConnection

use of org.ovirt.engine.api.model.StorageConnection in project ovirt-engine by oVirt.

the class IscsiBondMapperTest method verifyStorageConnections.

private static void verifyStorageConnections(StorageConnections before, StorageConnections after) {
    if (before == null) {
        assertNull(after);
    } else {
        assertEquals(before.getStorageConnections().size(), after.getStorageConnections().size());
        Set<String> ids = new HashSet<>();
        for (StorageConnection conn : before.getStorageConnections()) {
            ids.add(conn.getId());
        }
        for (StorageConnection conn : after.getStorageConnections()) {
            ids.remove(conn.getId());
        }
        assertEquals(0, ids.size());
    }
}
Also used : StorageConnection(org.ovirt.engine.api.model.StorageConnection) HashSet(java.util.HashSet)

Example 7 with StorageConnection

use of org.ovirt.engine.api.model.StorageConnection 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 StorageConnection

use of org.ovirt.engine.api.model.StorageConnection in project ovirt-engine by oVirt.

the class StorageDomainMapperTest method checkNFSStorageConnectionsMappingsToBll.

@Test
public void checkNFSStorageConnectionsMappingsToBll() {
    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");
    StorageConnection RESTConnection = new StorageConnection();
    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");
    StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null);
    assertEquals(connection.getId(), mappedResult.getId());
    assertEquals(connection.getStorageType(), mappedResult.getStorageType());
    assertEquals(connection.getConnection(), mappedResult.getConnection());
    assertEquals(connection.getNfsRetrans(), mappedResult.getNfsRetrans());
    assertEquals(connection.getNfsTimeo(), mappedResult.getNfsTimeo());
    assertEquals(connection.getNfsVersion(), mappedResult.getNfsVersion());
    assertEquals(connection.getMountOptions(), mappedResult.getMountOptions());
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 9 with StorageConnection

use of org.ovirt.engine.api.model.StorageConnection in project ovirt-engine by oVirt.

the class StorageDomainMapperTest method checkISCSISStorageConnectionsMappingsToBll.

@Test
public void checkISCSISStorageConnectionsMappingsToBll() {
    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");
    StorageConnection RESTConnection = new StorageConnection();
    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");
    RESTConnection.setPassword("123");
    StorageServerConnections mappedResult = StorageDomainMapper.map(RESTConnection, null);
    assertEquals(mappedResult.getId(), mappedResult.getId());
    assertEquals(mappedResult.getStorageType(), mappedResult.getStorageType());
    assertEquals(mappedResult.getConnection(), mappedResult.getConnection());
    assertEquals(mappedResult.getIqn(), mappedResult.getIqn());
    assertEquals(mappedResult.getUserName(), mappedResult.getUserName());
    assertEquals(mappedResult.getPassword(), mappedResult.getPassword());
    assertEquals(mappedResult.getPort(), mappedResult.getPort());
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 10 with StorageConnection

use of org.ovirt.engine.api.model.StorageConnection 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)

Aggregations

StorageConnection (org.ovirt.engine.api.model.StorageConnection)18 Test (org.junit.Test)11 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)10 Guid (org.ovirt.engine.core.compat.Guid)8 Response (javax.ws.rs.core.Response)4 Host (org.ovirt.engine.api.model.Host)4 HostStorage (org.ovirt.engine.api.model.HostStorage)3 StorageConnections (org.ovirt.engine.api.model.StorageConnections)2 HashSet (java.util.HashSet)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 DataCenter (org.ovirt.engine.api.model.DataCenter)1 IscsiBond (org.ovirt.engine.api.model.IscsiBond)1 Network (org.ovirt.engine.api.model.Network)1 Networks (org.ovirt.engine.api.model.Networks)1