Search in sources :

Example 1 with VmPlacementPolicy

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

the class V3VmPlacementPolicyInAdapter method adapt.

@Override
public VmPlacementPolicy adapt(V3VmPlacementPolicy from) {
    VmPlacementPolicy to = new VmPlacementPolicy();
    if (from.isSetAffinity()) {
        to.setAffinity(VmAffinity.fromValue(from.getAffinity()));
    }
    if (from.isSetHosts()) {
        to.setHosts(new Hosts());
        to.getHosts().getHosts().addAll(adaptIn(from.getHosts().getHosts()));
    }
    // V3 allowed specifying only one host, using "host" instead of "hosts":
    if (from.isSetHost() && !from.isSetHosts()) {
        Hosts hosts = new Hosts();
        Host host = adaptIn(from.getHost());
        hosts.getHosts().add(host);
        to.setHosts(hosts);
    }
    return to;
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Host(org.ovirt.engine.api.model.Host) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) V3VmPlacementPolicy(org.ovirt.engine.api.v3.types.V3VmPlacementPolicy)

Example 2 with VmPlacementPolicy

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

the class BackendVmResourceTest method testUpdateVmPolicySingleHostName.

@Test
public void testUpdateVmPolicySingleHostName() throws Exception {
    setUpUdpateVm();
    setUpGetHostByNameExpectations(1);
    setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
    Vm model = getModel(0);
    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]);
    verifyModel(resource.update(model), 0);
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) Test(org.junit.Test)

Example 3 with VmPlacementPolicy

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

the class BackendVmResourceTest method testUpdateVmPolicyHostsNames.

@Test
public void testUpdateVmPolicyHostsNames() throws Exception {
    setUpUdpateVm();
    for (int i = 0; i < NAMES.length; i++) {
        setUpGetHostByNameExpectations(i);
    }
    setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
    Vm model = getModel(0);
    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);
    verifyModel(resource.update(model), 0);
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) Test(org.junit.Test)

Example 4 with VmPlacementPolicy

use of org.ovirt.engine.api.model.VmPlacementPolicy 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);
}
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 5 with VmPlacementPolicy

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

the class BackendVmResourceTest method testUpdateVmPolicySingleHostId.

@Test
public void testUpdateVmPolicySingleHostId() throws Exception {
    setUpUdpateVm();
    setUriInfo(setUpActionExpectations(ActionType.UpdateVm, VmManagementParametersBase.class, new String[] {}, new Object[] {}, true, true));
    Vm model = getModel(0);
    model.setPlacementPolicy(new VmPlacementPolicy());
    model.getPlacementPolicy().setHosts(new Hosts());
    model.getPlacementPolicy().getHosts().getHosts().add(new Host());
    model.getPlacementPolicy().getHosts().getHosts().get(0).setId(GUIDS[1].toString());
    verifyModel(resource.update(model), 0);
}
Also used : Hosts(org.ovirt.engine.api.model.Hosts) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) VmPlacementPolicy(org.ovirt.engine.api.model.VmPlacementPolicy) Test(org.junit.Test)

Aggregations

Hosts (org.ovirt.engine.api.model.Hosts)12 VmPlacementPolicy (org.ovirt.engine.api.model.VmPlacementPolicy)12 Host (org.ovirt.engine.api.model.Host)11 Vm (org.ovirt.engine.api.model.Vm)9 Test (org.junit.Test)8 Response (javax.ws.rs.core.Response)4 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)4 Guid (org.ovirt.engine.core.compat.Guid)2 Action (org.ovirt.engine.api.model.Action)1 Cpu (org.ovirt.engine.api.model.Cpu)1 CpuTopology (org.ovirt.engine.api.model.CpuTopology)1 HighAvailability (org.ovirt.engine.api.model.HighAvailability)1 Io (org.ovirt.engine.api.model.Io)1 MemoryPolicy (org.ovirt.engine.api.model.MemoryPolicy)1 Usb (org.ovirt.engine.api.model.Usb)1 UsbType (org.ovirt.engine.api.model.UsbType)1 VmAffinity (org.ovirt.engine.api.model.VmAffinity)1 V3VmPlacementPolicy (org.ovirt.engine.api.v3.types.V3VmPlacementPolicy)1 RunVmOnceParams (org.ovirt.engine.core.common.action.RunVmOnceParams)1