use of org.onosproject.k8snode.api.K8sApiConfig in project onos by opennetworkinglab.
the class K8sNodeWebResource method updateApiConfigs.
/**
* Updates a set of kubernetes API config from the JSON input stream.
*
* @param input kubernetes API configs JSON input stream
* @return 200 OK with the updated kubernetes API config, 400 BAD_REQUEST
* if the JSON is malformed, and 304 NOT_MODIFIED without the updated config
* @onos.rsModel K8sApiConfig
*/
@PUT
@Path("api")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateApiConfigs(InputStream input) {
log.trace(String.format(MESSAGE_NODE, UPDATE));
Set<K8sApiConfig> configs = readApiConfigConfiguration(input);
for (K8sApiConfig config : configs) {
K8sApiConfig existing = configAdminService.apiConfig(endpoint(config));
if (existing == null) {
log.warn("There is no API configuration to update : {}", endpoint(config));
return Response.notModified().build();
} else if (!existing.equals(config)) {
configAdminService.updateApiConfig(config);
}
}
return Response.ok().build();
}
use of org.onosproject.k8snode.api.K8sApiConfig in project onos by opennetworkinglab.
the class K8sApiConfigCodecTest method testK8sApiConfigDecode.
/**
* Tests the kubernetes API config decoding.
*
* @throws IOException IO exception
*/
@Test
public void testK8sApiConfigDecode() throws IOException {
K8sApiConfig config = getK8sApiConfig("K8sApiConfig.json");
assertEquals("kubernetes", config.clusterName());
assertEquals(1, config.segmentId());
assertEquals("192.168.200.0/24", config.extNetworkCidr().toString());
assertEquals("NORMAL", config.mode().name());
assertEquals("HTTPS", config.scheme().name());
assertEquals("10.134.34.223", config.ipAddress().toString());
assertEquals(6443, config.port());
assertEquals("token", config.token());
assertEquals("caCertData", config.caCertData());
assertEquals("clientCertData", config.clientCertData());
assertEquals("clientKeyData", config.clientKeyData());
assertTrue(config.dvr());
Set<HostNodesInfo> infos = config.infos();
assertEquals(1, infos.size());
}
use of org.onosproject.k8snode.api.K8sApiConfig in project onos by opennetworkinglab.
the class K8sApiConfigCodecTest method testK8sApiConfigEncode.
/**
* Tests the kubernetes API config encoding.
*/
@Test
public void testK8sApiConfigEncode() {
HostNodesInfo info = new DefaultHostNodesInfo.Builder().hostIp(IpAddress.valueOf("192.168.10.10")).nodes(ImmutableSet.of("master", "worker")).build();
K8sApiConfig config = DefaultK8sApiConfig.builder().clusterName("kubernetes").segmentId(1).extNetworkCidr(IpPrefix.valueOf("192.168.200.0/24")).mode(K8sApiConfig.Mode.NORMAL).scheme(K8sApiConfig.Scheme.HTTPS).ipAddress(IpAddress.valueOf("10.10.10.23")).port(6443).state(CONNECTED).token("token").caCertData("caCertData").clientCertData("clientCertData").clientKeyData("clientKeyData").infos(ImmutableSet.of(info)).dvr(true).build();
ObjectNode configJson = k8sApiConfigCodec.encode(config, context);
assertThat(configJson, matchesK8sApiConfig(config));
}
use of org.onosproject.k8snode.api.K8sApiConfig in project onos by opennetworkinglab.
the class K8sApiConfigManager method removeApiConfig.
@Override
public K8sApiConfig removeApiConfig(String endpoint) {
checkArgument(!Strings.isNullOrEmpty(endpoint), ERR_NULL_ENDPOINT);
K8sApiConfig config = configStore.removeApiConfig(endpoint);
log.info(String.format(MSG_CONFIG, endpoint, MSG_REMOVED));
return config;
}
Aggregations