Search in sources :

Example 11 with StorageConnection

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

the class BackendStorageServerConnectionsResource method add.

@Override
public Response add(StorageConnection storageConn) {
    validateParameters(storageConn, "type");
    // map to backend object
    StorageServerConnections storageConnection = getMapper(StorageConnection.class, StorageServerConnections.class).map(storageConn, null);
    Guid hostId = Guid.Empty;
    if (storageConn.getHost() != null) {
        hostId = getHostId(storageConn.getHost());
    }
    switch(storageConnection.getStorageType()) {
        case ISCSI:
            validateParameters(storageConn, "address", "target", "port");
            break;
        case NFS:
            validateParameters(storageConn, "address", "path");
            break;
        case LOCALFS:
            validateParameters(storageConn, "path");
            break;
        case POSIXFS:
        case GLUSTERFS:
            // address is possible, but is optional, non mandatory
            validateParameters(storageConn, "path", "vfsType");
            break;
        default:
            break;
    }
    return performCreate(ActionType.AddStorageServerConnection, getAddParams(storageConnection, hostId), ENTITY_RETRIEVER);
}
Also used : StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Guid(org.ovirt.engine.core.compat.Guid)

Example 12 with StorageConnection

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

the class BackendIscsiBondStorageConnectionResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(1, getIscsiBondContainingStorageConnection());
    setUpEntityQueryExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { STORAGE_CONNECTION_ID.toString() }, getEntity(0));
    StorageConnection model = resource.get();
    assertEquals(GUIDS[0].toString(), model.getId());
    verifyLinks(model);
}
Also used : StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 13 with StorageConnection

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

the class BackendStorageDomainServerConnectionsResourceTest method testAttachSuccess.

@Test
public void testAttachSuccess() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpActionExpectations(ActionType.AttachStorageConnectionToStorageDomain, AttachDetachStorageConnectionParameters.class, new String[] {}, new Object[] {}, true, true);
    StorageConnection connection = new StorageConnection();
    connection.setId(GUIDS[3].toString());
    Response response = collection.add(connection);
    assertEquals(200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 14 with StorageConnection

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

the class BackendStorageServerConnectionsResourceTest method getModel.

StorageConnection getModel(int index) {
    StorageConnection model = new StorageConnection();
    model.setType(STORAGE_TYPES[index]);
    if (index == 0 || index == 3) {
        model.setAddress("1.1.1.1");
    }
    Host host = new Host();
    host.setId(GUIDS[1].toString());
    model.setHost(host);
    if (index == 0 || index == 1) {
        model.setPath("/data1");
    }
    return model;
}
Also used : Host(org.ovirt.engine.api.model.Host) StorageConnection(org.ovirt.engine.api.model.StorageConnection)

Example 15 with StorageConnection

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

the class IscsiBondMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.IscsiBond.class, to = IscsiBond.class)
public static IscsiBond map(org.ovirt.engine.core.common.businessentities.IscsiBond from, IscsiBond to) {
    IscsiBond iscsiBond = (to != null) ? to : new IscsiBond();
    DataCenter dataCenter = new DataCenter();
    dataCenter.setId(from.getStoragePoolId().toString());
    iscsiBond.setDataCenter(dataCenter);
    iscsiBond.setName(from.getName());
    iscsiBond.setDescription(from.getDescription());
    if (from.getId() != null) {
        iscsiBond.setId(from.getId().toString());
    }
    Networks networks = new Networks();
    for (Guid id : from.getNetworkIds()) {
        Network network = new Network();
        network.setId(id.toString());
        networks.getNetworks().add(network);
    }
    iscsiBond.setNetworks(networks);
    StorageConnections connections = new StorageConnections();
    for (String id : from.getStorageConnectionIds()) {
        StorageConnection conn = new StorageConnection();
        conn.setId(id);
        connections.getStorageConnections().add(conn);
    }
    iscsiBond.setStorageConnections(connections);
    return iscsiBond;
}
Also used : Networks(org.ovirt.engine.api.model.Networks) DataCenter(org.ovirt.engine.api.model.DataCenter) Network(org.ovirt.engine.api.model.Network) IscsiBond(org.ovirt.engine.api.model.IscsiBond) Guid(org.ovirt.engine.core.compat.Guid) StorageConnection(org.ovirt.engine.api.model.StorageConnection) StorageConnections(org.ovirt.engine.api.model.StorageConnections)

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