use of org.onosproject.kubevirtnode.api.KubevirtNodeAdminService in project onos by opennetworkinglab.
the class KubevirtNodeWebResource method deleteNode.
/**
* Removes a set of KubeVirt nodes' config from the JSON input stream.
*
* @param hostname host name contained in KubeVirt nodes configuration
* @return 204 NO_CONTENT, 400 BAD_REQUEST if the JSON is malformed, and
* 304 NOT_MODIFIED without the updated config
*/
@DELETE
@Path("{hostname}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteNode(@PathParam("hostname") String hostname) {
log.trace(String.format(MESSAGE_NODE, REMOVE));
KubevirtNodeAdminService service = get(KubevirtNodeAdminService.class);
KubevirtNode existing = service.node(nullIsIllegal(hostname, HOST_NAME + ERROR_MESSAGE));
if (existing == null) {
log.warn("There is no node configuration to delete : {}", hostname);
return Response.notModified().build();
} else {
service.removeNode(hostname);
}
return Response.noContent().build();
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeAdminService in project onos by opennetworkinglab.
the class KubevirtNodeWebResource method initNode.
/**
* Initializes KubeVirt node.
*
* @param hostname hostname of KubeVirt node
* @return 200 OK with init result, 404 not found, 500 server error
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("init/{hostname}")
public Response initNode(@PathParam("hostname") String hostname) {
log.trace(String.format(MESSAGE_NODE, QUERY));
KubevirtNodeAdminService service = get(KubevirtNodeAdminService.class);
KubevirtNode node = service.node(hostname);
if (node == null) {
log.error("Given node {} does not exist", hostname);
return Response.serverError().build();
}
KubevirtNode updated = node.updateState(INIT);
service.updateNode(updated);
return ok(mapper().createObjectNode()).build();
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeAdminService 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();
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeAdminService in project onos by opennetworkinglab.
the class KubevirtNodeWebResource method stateOfNode.
/**
* Obtains the state of the KubeVirt node.
*
* @param hostname hostname of the KubeVirt
* @return the state of the KubeVirt node in Json
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("state/{hostname}")
public Response stateOfNode(@PathParam("hostname") String hostname) {
log.trace(String.format(MESSAGE_NODE, QUERY));
KubevirtNodeAdminService service = get(KubevirtNodeAdminService.class);
KubevirtNode node = service.node(hostname);
String nodeState = node != null ? node.state().toString() : NOT_EXIST;
return ok(mapper().createObjectNode().put(STATE, nodeState)).build();
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeAdminService in project onos by opennetworkinglab.
the class KubevirtNodeWebResource method syncRules.
/**
* Synchronizes the flow rules.
*
* @return 200 OK with sync result, 404 not found
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("sync/rules")
public Response syncRules() {
KubevirtNodeAdminService service = get(KubevirtNodeAdminService.class);
service.completeNodes().forEach(node -> syncRulesBase(service, node));
return ok(mapper().createObjectNode()).build();
}
Aggregations