Search in sources :

Example 61 with Disk

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

the class BackendStorageDomainDisksResourceTest method testAdd.

@Test
public void testAdd() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpHttpHeaderExpectations("Expect", "201-created");
    setUpEntityQueryExpectations(QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Disk model = getModel();
    setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "StorageDomainId" }, new Object[] { GUIDS[3] }, true, true, GUIDS[0], asList(storagePoolId), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Disk);
    verifyModel((Disk) response.getEntity(), 0);
    assertNull(((Disk) response.getEntity()).getCreationStatus());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 62 with Disk

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

the class BackendStorageDomainDisksResourceTest method testAddUnregistered.

@Test
public void testAddUnregistered() throws Exception {
    setUriInfo(addMatrixParameterExpectations(setUpBasicUriExpectations(), BackendStorageDomainDisksResource.UNREGISTERED));
    setUpHttpHeaderExpectations("Expect", "201-created");
    StoragePool storagePool = new StoragePool();
    storagePool.setId(storagePoolId);
    setUpEntityQueryExpectations(QueryType.GetStoragePoolsByStorageDomainId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[3] }, Collections.singletonList(storagePool));
    setUpEntityQueryExpectations(QueryType.GetUnregisteredDisk, GetUnregisteredDiskQueryParameters.class, new String[] { "DiskId", "StorageDomainId", "StoragePoolId" }, new Object[] { GUIDS[0], GUIDS[3], storagePoolId }, getEntity(0));
    Disk model = getModel();
    org.ovirt.engine.core.common.businessentities.storage.Disk imageToRegister = new DiskMapper().map(model, getEntity(0));
    // imageToRegister.setDiskAlias("alias");
    setUpCreationExpectations(ActionType.RegisterDisk, RegisterDiskParameters.class, new String[] { "DiskImage" }, new Object[] { imageToRegister }, true, true, GUIDS[0], QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    model.setId(GUIDS[0].toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Disk);
    verifyModel((Disk) response.getEntity(), 0);
    assertNull(((Disk) response.getEntity()).getCreationStatus());
}
Also used : Response(javax.ws.rs.core.Response) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) DiskMapper(org.ovirt.engine.api.restapi.types.DiskMapper) Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 63 with Disk

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

the class BackendTemplateDiskResourceTest method testGet.

@Test
public void testGet() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(1);
    Disk disk = resource.get();
    verifyModelSpecific(disk, 1);
    verifyLinks(disk);
}
Also used : Disk(org.ovirt.engine.api.model.Disk) Test(org.junit.Test)

Example 64 with Disk

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

the class BackendTemplateDisksResourceTest method testList.

@Test
@Override
public void testList() throws Exception {
    UriInfo uriInfo = setUpUriExpectations(null);
    setUpEntityQueryExpectations(1, null);
    collection.setUriInfo(uriInfo);
    List<Disk> disks = getCollection();
    for (Disk disk : disks) {
        assertNotNull(disk.getStorageDomains());
        List<StorageDomain> storageDomains = disk.getStorageDomains().getStorageDomains();
        assertEquals(1, storageDomains.size());
        assertEquals(storageDomains.get(0).getId(), GUIDS[0].toString());
    }
    verifyCollection(disks);
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) Disk(org.ovirt.engine.api.model.Disk) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 65 with Disk

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

the class DiskSnapshotMapper method map.

@Mapping(from = org.ovirt.engine.core.common.businessentities.storage.Disk.class, to = DiskSnapshot.class)
public static DiskSnapshot map(org.ovirt.engine.core.common.businessentities.storage.Disk entity, DiskSnapshot template) {
    if (template == null) {
        template = new DiskSnapshot();
    }
    DiskSnapshot model = (DiskSnapshot) DiskMapper.map(entity, template);
    Disk disk = new Disk();
    disk.setId(entity.getId().toString());
    model.setDisk(disk);
    DiskImage diskImage = (DiskImage) entity;
    model.setId(diskImage.getImageId().toString());
    model.setImageId(null);
    return model;
}
Also used : DiskSnapshot(org.ovirt.engine.api.model.DiskSnapshot) Disk(org.ovirt.engine.api.model.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

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