use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class LinkHelperTest method testVmTagLinks.
@Test
public void testVmTagLinks() throws Exception {
Tag tag = new Tag();
tag.setId(TAG_ID);
tag.setVm(new Vm());
tag.getVm().setId(VM_ID);
LinkHelper.addLinks(tag);
assertEquals(VM_TAG_HREF, tag.getHref());
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testAddWithPlacementPolicyHostsNames.
@Test
public void testAddWithPlacementPolicyHostsNames() throws Exception {
setUpAddVm();
for (int i = 0; i < NAMES.length; i++) {
setUpGetHostByNameExpectations(i);
}
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());
Hosts hosts = new Hosts();
for (int i = 0; i < NAMES.length; i++) {
Host newHost = new Host();
newHost.setName(NAMES[i]);
hosts.getHosts().add(newHost);
}
model.getPlacementPolicy().setHosts(hosts);
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 getModel.
static Vm getModel(int index) {
Vm model = new Vm();
model.setName(NAMES[index]);
model.setDescription(DESCRIPTIONS[index]);
model.setId(GUIDS[index].toString());
model.setCluster(new org.ovirt.engine.api.model.Cluster());
model.getCluster().setId(GUIDS[2].toString());
return model;
}
use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.
the class BackendVmsResourceTest method testCloneVmFromSnapshot.
@Test
public void testCloneVmFromSnapshot() throws Exception {
setUriInfo(setUpBasicUriExpectations());
org.ovirt.engine.core.common.businessentities.VM vmConfiguration = getEntity(0);
Map<Guid, org.ovirt.engine.core.common.businessentities.storage.Disk> diskImageMap = new HashMap<>();
diskImageMap.put(Guid.newGuid(), new DiskImage());
vmConfiguration.setDiskMap(diskImageMap);
setUriInfo(setUpBasicUriExpectations());
setUpGetPayloadExpectations(1, 2);
setUpGetBallooningExpectations(1, 2);
setUpGetGraphicsExpectations(1);
setUpGetCertuficateExpectations(1, 2);
setUpGetConsoleExpectations(2, 2);
setUpGetVmOvfExpectations(2);
setUpGetVirtioScsiExpectations(2);
setUpGetSoundcardExpectations(2);
setUpGetRngDeviceExpectations(2);
setUpEntityQueryExpectations(QueryType.GetVmConfigurationBySnapshot, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, vmConfiguration);
setUpCreationExpectations(ActionType.AddVmFromSnapshot, AddVmFromSnapshotParameters.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(createDiskAttachmentsCollection(), createSnapshotsCollection(1));
model.setTemplate(null);
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 testAddWithPlacementPolicyHostsIds.
@Test
public void testAddWithPlacementPolicyHostsIds() throws Exception {
setUpAddVm();
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());
Hosts hosts = new Hosts();
for (int i = 0; i < GUIDS.length; i++) {
Host newHost = new Host();
newHost.setId(GUIDS[i].toString());
hosts.getHosts().add(newHost);
}
model.getPlacementPolicy().setHosts(hosts);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Vm);
verifyModel((Vm) response.getEntity(), 2);
}
Aggregations