Search in sources :

Example 86 with Vm

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());
}
Also used : Vm(org.ovirt.engine.api.model.Vm) Tag(org.ovirt.engine.api.model.Tag) Test(org.junit.Test)

Example 87 with Vm

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);
}
Also used : Response(javax.ws.rs.core.Response) Hosts(org.ovirt.engine.api.model.Hosts) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) Test(org.junit.Test)

Example 88 with Vm

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;
}
Also used : Vm(org.ovirt.engine.api.model.Vm)

Example 89 with Vm

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);
}
Also used : Response(javax.ws.rs.core.Response) HashMap(java.util.HashMap) Vm(org.ovirt.engine.api.model.Vm) Guid(org.ovirt.engine.core.compat.Guid) Disk(org.ovirt.engine.api.model.Disk) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) Test(org.junit.Test)

Example 90 with Vm

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);
}
Also used : Response(javax.ws.rs.core.Response) Hosts(org.ovirt.engine.api.model.Hosts) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) Test(org.junit.Test)

Aggregations

Vm (org.ovirt.engine.api.model.Vm)145 Test (org.junit.Test)80 Response (javax.ws.rs.core.Response)26 Host (org.ovirt.engine.api.model.Host)21 WebApplicationException (javax.ws.rs.WebApplicationException)19 Guid (org.ovirt.engine.core.compat.Guid)15 Template (org.ovirt.engine.api.model.Template)11 Hosts (org.ovirt.engine.api.model.Hosts)10 Action (org.ovirt.engine.api.model.Action)9 VmPlacementPolicy (org.ovirt.engine.api.model.VmPlacementPolicy)9 Vms (org.ovirt.engine.api.model.Vms)8 RunVmOnceParams (org.ovirt.engine.core.common.action.RunVmOnceParams)8 VM (org.ovirt.engine.core.common.businessentities.VM)8 Disk (org.ovirt.engine.api.model.Disk)7 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)7 ArrayList (java.util.ArrayList)6 Nic (org.ovirt.engine.api.model.Nic)6 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)6 Configuration (org.ovirt.engine.api.model.Configuration)5 DiskAttachment (org.ovirt.engine.api.model.DiskAttachment)5