Search in sources :

Example 1 with HostStateChangeDenialReason

use of com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason in project vespa by vespa-engine.

the class HostResource method webExceptionWithDenialReason.

private static WebApplicationException webExceptionWithDenialReason(String operationDescription, HostName hostName, HostStateChangeDeniedException e) {
    HostStateChangeDenialReason hostStateChangeDenialReason = new HostStateChangeDenialReason(e.getConstraintName(), operationDescription + " failed: " + e.getMessage());
    UpdateHostResponse response = new UpdateHostResponse(hostName.s(), hostStateChangeDenialReason);
    return new WebApplicationException(hostStateChangeDenialReason.toString(), e, Response.status(Response.Status.CONFLICT).entity(response).type(MediaType.APPLICATION_JSON_TYPE).build());
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) WebApplicationException(javax.ws.rs.WebApplicationException) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason)

Example 2 with HostStateChangeDenialReason

use of com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason in project vespa by vespa-engine.

the class OrchestratorImplTest method testSuspendCallWithFailureReason.

@Test(expected = OrchestratorException.class)
public void testSuspendCallWithFailureReason() {
    when(configServerApi.put(OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName + "/suspended", Optional.empty(), UpdateHostResponse.class)).thenReturn(new UpdateHostResponse(hostName, new HostStateChangeDenialReason("hostname", "fail")));
    orchestrator.suspend(hostName);
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason) Test(org.junit.Test)

Example 3 with HostStateChangeDenialReason

use of com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason in project vespa by vespa-engine.

the class OrchestratorImplTest method testResumeCallWithFailureReason.

@Test(expected = OrchestratorException.class)
public void testResumeCallWithFailureReason() {
    when(configServerApi.delete(OrchestratorImpl.ORCHESTRATOR_PATH_PREFIX_HOST_API + "/" + hostName + "/suspended", UpdateHostResponse.class)).thenReturn(new UpdateHostResponse(hostName, new HostStateChangeDenialReason("hostname", "fail")));
    orchestrator.resume(hostName);
}
Also used : UpdateHostResponse(com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse) HostStateChangeDenialReason(com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason) Test(org.junit.Test)

Aggregations

HostStateChangeDenialReason (com.yahoo.vespa.orchestrator.restapi.wire.HostStateChangeDenialReason)3 UpdateHostResponse (com.yahoo.vespa.orchestrator.restapi.wire.UpdateHostResponse)3 Test (org.junit.Test)2 WebApplicationException (javax.ws.rs.WebApplicationException)1