use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendVmPoolsResource method deprecatedPopulate.
@Override
protected VmPool deprecatedPopulate(VmPool model, org.ovirt.engine.core.common.businessentities.VmPool entity) {
if (model.isSetSize() && model.getSize() > 0) {
VM vm = getVM(model);
model.setTemplate(new Template());
model.getTemplate().setId(vm.getVmtGuid().toString());
model = getMapper(VM.class, VmPool.class).map(vm, model);
DisplayHelper.adjustDisplayData(this, model.getVm(), false);
if (vm.getInstanceTypeId() != null) {
model.setInstanceType(new InstanceType());
model.getInstanceType().setId(vm.getInstanceTypeId().toString());
}
}
return model;
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplateResourceTest method testConflictedUpdate.
@Test
public void testConflictedUpdate() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetEntityExpectations(1);
Template model = getRestModel(1);
model.setId(GUIDS[1].toString());
try {
resource.update(model);
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
verifyImmutabilityConstraint(wae);
}
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddVersionNoBaseTemplateId.
@Test
public void testAddVersionNoBaseTemplateId() throws Exception {
setUriInfo(setUpBasicUriExpectations());
Template t = getModel(2);
t.getVersion().setBaseTemplate(null);
try {
collection.add(t);
fail("Should have failed with 400 error due to a missing base template");
} catch (WebApplicationException e) {
assertNotNull(e.getResponse());
assertEquals(400, e.getResponse().getStatus());
}
}
use of org.ovirt.engine.api.model.Template 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());
}
use of org.ovirt.engine.api.model.Template 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());
}
Aggregations