Search in sources :

Example 16 with Host

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

the class BackendHostResourceTest method testUpdateWithClusterName.

@Test
public void testUpdateWithClusterName() throws Exception {
    String clusterName = "Default";
    setUpGetEntityExpectations(3);
    setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { clusterName }, getCluster(clusterName, GUIDS[1]));
    setUriInfo(setUpActionExpectations(ActionType.ChangeVDSCluster, ChangeVDSClusterParameters.class, new String[] { "ClusterId", "VdsId" }, new Object[] { GUIDS[1], GUIDS[0] }, true, true, new ActionReturnValue(), false));
    setUriInfo(setUpActionExpectations(ActionType.UpdateVds, UpdateVdsActionParameters.class, new String[] { "RootPassword" }, new Object[] { ROOT_PASSWORD }, true, true));
    org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
    cluster.setName(clusterName);
    Host host = getModel(0);
    host.setCluster(cluster);
    verifyModel(resource.update(host), 0);
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Host(org.ovirt.engine.api.model.Host) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) Test(org.junit.Test)

Example 17 with Host

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

the class BackendHostsResourceTest method getModel.

static Host getModel(int index) {
    Host model = new Host();
    model.setName(NAMES[index]);
    model.setAddress(ADDRESSES[index]);
    model.setRootPassword(ROOT_PASSWORD);
    return model;
}
Also used : Host(org.ovirt.engine.api.model.Host)

Example 18 with Host

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

the class BackendHostsResourceTest method doTestBadAddHost.

private void doTestBadAddHost(boolean valid, boolean success, String detail) throws Exception {
    setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { "Default" }, setUpCluster(GUIDS[1]));
    setUriInfo(setUpActionExpectations(ActionType.AddVds, AddVdsActionParameters.class, new String[] { "RootPassword" }, new Object[] { ROOT_PASSWORD }, valid, success));
    Host model = getModel(0);
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Host(org.ovirt.engine.api.model.Host) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)

Example 19 with Host

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

the class BackendHostsResourceTest method testAddHost.

@Test
public void testAddHost() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { "Default" }, setUpCluster(GUIDS[1]));
    setUpCreationExpectations(ActionType.AddVds, AddVdsActionParameters.class, new String[] { "RootPassword" }, new Object[] { ROOT_PASSWORD }, true, true, GUIDS[0], QueryType.GetVdsByVdsId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Host model = getModel(0);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Host);
    verifyModel((Host) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) Host(org.ovirt.engine.api.model.Host) Test(org.junit.Test)

Example 20 with Host

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

the class CompletenessAssertorTest method testMissingSubFieldAlternatives.

@Test
public void testMissingSubFieldAlternatives() throws Exception {
    Vm vm = new Vm();
    vm.setDescription("incomplete");
    vm.setHost(new Host());
    try {
        CompletenessAssertor.validateParameters(vm, "host.id|name");
        fail("expected WebApplicationException on incomplete model");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Vm", "host.id|name");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Vm(org.ovirt.engine.api.model.Vm) Host(org.ovirt.engine.api.model.Host) 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