Search in sources :

Example 11 with Host

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

the class BackendHostsResourceTest method testAddIncompleteParameters.

@Test
public void testAddIncompleteParameters() throws Exception {
    Host model = new Host();
    model.setName(NAMES[0]);
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Host", "add", "address");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Host(org.ovirt.engine.api.model.Host) Test(org.junit.Test)

Example 12 with Host

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

the class BackendStorageServerConnectionResourceTest method getModel.

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

Example 13 with Host

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

the class BackendStorageServerConnectionsResourceTest method testAddFailure.

@Test
public void testAddFailure() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    Host host = new Host();
    host.setId(GUIDS[1].toString());
    StorageServerConnections connection = new StorageServerConnections();
    connection.setConnection("1.1.1.1:/data1");
    connection.setStorageType(STORAGE_TYPES_MAPPED[0]);
    setUpCreationExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { connection.getConnection(), STORAGE_TYPES_MAPPED[0], GUIDS[1] }, false, false, GUIDS[0].toString(), QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[0].toString() }, getEntity(0));
    Response response = null;
    try {
        response = collection.add(getModel(0));
    } catch (WebApplicationException e) {
        assertNotNull(e.getResponse());
        assertEquals(400, e.getResponse().getStatus());
    }
}
Also used : Response(javax.ws.rs.core.Response) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) WebApplicationException(javax.ws.rs.WebApplicationException) Host(org.ovirt.engine.api.model.Host) Test(org.junit.Test)

Example 14 with Host

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

the class BackendStorageServerConnectionsResourceTest method testAddLocal.

@Test
public void testAddLocal() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    Host host = new Host();
    host.setId(GUIDS[1].toString());
    StorageServerConnections connection = new StorageServerConnections();
    connection.setConnection("/data1");
    connection.setStorageType(STORAGE_TYPES_MAPPED[1]);
    setUpCreationExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { connection.getConnection(), STORAGE_TYPES_MAPPED[1], GUIDS[1] }, true, true, GUIDS[1].toString(), QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[1].toString() }, getEntity(1));
    Response response = collection.add(getModel(1));
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof StorageConnection);
    verifyModel((StorageConnection) response.getEntity(), 1);
}
Also used : Response(javax.ws.rs.core.Response) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Host(org.ovirt.engine.api.model.Host) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Example 15 with Host

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

the class BackendStorageServerConnectionsResourceTest method testAdd.

@Test
public void testAdd() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    Host host = new Host();
    host.setId(GUIDS[1].toString());
    StorageServerConnections connection = new StorageServerConnections();
    connection.setConnection("1.1.1.1:/data1");
    connection.setStorageType(STORAGE_TYPES_MAPPED[0]);
    setUpCreationExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { connection.getConnection(), STORAGE_TYPES_MAPPED[0], GUIDS[1] }, true, true, GUIDS[0].toString(), QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[0].toString() }, getEntity(0));
    Response response = collection.add(getModel(0));
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof StorageConnection);
    verifyModel((StorageConnection) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) Host(org.ovirt.engine.api.model.Host) StorageConnection(org.ovirt.engine.api.model.StorageConnection) Test(org.junit.Test)

Aggregations

Host (org.ovirt.engine.api.model.Host)114 Test (org.junit.Test)58 Vm (org.ovirt.engine.api.model.Vm)21 Response (javax.ws.rs.core.Response)15 Hosts (org.ovirt.engine.api.model.Hosts)15 StorageDomain (org.ovirt.engine.api.model.StorageDomain)13 WebApplicationException (javax.ws.rs.WebApplicationException)12 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 VmPlacementPolicy (org.ovirt.engine.api.model.VmPlacementPolicy)11 Guid (org.ovirt.engine.core.compat.Guid)10 Cluster (org.ovirt.engine.api.model.Cluster)7 HostNic (org.ovirt.engine.api.model.HostNic)6 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)5 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)5 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)3 AffinityGroup (org.ovirt.engine.api.model.AffinityGroup)3 HostStorage (org.ovirt.engine.api.model.HostStorage)3 HostType (org.ovirt.engine.api.model.HostType)3 Spm (org.ovirt.engine.api.model.Spm)3