Search in sources :

Example 1 with KubevirtApiConfigService

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

the class KubevirtListApiConfigsCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    KubevirtApiConfigService service = get(KubevirtApiConfigService.class);
    KubevirtApiConfig config = service.apiConfig();
    if (outputJson()) {
        print("%s", json(config));
    } else {
        print(FORMAT, "Scheme", "Server IP", "Port", "Controller IP", "State");
        String controllerIp = "N/A";
        if (config != null) {
            if (config.controllerIp() != null) {
                controllerIp = config.controllerIp().toString();
            }
            print(FORMAT, config.scheme().name(), config.ipAddress().toString(), config.port(), controllerIp, config.state().name());
        } else {
            print("Kubevirt config not found!");
        }
    }
}
Also used : KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig) KubevirtApiConfigService(org.onosproject.kubevirtnode.api.KubevirtApiConfigService)

Example 2 with KubevirtApiConfigService

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

the class KubevirtSyncStateCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    KubevirtApiConfigService apiConfigService = get(KubevirtApiConfigService.class);
    print("Re-synchronizing Kubevirt node states..");
    KubevirtApiConfig config = apiConfigService.apiConfig();
    bootstrapKubevirtNodes(config);
    print("Done.");
}
Also used : KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig) KubevirtApiConfigService(org.onosproject.kubevirtnode.api.KubevirtApiConfigService)

Example 3 with KubevirtApiConfigService

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

the class KubevirtNodeWebResource method healthz.

/**
 * Returns the health check result.
 *
 * @return 200 OK with health check result, 404 not found
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("healthz")
public Response healthz() {
    KubevirtApiConfigService configService = get(KubevirtApiConfigService.class);
    KubevirtNodeService nodeService = get(KubevirtNodeService.class);
    // TODO: we need to add more health check items
    boolean allInit = true;
    KubevirtApiConfig config = configService.apiConfig();
    if (nodeService.nodes().size() == 0) {
        allInit = false;
    } else {
        for (KubevirtNode node : nodeService.nodes()) {
            if (node.state() != INIT) {
                allInit = false;
            }
        }
    }
    String result = ERROR;
    if (config != null && !allInit) {
        result = OK;
    }
    ObjectNode jsonResult = mapper().createObjectNode();
    jsonResult.put(API_CONFIG, result);
    return ok(jsonResult).build();
}
Also used : KubevirtNodeService(org.onosproject.kubevirtnode.api.KubevirtNodeService) KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig) KubevirtApiConfigService(org.onosproject.kubevirtnode.api.KubevirtApiConfigService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

KubevirtApiConfig (org.onosproject.kubevirtnode.api.KubevirtApiConfig)3 KubevirtApiConfigService (org.onosproject.kubevirtnode.api.KubevirtApiConfigService)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 KubevirtNode (org.onosproject.kubevirtnode.api.KubevirtNode)1 KubevirtNodeService (org.onosproject.kubevirtnode.api.KubevirtNodeService)1