Search in sources :

Example 31 with AsyncTaskStatus

use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.

the class BackendStorageDomainVmResourceTest method doTestImportAsync.

private void doTestImportAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus actionStatus) throws Exception {
    setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]);
    setUpGetDataCenterByStorageDomainExpectations(GUIDS[3]);
    setUriInfo(setUpActionExpectations(ActionType.ImportVm, ImportVmParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "ClusterId" }, new Object[] { VM_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1] }, asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus))));
    StorageDomain storageDomain = new StorageDomain();
    storageDomain.setId(GUIDS[2].toString());
    org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
    cluster.setId(GUIDS[1].toString());
    Action action = new Action();
    action.setStorageDomain(storageDomain);
    action.setCluster(cluster);
    Response response = resource.doImport(action);
    verifyActionResponse(response, URL_BASE, true, null);
    action = (Action) response.getEntity();
    assertTrue(action.isSetStatus());
    assertEquals(actionStatus.value(), action.getStatus());
}
Also used : Action(org.ovirt.engine.api.model.Action) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Response(javax.ws.rs.core.Response) BackendStorageDomainVmsResourceTest.setUpStorageDomain(org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain) StorageDomain(org.ovirt.engine.api.model.StorageDomain) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) ImportVmParameters(org.ovirt.engine.core.common.action.ImportVmParameters)

Example 32 with AsyncTaskStatus

use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.

the class BackendVmDisksResourceTest method testAddDiskIdentifyStorageDomainByName.

@Test
public void testAddDiskIdentifyStorageDomainByName() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpHttpHeaderExpectations("Expect", "201-created");
    setUpGetDiskExpectations();
    int times = 2;
    while (times-- > 0) {
        setUpEntityQueryExpectations(QueryType.GetAllStorageDomains, QueryParametersBase.class, new String[] {}, new Object[] {}, getStorageDomains());
    }
    setUpEntityQueryExpectations(QueryType.GetStorageDomainById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getStorageDomain(GUIDS[2]));
    setUpCreationExpectations(ActionType.AddDisk, AddDiskParameters.class, new String[] { "VmId", "StorageDomainId" }, new Object[] { VM_ID, GUIDS[2] }, true, true, GUIDS[0], asList(GUIDS[3]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, asList(getEntity(0)));
    Disk model = getModel();
    model.getStorageDomains().getStorageDomains().get(0).setId(null);
    model.getStorageDomains().getStorageDomains().get(0).setName("Storage_Domain_1");
    model.setProvisionedSize(1024 * 1024L);
    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 33 with AsyncTaskStatus

use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.

the class BackendTemplatesResourceTest method testAddWithClusterName.

@Test
public void testAddWithClusterName() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpHttpHeaderExpectations("Expect", "201-created");
    setUpEntityQueryExpectations(QueryType.GetClusterById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getClusterEntity());
    setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
    setUpGetEntityExpectations(0);
    setUpGetGraphicsExpectations(1);
    setUpGetConsoleExpectations(0, 0, 1);
    setUpGetVirtioScsiExpectations(0, 0);
    setUpGetSoundcardExpectations(0, 0, 1);
    setUpGetRngDeviceExpectations(0, 0);
    setUpGetBallooningExpectations(0, 0);
    setUpGetEntityExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[2] }, setUpCluster(GUIDS[2]));
    setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Template model = getModel(0);
    model.setCluster(new org.ovirt.engine.api.model.Cluster());
    model.getCluster().setName(NAMES[2]);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Template);
    verifyModel((Template) response.getEntity(), 0);
    assertNull(((Template) response.getEntity()).getCreationStatus());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 34 with AsyncTaskStatus

use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.

the class BackendTemplatesResourceTest method testAddWithCluster.

@Test
public void testAddWithCluster() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpHttpHeaderExpectations("Expect", "201-created");
    setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
    setUpGetEntityExpectations(0);
    setUpGetGraphicsExpectations(1);
    setUpGetConsoleExpectations(0, 0, 1);
    setUpGetVirtioScsiExpectations(0, 0);
    setUpGetSoundcardExpectations(0, 0, 1);
    setUpGetRngDeviceExpectations(0, 0);
    setUpGetBallooningExpectations(0, 0);
    setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Template model = getModel(0);
    model.setCluster(new org.ovirt.engine.api.model.Cluster());
    model.getCluster().setId(GUIDS[2].toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Template);
    verifyModel((Template) response.getEntity(), 0);
    assertNull(((Template) response.getEntity()).getCreationStatus());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 35 with AsyncTaskStatus

use of org.ovirt.engine.core.common.businessentities.AsyncTaskStatus in project ovirt-engine by oVirt.

the class BackendTemplatesResourceTest method doTestAddAsync.

private void doTestAddAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus creationStatus) throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetGraphicsExpectations(1);
    setUpGetConsoleExpectations(0, 1);
    setUpGetVirtioScsiExpectations(0);
    setUpGetSoundcardExpectations(0, 1);
    setUpGetRngDeviceExpectations(0);
    setUpGetBallooningExpectations(new Integer[] { 0 });
    setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
    setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(asyncStatus)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Response response = collection.add(getModel(0));
    assertEquals(202, response.getStatus());
    assertTrue(response.getEntity() instanceof Template);
    verifyModel((Template) response.getEntity(), 0);
    Template created = (Template) response.getEntity();
    assertNotNull(created.getCreationStatus());
    assertEquals(creationStatus.value(), created.getCreationStatus());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate)

Aggregations

AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)41 Response (javax.ws.rs.core.Response)26 Test (org.junit.Test)15 Template (org.ovirt.engine.api.model.Template)12 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)9 Action (org.ovirt.engine.api.model.Action)7 Disk (org.ovirt.engine.api.model.Disk)7 Guid (org.ovirt.engine.core.compat.Guid)7 StorageDomain (org.ovirt.engine.api.model.StorageDomain)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 CreationStatus (org.ovirt.engine.api.model.CreationStatus)3 Vm (org.ovirt.engine.api.model.Vm)3 Collections (java.util.Collections)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 Fault (org.ovirt.engine.api.model.Fault)2 SPMTask (org.ovirt.engine.core.bll.tasks.interfaces.SPMTask)2 SpmStatusResult (org.ovirt.engine.core.common.businessentities.SpmStatusResult)2