Search in sources :

Example 1 with INIT

use of org.onosproject.kubevirtnode.api.KubevirtNodeState.INIT in project onos by opennetworkinglab.

the class KubevirtNodeWebResource method initIncompleteNodes.

/**
 * Initializes KubeVirt nodes which are in the stats other than COMPLETE.
 *
 * @return 200 OK with init result, 500 server error
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("init/incomplete")
public Response initIncompleteNodes() {
    log.trace(String.format(MESSAGE_NODE, QUERY));
    KubevirtNodeAdminService service = get(KubevirtNodeAdminService.class);
    service.nodes().stream().filter(n -> n.state() != KubevirtNodeState.COMPLETE).forEach(n -> {
        KubevirtNode updated = n.updateState(INIT);
        service.updateNode(updated);
    });
    return ok(mapper().createObjectNode()).build();
}
Also used : PathParam(javax.ws.rs.PathParam) AbstractWebResource(org.onosproject.rest.AbstractWebResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig) KubevirtNodeService(org.onosproject.kubevirtnode.api.KubevirtNodeService) COMPLETE(org.onosproject.kubevirtnode.api.KubevirtNodeState.COMPLETE) INDENT_OUTPUT(com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) KubevirtApiConfigService(org.onosproject.kubevirtnode.api.KubevirtApiConfigService) MediaType(javax.ws.rs.core.MediaType) Consumes(javax.ws.rs.Consumes) JsonNode(com.fasterxml.jackson.databind.JsonNode) UriBuilder(javax.ws.rs.core.UriBuilder) Tools.nullIsIllegal(org.onlab.util.Tools.nullIsIllegal) DELETE(javax.ws.rs.DELETE) KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) Context(javax.ws.rs.core.Context) Set(java.util.Set) Sets(com.google.common.collect.Sets) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) KubevirtNodeAdminService(org.onosproject.kubevirtnode.api.KubevirtNodeAdminService) Response(javax.ws.rs.core.Response) INIT(org.onosproject.kubevirtnode.api.KubevirtNodeState.INIT) KubevirtNodeUtil.waitFor(org.onosproject.kubevirtnode.util.KubevirtNodeUtil.waitFor) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) KubevirtNodeState(org.onosproject.kubevirtnode.api.KubevirtNodeState) Tools.readTreeFromStream(org.onlab.util.Tools.readTreeFromStream) InputStream(java.io.InputStream) Response.created(javax.ws.rs.core.Response.created) KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) KubevirtNodeAdminService(org.onosproject.kubevirtnode.api.KubevirtNodeAdminService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 INDENT_OUTPUT (com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Sets (com.google.common.collect.Sets)1 InputStream (java.io.InputStream)1 Set (java.util.Set)1 Consumes (javax.ws.rs.Consumes)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 Context (javax.ws.rs.core.Context)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1 Response.created (javax.ws.rs.core.Response.created)1 UriBuilder (javax.ws.rs.core.UriBuilder)1