use of org.onosproject.kubevirtnode.api.KubevirtNode 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.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtNodeWebResource method readNodeConfiguration.
private Set<KubevirtNode> readNodeConfiguration(InputStream input) {
Set<KubevirtNode> nodeSet = Sets.newHashSet();
try {
JsonNode jsonTree = readTreeFromStream(mapper().enable(INDENT_OUTPUT), input);
ArrayNode nodes = (ArrayNode) jsonTree.path(NODES);
nodes.forEach(node -> {
try {
ObjectNode objectNode = node.deepCopy();
KubevirtNode kubevirtNode = codec(KubevirtNode.class).decode(objectNode, this);
nodeSet.add(kubevirtNode);
} catch (Exception e) {
log.error("Exception occurred due to {}", e);
throw new IllegalArgumentException();
}
});
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
return nodeSet;
}
use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtNodeCodecTest method testKubevirtComputeNodeDecode.
/**
* Tests the kubevirt compute node decoding.
*
* @throws IOException io exception
*/
@Test
public void testKubevirtComputeNodeDecode() throws IOException {
KubevirtNode node = getKubevirtNode("KubevirtWorkerNode.json");
assertThat(node.hostname(), is("worker-01"));
assertThat(node.type().name(), is("WORKER"));
assertThat(node.managementIp().toString(), is("172.16.130.4"));
assertThat(node.dataIp().toString(), is("172.16.130.4"));
assertThat(node.intgBridge().toString(), is("of:00000000000000a1"));
assertThat(node.tunBridge().toString(), is("of:00000000000000a2"));
assertThat(node.phyIntfs().size(), is(2));
node.phyIntfs().forEach(intf -> {
if (intf.network().equals("mgmtnetwork")) {
assertThat(intf.intf(), is("eth3"));
assertThat(intf.physBridge().toString(), is("of:00000000000000a3"));
}
if (intf.network().equals("oamnetwork")) {
assertThat(intf.intf(), is("eth4"));
assertThat(intf.physBridge().toString(), is("of:00000000000000a4"));
}
});
}
use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtNodeCodecTest method testKubevirtGatweayNodeEncode.
/**
* Tests the kubevirt gateway node encoding.
*/
@Test
public void testKubevirtGatweayNodeEncode() {
KubevirtNode node = DefaultKubevirtNode.builder().hostname("gateway").type(KubevirtNode.Type.GATEWAY).state(KubevirtNodeState.INIT).managementIp(IpAddress.valueOf("10.10.10.1")).intgBridge(DeviceId.deviceId("br-int")).tunBridge(DeviceId.deviceId("br-tun")).dataIp(IpAddress.valueOf("20.20.20.2")).gatewayBridgeName("gateway").build();
ObjectNode nodeJson = kubevirtNodeCodec.encode(node, context);
assertThat(nodeJson, matchesKubevirtNode(node));
}
use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.
the class KubevirtNodeCodecTest method testKubevirtGatewayNodeDecode.
/**
* Tests the kubevirt gateway node decoding.
*
* @throws IOException io exception
*/
@Test
public void testKubevirtGatewayNodeDecode() throws IOException {
KubevirtNode node = getKubevirtNode("KubevirtGatewayNode.json");
assertThat(node.hostname(), is("gateway-01"));
assertThat(node.type().name(), is("GATEWAY"));
assertThat(node.managementIp().toString(), is("172.16.130.4"));
assertThat(node.dataIp().toString(), is("172.16.130.4"));
assertThat(node.intgBridge().toString(), is("of:00000000000000a1"));
assertThat(node.tunBridge().toString(), is("of:00000000000000a2"));
assertThat(node.gatewayBridgeName(), is("gateway"));
}
Aggregations