Search in sources :

Example 41 with Host

use of org.ovirt.engine.api.model.Host 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 42 with Host

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

the class BackendVmResourceTest method testMigrateWithHostId.

@Test
public void testMigrateWithHostId() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.MigrateVmToServer, MigrateVmToServerParameters.class, new String[] { "VmId", "VdsId", "ForceMigrationForNonMigratableVm" }, new Object[] { GUIDS[0], GUIDS[1], Boolean.FALSE }));
    Action action = new Action();
    action.setHost(new Host());
    action.getHost().setId(GUIDS[1].toString());
    verifyActionResponse(resource.migrate(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) MigrateVmToServerParameters(org.ovirt.engine.core.common.action.MigrateVmToServerParameters) Host(org.ovirt.engine.api.model.Host) Test(org.junit.Test)

Example 43 with Host

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

the class BackendVmResourceTest method testStartWithHostId.

@Test
public void testStartWithHostId() throws Exception {
    Host host = new Host();
    host.setId(GUIDS[1].toString());
    testStartWithHost(host, GUIDS[1]);
}
Also used : Host(org.ovirt.engine.api.model.Host) Test(org.junit.Test)

Example 44 with Host

use of org.ovirt.engine.api.model.Host 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 45 with Host

use of org.ovirt.engine.api.model.Host 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

Host (org.ovirt.engine.api.model.Host)114 Test (org.junit.Test)58 Vm (org.ovirt.engine.api.model.Vm)21 Response (javax.ws.rs.core.Response)15 Hosts (org.ovirt.engine.api.model.Hosts)15 StorageDomain (org.ovirt.engine.api.model.StorageDomain)13 WebApplicationException (javax.ws.rs.WebApplicationException)12 VDS (org.ovirt.engine.core.common.businessentities.VDS)12 VmPlacementPolicy (org.ovirt.engine.api.model.VmPlacementPolicy)11 Guid (org.ovirt.engine.core.compat.Guid)10 Cluster (org.ovirt.engine.api.model.Cluster)7 HostNic (org.ovirt.engine.api.model.HostNic)6 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)5 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)5 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)3 AffinityGroup (org.ovirt.engine.api.model.AffinityGroup)3 HostStorage (org.ovirt.engine.api.model.HostStorage)3 HostType (org.ovirt.engine.api.model.HostType)3 Spm (org.ovirt.engine.api.model.Spm)3