Search in sources :

Example 16 with Template

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

the class BackendVmsResourceTest method testAddFromScratchNamedCluster.

@Test
public void testAddFromScratchNamedCluster() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetPayloadExpectations(2, 0);
    setUpGetBallooningExpectations(2, 0);
    setUpGetGraphicsExpectations(1);
    setUpGetConsoleExpectations(0, 0);
    setUpGetVmOvfExpectations(0, 0);
    setUpGetVirtioScsiExpectations(0, 0);
    setUpGetSoundcardExpectations(0, 0);
    setUpGetRngDeviceExpectations(0, 0);
    setUpGetCertuficateExpectations(2, 0);
    setUpHttpHeaderExpectations("Expect", "201-created");
    setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[1] }, setUpCluster(GUIDS[1]));
    setUpEntityQueryExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getTemplateEntity(0));
    setUpCreationExpectations(ActionType.AddVmFromScratch, AddVmParameters.class, new String[] { "StorageDomainId" }, new Object[] { Guid.Empty }, true, true, GUIDS[0], asList(GUIDS[1]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Vm model = getModel(0);
    model.setCluster(new org.ovirt.engine.api.model.Cluster());
    model.getCluster().setName(NAMES[1]);
    model.setTemplate(new Template());
    model.getTemplate().setId(DEFAULT_TEMPLATE_ID);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Vm);
    verifyModel((Vm) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Vm(org.ovirt.engine.api.model.Vm) Template(org.ovirt.engine.api.model.Template) Test(org.junit.Test)

Example 17 with Template

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

the class BackendVmsResourceTest method testAddPassTemplateByName.

@Test
public void testAddPassTemplateByName() throws Exception {
    setUpGetConsoleExpectations(1);
    setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Name", "DataCenterId" }, new Object[] { NAMES[1], GUIDS[3] }, getTemplateEntity(1));
    setupAddExpectations();
    setUpCreationExpectations(ActionType.AddVm, AddVmParameters.class, new String[] { "StorageDomainId" }, new Object[] { GUIDS[0] }, true, true, GUIDS[2], QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getEntity(2));
    Vm model = getModel(2);
    model.setTemplate(new Template());
    model.getTemplate().setName(NAMES[1]);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Vm);
    verifyModel((Vm) response.getEntity(), 2);
}
Also used : Response(javax.ws.rs.core.Response) Vm(org.ovirt.engine.api.model.Vm) Template(org.ovirt.engine.api.model.Template) Test(org.junit.Test)

Example 18 with Template

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

the class BackendVmsResourceTest method testAddFromScratch.

@Test
public void testAddFromScratch() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpHttpHeaderExpectations("Expect", "201-created");
    setUpGetPayloadExpectations(2, 0);
    setUpGetConsoleExpectations(0, 0);
    setUpGetVmOvfExpectations(0, 0);
    setUpGetVirtioScsiExpectations(0, 0);
    setUpGetSoundcardExpectations(0, 0);
    setUpGetRngDeviceExpectations(0, 0);
    setUpGetBallooningExpectations(2, 0);
    setUpGetGraphicsExpectations(1);
    setUpGetCertuficateExpectations(2, 0);
    setUpEntityQueryExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    setUpEntityQueryExpectations(QueryType.GetClusterById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, getClusterEntity());
    setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getTemplateEntity(0));
    setUpCreationExpectations(ActionType.AddVmFromScratch, AddVmParameters.class, new String[] { "StorageDomainId" }, new Object[] { Guid.Empty }, true, true, GUIDS[0], asList(GUIDS[1]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Vm model = getModel(0);
    model.setCluster(new org.ovirt.engine.api.model.Cluster());
    model.getCluster().setId(GUIDS[1].toString());
    model.setTemplate(new Template());
    model.getTemplate().setId(DEFAULT_TEMPLATE_ID);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Vm);
    verifyModel((Vm) response.getEntity(), 0);
    assertNull(((Vm) response.getEntity()).getCreationStatus());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Vm(org.ovirt.engine.api.model.Vm) Template(org.ovirt.engine.api.model.Template) Test(org.junit.Test)

Example 19 with Template

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

the class BackendVmsResourceTest method createModel.

private Vm createModel(DiskAttachments diskAttachments) {
    Vm model = getModel(2);
    model.setTemplate(new Template());
    model.getTemplate().setId(GUIDS[1].toString());
    model.setCluster(new org.ovirt.engine.api.model.Cluster());
    model.getCluster().setId(GUIDS[2].toString());
    if (diskAttachments != null) {
        model.setDiskAttachments(diskAttachments);
    }
    return model;
}
Also used : Vm(org.ovirt.engine.api.model.Vm) Template(org.ovirt.engine.api.model.Template)

Example 20 with Template

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

the class BackendVmsResourceTest method doTestAddAsync.

private void doTestAddAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus creationStatus) throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpGetPayloadExpectations(1, 0);
    setUpGetBallooningExpectations(1, 0);
    setUpGetGraphicsExpectations(1);
    setUpGetConsoleExpectations(0);
    setUpGetVirtioScsiExpectations(0);
    setUpGetSoundcardExpectations(0);
    setUpGetRngDeviceExpectations(0);
    setUpGetVmOvfExpectations(0);
    setUpGetCertuficateExpectations(1, 0);
    setUpEntityQueryExpectations(QueryType.GetClusterById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, getClusterEntity());
    setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getTemplateEntity(0));
    setUpCreationExpectations(ActionType.AddVmFromScratch, AddVmParameters.class, new String[] { "StorageDomainId" }, new Object[] { Guid.Empty }, true, true, GUIDS[0], asList(GUIDS[1]), asList(new AsyncTaskStatus(asyncStatus)), QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Vm model = getModel(0);
    model.setCluster(new org.ovirt.engine.api.model.Cluster());
    model.getCluster().setId(GUIDS[1].toString());
    model.setTemplate(new Template());
    model.getTemplate().setId(DEFAULT_TEMPLATE_ID);
    Response response = collection.add(model);
    assertEquals(202, response.getStatus());
    assertTrue(response.getEntity() instanceof Vm);
    verifyModel((Vm) response.getEntity(), 0);
    Vm created = (Vm) 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) Vm(org.ovirt.engine.api.model.Vm) Template(org.ovirt.engine.api.model.Template)

Aggregations

Template (org.ovirt.engine.api.model.Template)57 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)32 Test (org.junit.Test)21 Response (javax.ws.rs.core.Response)16 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)12 Vm (org.ovirt.engine.api.model.Vm)11 WebApplicationException (javax.ws.rs.WebApplicationException)6 VmPool (org.ovirt.engine.api.model.VmPool)4 Cluster (org.ovirt.engine.api.model.Cluster)3 InstanceType (org.ovirt.engine.api.model.InstanceType)3 TimeZone (org.ovirt.engine.api.model.TimeZone)3 GetVmTemplateParameters (org.ovirt.engine.core.common.queries.GetVmTemplateParameters)3 ArrayList (java.util.ArrayList)2 Boot (org.ovirt.engine.api.model.Boot)2 Host (org.ovirt.engine.api.model.Host)2 OperatingSystem (org.ovirt.engine.api.model.OperatingSystem)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Tag (org.ovirt.engine.api.model.Tag)2 TemplateVersion (org.ovirt.engine.api.model.TemplateVersion)2 Templates (org.ovirt.engine.api.model.Templates)2