use of org.ovirt.engine.api.model.Vm 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;
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testAdd.
@Test
public void testAdd() throws Exception {
setUpGetConsoleExpectations(1);
setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, 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));
Response response = collection.add(createModel(null));
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 testCloneWithDisk.
@Test
public void testCloneWithDisk() throws Exception {
setUriInfo(addMatrixParameterExpectations(setUpBasicUriExpectations(), BackendVmsResource.CLONE, "true"));
setUpTemplateDisksExpectations(GUIDS[1]);
setUpGetPayloadExpectations(1, 2);
setUpGetBallooningExpectations(1, 2);
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(1, 2);
setUpGetVmOvfExpectations(2);
setUpGetVirtioScsiExpectations(2);
setUpGetSoundcardExpectations(1, 2);
setUpGetRngDeviceExpectations(1, 2);
setUpGetCertuficateExpectations(1, 2);
setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, getTemplateEntity(1));
setUpEntityQueryExpectations(QueryType.GetClusterById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getClusterEntity());
setUpCreationExpectations(ActionType.AddVmFromTemplate, 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));
Response response = collection.add(createModel(createDiskAttachmentsCollection()));
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 testAddFromConfiguration.
@Test
public void testAddFromConfiguration() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetPayloadExpectations(1, 2);
setUpGetBallooningExpectations(1, 2);
setUpGetGraphicsExpectations(1);
setUpGetCertuficateExpectations(1, 2);
setUpGetConsoleExpectations(2);
setUpGetVmOvfExpectations(2);
setUpGetVirtioScsiExpectations(2);
setUpGetSoundcardExpectations(2);
setUpGetRngDeviceExpectations(2);
Vm model = createModel(null);
org.ovirt.engine.core.common.businessentities.VM returnedVM = getEntity(2);
model.setInitialization(new Initialization());
model.getInitialization().setConfiguration(new Configuration());
model.getInitialization().getConfiguration().setData("asdasdasd");
model.getInitialization().getConfiguration().setType(org.ovirt.engine.api.model.ConfigurationType.OVF);
setUpGetEntityExpectations(QueryType.GetVmFromConfiguration, GetVmFromConfigurationQueryParameters.class, new String[] { "VmConfiguration", "ConfigurationType" }, new Object[] { model.getInitialization().getConfiguration().getData(), ConfigurationType.OVF }, returnedVM);
setUpCreationExpectations(ActionType.ImportVmFromConfiguration, ImportVmFromConfParameters.class, new String[] { "Vm", "ClusterId", "ImportAsNewEntity" }, new Object[] { returnedVM, Guid.createGuidFromString(model.getCluster().getId()), false }, true, true, GUIDS[2], QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, returnedVM);
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 testAddUseExistingIcons.
@Test
public void testAddUseExistingIcons() throws Exception {
setUpEntityQueryExpectations(QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, 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));
final Vm model = createModel(null);
model.setSmallIcon(IconTestHelpler.createIcon(GUIDS[2]));
model.setLargeIcon(IconTestHelpler.createIcon(GUIDS[3]));
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Vm);
verifyModel((Vm) response.getEntity(), 2);
}
Aggregations