use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testAddWithPlacementPolicySingleHostName.
@Test
public void testAddWithPlacementPolicySingleHostName() throws Exception {
setUpAddVm();
setUpGetHostByNameExpectations(1);
setUpGetConsoleExpectations(1);
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 = createModel(null);
model.setPlacementPolicy(new VmPlacementPolicy());
model.getPlacementPolicy().setHosts(new Hosts());
model.getPlacementPolicy().getHosts().getHosts().add(new Host());
model.getPlacementPolicy().getHosts().getHosts().get(0).setName(NAMES[1]);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Vm);
verifyModel((Vm) response.getEntity(), 2);
}
use of org.ovirt.engine.api.model.Vm 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());
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testCloneFromTemplateWithClonePermissionsClone.
@Test
public void testCloneFromTemplateWithClonePermissionsClone() throws Exception {
Vm model = createModel(createDiskAttachmentsCollection());
doTestCloneFromTemplateWithClonePermissions(model, true);
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method doTestBadAddFromScratch.
private void doTestBadAddFromScratch(boolean valid, boolean success, String detail) throws Exception {
setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getTemplateEntity(0));
when(osRepository.isBalloonEnabled(anyInt(), any())).thenReturn(false);
setUpEntityQueryExpectations(QueryType.GetClusterById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, getClusterEntity());
setUriInfo(setUpActionExpectations(ActionType.AddVmFromScratch, AddVmParameters.class, new String[] { "StorageDomainId" }, new Object[] { Guid.Empty }, valid, success));
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);
try {
collection.add(model);
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
verifyFault(wae, detail);
}
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmResourceTest method testUpdateUploadIcon.
@Test
public void testUpdateUploadIcon() throws Exception {
setUpGetEntityExpectations(3);
setUpGetPayloadExpectations(0, 2);
setUpGetBallooningExpectations();
setUpGetBallooningExpectations();
setUpGetGraphicsExpectations(2);
setUpGetConsoleExpectations(0);
setUpGetVmOvfExpectations(0);
setUpGetVirtioScsiExpectations(0);
setUpGetSoundcardExpectations(0);
setUpGetRngDeviceExpectations(0);
setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
final Vm model = getModel(0);
model.setLargeIcon(IconTestHelpler.createIconWithData());
verifyModel(resource.update(model), 0);
}
Aggregations