Search in sources :

Example 71 with StorageDomain

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

the class BackendStorageDomainsResourceTest method testAddStorageDomainWithExistingConnectionId.

@Test
public void testAddStorageDomainWithExistingConnectionId() throws Exception {
    Host host = new Host();
    host.setId(GUIDS[0].toString());
    setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[POSIX_IDX].toString() }, setUpPosixStorageServerConnection(POSIX_IDX));
    setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[POSIX_IDX].toString() }, setUpPosixStorageServerConnection(POSIX_IDX));
    setUpGetEntityExpectations(QueryType.GetExistingStorageDomainList, GetExistingStorageDomainListParameters.class, new String[] { "Id", "StorageType", "StorageDomainType", "Path" }, new Object[] { GUIDS[0], STORAGE_TYPES_MAPPED[POSIX_IDX], TYPES_MAPPED[0], ADDRESSES[POSIX_IDX] + ":" + PATHS[POSIX_IDX] }, new ArrayList<>());
    setUpCreationExpectations(ActionType.AddPosixFsStorageDomain, StorageDomainManagementParameter.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, true, true, GUIDS[POSIX_IDX], QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[POSIX_IDX] }, getEntity(POSIX_IDX));
    StorageDomain model = new StorageDomain();
    model.setName(getSafeEntry(POSIX_IDX, NAMES));
    model.setDescription(getSafeEntry(POSIX_IDX, DESCRIPTIONS));
    model.setType(getSafeEntry(POSIX_IDX, TYPES));
    model.setStorage(new HostStorage());
    model.setHost(new Host());
    model.getHost().setId(GUIDS[0].toString());
    model.getStorage().setId(GUIDS[POSIX_IDX].toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof StorageDomain);
    verifyModel((StorageDomain) response.getEntity(), POSIX_IDX);
}
Also used : Response(javax.ws.rs.core.Response) StorageDomain(org.ovirt.engine.api.model.StorageDomain) Host(org.ovirt.engine.api.model.Host) HostStorage(org.ovirt.engine.api.model.HostStorage) Test(org.junit.Test)

Example 72 with StorageDomain

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

the class BackendStorageDomainsResourceTest method testAddIncompleteDomainParameters.

@Test
public void testAddIncompleteDomainParameters() throws Exception {
    StorageDomain model = getModel(0);
    model.setName(NAMES[0]);
    model.setHost(new Host());
    model.getHost().setId(GUIDS[0].toString());
    model.setStorage(new HostStorage());
    model.getStorage().setAddress(ADDRESSES[0]);
    model.getStorage().setPath(PATHS[0]);
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "StorageDomain", "add", "storage.type");
    }
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) WebApplicationException(javax.ws.rs.WebApplicationException) Host(org.ovirt.engine.api.model.Host) HostStorage(org.ovirt.engine.api.model.HostStorage) Test(org.junit.Test)

Example 73 with StorageDomain

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

the class BackendStorageDomainsResourceTest method testAddStorageDomainWithNoStorageObject.

@Test
public void testAddStorageDomainWithNoStorageObject() throws Exception {
    Host host = new Host();
    host.setId(GUIDS[0].toString());
    setUriInfo(setUpBasicUriExpectations());
    StorageDomain model = new StorageDomain();
    model.setName(getSafeEntry(POSIX_IDX, NAMES));
    model.setDescription(getSafeEntry(POSIX_IDX, DESCRIPTIONS));
    model.setType(getSafeEntry(POSIX_IDX, TYPES));
    model.setHost(new Host());
    model.getHost().setId(GUIDS[0].toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "StorageDomain", "add", "storage");
    }
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) WebApplicationException(javax.ws.rs.WebApplicationException) Host(org.ovirt.engine.api.model.Host) Test(org.junit.Test)

Example 74 with StorageDomain

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

the class BackendStorageDomainsResourceTest method testAddLocalStorageDomain.

@Test
public void testAddLocalStorageDomain() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { PATHS[LOCAL_IDX], STORAGE_TYPES_MAPPED[LOCAL_IDX], GUIDS[0] }, true, true, GUIDS[LOCAL_IDX].toString()));
    setUpGetEntityExpectations(QueryType.GetStorageServerConnectionById, StorageServerConnectionQueryParametersBase.class, new String[] { "ServerConnectionId" }, new Object[] { GUIDS[LOCAL_IDX].toString() }, setUpLocalStorageServerConnection(LOCAL_IDX));
    setUpCreationExpectations(ActionType.AddLocalStorageDomain, StorageDomainManagementParameter.class, new String[] { "VdsId" }, new Object[] { GUIDS[0] }, true, true, GUIDS[LOCAL_IDX], QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[LOCAL_IDX] }, getEntity(LOCAL_IDX));
    StorageDomain model = getModel(LOCAL_IDX);
    model.getStorage().setAddress(null);
    model.setHost(new Host());
    model.getHost().setId(GUIDS[0].toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof StorageDomain);
    verifyModel((StorageDomain) response.getEntity(), LOCAL_IDX);
}
Also used : Response(javax.ws.rs.core.Response) StorageDomain(org.ovirt.engine.api.model.StorageDomain) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) Host(org.ovirt.engine.api.model.Host) Test(org.junit.Test)

Example 75 with StorageDomain

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

the class BackendStorageDomainsResourceTest method doTestBadAddStorageDomain.

private void doTestBadAddStorageDomain(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.AddStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] { "StorageServerConnection.Connection", "StorageServerConnection.StorageType", "VdsId" }, new Object[] { ADDRESSES[0] + ":" + PATHS[0], STORAGE_TYPES_MAPPED[0], GUIDS[0] }, true, true, GUIDS[0].toString()));
    setUpActionExpectations(ActionType.RemoveStorageServerConnection, StorageServerConnectionParametersBase.class, new String[] {}, new Object[] {}, true, true, null);
    setUpGetEntityExpectations(QueryType.GetExistingStorageDomainList, GetExistingStorageDomainListParameters.class, new String[] { "Id", "StorageType", "StorageDomainType", "Path" }, new Object[] { GUIDS[0], STORAGE_TYPES_MAPPED[0], TYPES_MAPPED[0], ADDRESSES[0] + ":" + PATHS[0] }, new ArrayList<>());
    setUpActionExpectations(ActionType.AddNFSStorageDomain, StorageDomainManagementParameter.class, new String[] {}, new Object[] {}, valid, success);
    StorageDomain model = getModel(0);
    model.setHost(new Host());
    model.getHost().setId(GUIDS[0].toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) WebApplicationException(javax.ws.rs.WebApplicationException) StorageServerConnectionParametersBase(org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase) Host(org.ovirt.engine.api.model.Host)

Aggregations

StorageDomain (org.ovirt.engine.api.model.StorageDomain)88 Test (org.junit.Test)41 WebApplicationException (javax.ws.rs.WebApplicationException)14 Action (org.ovirt.engine.api.model.Action)14 Response (javax.ws.rs.core.Response)13 Host (org.ovirt.engine.api.model.Host)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 Disk (org.ovirt.engine.api.model.Disk)9 StorageDomains (org.ovirt.engine.api.model.StorageDomains)9 BackendStorageDomainVmsResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain)8 HostStorage (org.ovirt.engine.api.model.HostStorage)6 BackendStorageDomainTemplatesResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainTemplatesResourceTest.setUpStorageDomain)6 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)6 DataCenter (org.ovirt.engine.api.model.DataCenter)5 Vm (org.ovirt.engine.api.model.Vm)5 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)5 Guid (org.ovirt.engine.core.compat.Guid)5 DiskProfile (org.ovirt.engine.api.model.DiskProfile)4 ExportRepoImageParameters (org.ovirt.engine.core.common.action.ExportRepoImageParameters)4 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)4