Search in sources :

Example 81 with Vm

use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.

the class AffinityGroupMapperTest method testVmIds.

@Test
public void testVmIds() throws Exception {
    AffinityGroup model = new AffinityGroup();
    Vm vm = new Vm();
    final Guid vmGuid = Guid.newGuid();
    vm.setId(vmGuid.toString());
    model.setVms(new Vms());
    model.getVms().getVms().add(vm);
    org.ovirt.engine.core.common.scheduling.AffinityGroup entity = new org.ovirt.engine.core.common.scheduling.AffinityGroup();
    AffinityGroupMapper.map(model, entity);
    assertEquals(vmGuid, entity.getVmIds().get(0));
}
Also used : Vm(org.ovirt.engine.api.model.Vm) Guid(org.ovirt.engine.core.compat.Guid) Vms(org.ovirt.engine.api.model.Vms) AffinityGroup(org.ovirt.engine.api.model.AffinityGroup) Test(org.junit.Test)

Example 82 with Vm

use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.

the class LinkFollowerTest method testFollowLinks.

@Test
public void testFollowLinks() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    LinksTreeNode linksTree = linkFollower.createLinksTree(Vm.class, "nics,disk_attachments.disk");
    Vm vm = createVm();
    linkFollower.followLinks(vm, linksTree);
    assertNotNull(vm.getNics());
    assertNotNull(vm.getNics().getNics());
    assertFalse(vm.getNics().getNics().isEmpty());
    assertEquals(2, vm.getNics().getNics().size());
    assertNotNull(vm.getDiskAttachments());
    assertNotNull(vm.getDiskAttachments().getDiskAttachments());
    assertFalse(vm.getDiskAttachments().getDiskAttachments().isEmpty());
    assertEquals(3, vm.getDiskAttachments().getDiskAttachments().size());
    assertNotNull(vm.getDiskAttachments().getDiskAttachments().get(0).getDisk());
    assertNotNull(vm.getDiskAttachments().getDiskAttachments().get(1).getDisk());
    assertNotNull(vm.getDiskAttachments().getDiskAttachments().get(2).getDisk());
}
Also used : LinksTreeNode(org.ovirt.engine.api.restapi.resource.utils.LinksTreeNode) Vm(org.ovirt.engine.api.model.Vm) Test(org.junit.Test)

Example 83 with Vm

use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.

the class LinkHelperTest method testStatisticLinks.

@Test
public void testStatisticLinks() throws Exception {
    Statistic statistic = new Statistic();
    statistic.setId(STATISTIC_ID);
    statistic.setVm(new Vm());
    statistic.getVm().setId(VM_ID);
    LinkHelper.addLinks(statistic);
    assertEquals(STATISTIC_HREF, statistic.getHref());
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Vm(org.ovirt.engine.api.model.Vm) Test(org.junit.Test)

Example 84 with Vm

use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.

the class LinkHelperTest method testCdRomLinks.

@Test
public void testCdRomLinks() throws Exception {
    Cdrom cdrom = new Cdrom();
    cdrom.setId(CDROM_ID);
    cdrom.setVm(new Vm());
    cdrom.getVm().setId(VM_ID);
    LinkHelper.addLinks(cdrom);
    assertEquals(CDROM_HREF, cdrom.getHref());
}
Also used : Cdrom(org.ovirt.engine.api.model.Cdrom) Vm(org.ovirt.engine.api.model.Vm) Test(org.junit.Test)

Example 85 with Vm

use of org.ovirt.engine.api.model.Vm in project ovirt-engine by oVirt.

the class LinkHelperTest method testStorageDomainVmLinks.

@Test
public void testStorageDomainVmLinks() throws Exception {
    Vm vm = new Vm();
    vm.setId(VM_ID);
    vm.setStorageDomain(new StorageDomain());
    vm.getStorageDomain().setId(STORAGE_DOMAIN_ID);
    vm = LinkHelper.addLinks(vm);
    assertEquals(STORAGE_DOMAIN_VM_HREF, vm.getHref());
    assertEquals(STORAGE_DOMAIN_HREF, vm.getStorageDomain().getHref());
}
Also used : StorageDomain(org.ovirt.engine.api.model.StorageDomain) Vm(org.ovirt.engine.api.model.Vm) 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