Search in sources :

Example 11 with KubevirtApiConfig

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

the class KubevirtApiConfigManager method removeApiConfig.

@Override
public KubevirtApiConfig removeApiConfig(String endpoint) {
    checkArgument(!Strings.isNullOrEmpty(endpoint), ERR_NULL_ENDPOINT);
    KubevirtApiConfig config = configStore.removeApiConfig(endpoint);
    log.info(String.format(MSG_CONFIG, endpoint, MSG_REMOVED));
    return config;
}
Also used : KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig)

Example 12 with KubevirtApiConfig

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

the class KubevirtNodeWatcher method instantiateNodeWatcher.

private void instantiateNodeWatcher() {
    KubevirtApiConfig config = kubevirtApiConfigService.apiConfig();
    if (config == null) {
        return;
    }
    KubernetesClient client = k8sClient(config);
    if (client != null) {
        client.nodes().watch(internalKubevirtNodeWatcher);
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig)

Example 13 with KubevirtApiConfig

use of org.onosproject.kubevirtnode.api.KubevirtApiConfig 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)

Example 14 with KubevirtApiConfig

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

the class KubevirtApiConfigCodecTest method testKubevirtApiConfigEncode.

/**
 * Tests the KubeVirt API config encoding.
 */
@Test
public void testKubevirtApiConfigEncode() {
    KubevirtApiConfig config = DefaultKubevirtApiConfig.builder().scheme(HTTPS).ipAddress(IpAddress.valueOf("10.10.10.23")).port(6443).state(CONNECTED).token("token").caCertData("caCertData").clientCertData("clientCertData").clientKeyData("clientKeyData").serviceFqdn("kubevirt.edgestack.svc.cluster.local").apiServerFqdn("kubernetes.default.svc.cluster.local").controllerIp(IpAddress.valueOf("127.0.0.1")).build();
    ObjectNode configJson = kubevirtApiConfigCodec.encode(config, context);
    assertThat(configJson, matchesKubevirtApiConfig(config));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) KubevirtApiConfig(org.onosproject.kubevirtnode.api.KubevirtApiConfig) DefaultKubevirtApiConfig(org.onosproject.kubevirtnode.api.DefaultKubevirtApiConfig) KubevirtApiConfigJsonMatcher.matchesKubevirtApiConfig(org.onosproject.kubevirtnode.codec.KubevirtApiConfigJsonMatcher.matchesKubevirtApiConfig) Test(org.junit.Test)

Aggregations

KubevirtApiConfig (org.onosproject.kubevirtnode.api.KubevirtApiConfig)14 DefaultKubevirtApiConfig (org.onosproject.kubevirtnode.api.DefaultKubevirtApiConfig)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Produces (javax.ws.rs.Produces)3 KubevirtApiConfigService (org.onosproject.kubevirtnode.api.KubevirtApiConfigService)3 KubevirtApiConfigJsonMatcher.matchesKubevirtApiConfig (org.onosproject.kubevirtnode.codec.KubevirtApiConfigJsonMatcher.matchesKubevirtApiConfig)3 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2 Consumes (javax.ws.rs.Consumes)2 Path (javax.ws.rs.Path)2 Test (org.junit.Test)2 IpAddress (org.onlab.packet.IpAddress)2 KubevirtApiConfigAdminService (org.onosproject.kubevirtnode.api.KubevirtApiConfigAdminService)2 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)1 InputStream (java.io.InputStream)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 KubevirtNode (org.onosproject.kubevirtnode.api.KubevirtNode)1