use of org.onosproject.kubevirtnode.api.KubevirtNodeService in project onos by opennetworkinglab.
the class DefaultKubevirtPort method tenantDeviceId.
@Override
public DeviceId tenantDeviceId() {
KubevirtNetworkService networkService = DefaultServiceDirectory.getService(KubevirtNetworkService.class);
KubevirtNodeService nodeService = DefaultServiceDirectory.getService(KubevirtNodeService.class);
KubevirtNetwork network = networkService.network(networkId);
KubevirtNode node = nodeService.node(deviceId);
if (network == null || node == null) {
return null;
} else {
return network.tenantDeviceId(node.hostname());
}
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeService in project onos by opennetworkinglab.
the class KubevirtHostnameCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
KubevirtNodeService nodeService = get(KubevirtNodeService.class);
Set<String> hostnames = nodeService.nodes().stream().map(KubevirtNode::hostname).collect(Collectors.toSet());
SortedSet<String> strings = delegate.getStrings();
strings.addAll(hostnames);
return delegate.complete(session, commandLine, candidates);
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeService in project onos by opennetworkinglab.
the class KubevirtCheckNodeCommand method doExecute.
@Override
protected void doExecute() throws Exception {
KubevirtNodeService nodeService = get(KubevirtNodeService.class);
DeviceService deviceService = get(DeviceService.class);
KubevirtNode node = nodeService.node(hostname);
if (node == null) {
print("Cannot find %s from registered nodes", hostname);
return;
}
print("[Integration Bridge Status]");
Device intgBridge = deviceService.getDevice(node.intgBridge());
if (intgBridge != null) {
print("%s %s=%s available=%s %s", deviceService.isAvailable(intgBridge.id()) ? MSG_PASS : MSG_FAIL, INTEGRATION_BRIDGE, intgBridge.id(), deviceService.isAvailable(intgBridge.id()), intgBridge.annotations());
}
print("");
print("[Tunnel Bridge Status]");
Device tunBridge = deviceService.getDevice(node.tunBridge());
if (tunBridge != null) {
print("%s %s=%s available=%s %s", deviceService.isAvailable(tunBridge.id()) ? MSG_PASS : MSG_FAIL, TUNNEL_BRIDGE, tunBridge.id(), deviceService.isAvailable(tunBridge.id()), tunBridge.annotations());
if (node.dataIp() != null) {
printPortState(deviceService, node.tunBridge(), VXLAN);
printPortState(deviceService, node.tunBridge(), GRE);
printPortState(deviceService, node.tunBridge(), GENEVE);
}
}
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeService in project onos by opennetworkinglab.
the class KubevirtListNodesCommand method doExecute.
@Override
protected void doExecute() throws Exception {
KubevirtNodeService nodeService = get(KubevirtNodeService.class);
List<KubevirtNode> nodes = Lists.newArrayList(nodeService.nodes());
nodes.sort(Comparator.comparing(KubevirtNode::hostname));
String format = genFormatString(ImmutableList.of(HOSTNAME_LENGTH, TYPE_LENGTH, MANAGEMENT_IP_LENGTH, DATA_IP_LENGTH, STATUS));
if (outputJson()) {
print("%s", json(nodes));
} else {
print(format, "Hostname", "Type", "Management IP", "Data IP", "State");
for (KubevirtNode node : nodes) {
print(format, StringUtils.substring(node.hostname(), 0, HOSTNAME_LENGTH - MARGIN_LENGTH), node.type(), StringUtils.substring(node.managementIp().toString(), 0, MANAGEMENT_IP_LENGTH - MARGIN_LENGTH), node.dataIp() != null ? StringUtils.substring(node.dataIp().toString(), 0, DATA_IP_LENGTH - MARGIN_LENGTH) : "", node.state());
}
print("Total %s nodes", nodeService.nodes().size());
}
}
use of org.onosproject.kubevirtnode.api.KubevirtNodeService 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();
}
Aggregations