Search in sources :

Example 51 with Disk

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

the class BackendVmDisksResourceTest method testAddIscsiLunDiskIncompleteParametersConnectionPort.

@Test
public void testAddIscsiLunDiskIncompleteParametersConnectionPort() {
    Disk model = createIscsiLunDisk();
    model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setPort(null);
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        // Because of extra frame offset used current method name in test, while in real world used "add" method name
        verifyIncompleteException(wae, "LogicalUnit", "testAddIscsiLunDiskIncompleteParametersConnectionPort", "port");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 52 with Disk

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

the class BackendVmDisksResourceTest method testAddLunDisk.

@Test
public /**
 * This test checks that addition of LUN-Disk is successful. There is no real difference in the
 * implementation of adding regular disk and adding a lun-disk; in both cases the disk entity
 * is mapped and passed to the Backend, and Backend infers the type of disk from the entity and creates it.
 *
 * So what this test actually checks is that it's OK for the user not to specify size|provisionedSize
 * when creating a LUN-Disk
 */
void testAddLunDisk() {
    Disk model = createIscsiLunDisk();
    testAddDiskImpl(model);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 53 with Disk

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

the class BackendVmDisksResourceTest method testAddIscsiLunDiskIncompleteParametersConnectionTarget.

@Test
public void testAddIscsiLunDiskIncompleteParametersConnectionTarget() {
    Disk model = createIscsiLunDisk();
    model.getLunStorage().getLogicalUnits().getLogicalUnits().get(0).setTarget(null);
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(model);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        // Because of extra frame offset used current method name in test, while in real world used "add" method name
        verifyIncompleteException(wae, "LogicalUnit", "testAddIscsiLunDiskIncompleteParametersConnectionTarget", "target");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 54 with Disk

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

the class BackendVmDisksResourceTest method testAttachDisk.

@Test
public void testAttachDisk() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AttachDiskToVm, AttachDetachVmDiskParameters.class, new String[] { "VmId", "EntityInfo" }, new Object[] { VM_ID, new EntityInfo(VdcObjectType.Disk, DISK_ID) }, true, true, null, null, null, QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, asList(getEntity(0)));
    Disk model = getModel();
    // means this is an existing disk --> attach
    model.setId(DISK_ID.toString());
    model.setProvisionedSize(1024 * 1024L);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) EntityInfo(org.ovirt.engine.core.common.asynctasks.EntityInfo) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 55 with Disk

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

the class BackendVmDisksResourceTest method doTestBadAddDisk.

private void doTestBadAddDisk(boolean valid, boolean success, String detail) throws Exception {
    setUpEntityQueryExpectations(QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getStorageDomain(GUIDS[2]));
    setUriInfo(setUpActionExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "VmId" }, new Object[] { VM_ID }, valid, success));
    Disk model = getModel();
    model.setProvisionedSize(1024 * 1024L);
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Disk(org.ovirt.engine.api.model.Disk) AddDiskParameters(org.ovirt.engine.core.common.action.AddDiskParameters)

Aggregations

Disk (org.ovirt.engine.api.model.Disk)68 Test (org.junit.Test)33 Response (javax.ws.rs.core.Response)13 Guid (org.ovirt.engine.core.compat.Guid)13 WebApplicationException (javax.ws.rs.WebApplicationException)10 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)10 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)10 StorageDomain (org.ovirt.engine.api.model.StorageDomain)9 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)7 Vm (org.ovirt.engine.api.model.Vm)6 StorageDomains (org.ovirt.engine.api.model.StorageDomains)4 V3Disk (org.ovirt.engine.api.v3.types.V3Disk)4 DiskAttachments (org.ovirt.engine.api.model.DiskAttachments)3 V3Disks (org.ovirt.engine.api.v3.types.V3Disks)3 UriInfo (javax.ws.rs.core.UriInfo)2 HostStorage (org.ovirt.engine.api.model.HostStorage)2 V3CdRoms (org.ovirt.engine.api.v3.types.V3CdRoms)2 V3CustomProperties (org.ovirt.engine.api.v3.types.V3CustomProperties)2 V3Floppies (org.ovirt.engine.api.v3.types.V3Floppies)2 V3KatelloErrata (org.ovirt.engine.api.v3.types.V3KatelloErrata)2