Search in sources :

Example 6 with K8sNodeService

use of org.onosproject.k8snode.api.K8sNodeService in project onos by opennetworkinglab.

the class K8sHostnameCompleter method complete.

@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
    StringsCompleter delegate = new StringsCompleter();
    K8sNodeService nodeService = get(K8sNodeService.class);
    Set<String> hostnames = nodeService.nodes().stream().map(K8sNode::hostname).collect(Collectors.toSet());
    SortedSet<String> strings = delegate.getStrings();
    strings.addAll(hostnames);
    return delegate.complete(session, commandLine, candidates);
}
Also used : StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) K8sNodeService(org.onosproject.k8snode.api.K8sNodeService)

Example 7 with K8sNodeService

use of org.onosproject.k8snode.api.K8sNodeService in project onos by opennetworkinglab.

the class K8sNodeCheckCommand method doExecute.

@Override
protected void doExecute() {
    K8sNodeService nodeService = get(K8sNodeService.class);
    DeviceService deviceService = get(DeviceService.class);
    K8sNode 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_OK : MSG_ERROR, node.intgBridgeName(), intgBridge.id(), deviceService.isAvailable(intgBridge.id()), intgBridge.annotations());
        printPortState(deviceService, node.intgBridge(), node.intgBridgePortName());
        printPortState(deviceService, node.intgBridge(), node.intgToExtPatchPortName());
        printPortState(deviceService, node.intgBridge(), node.intgToLocalPatchPortName());
    } else {
        print("%s %s=%s is not available", MSG_ERROR, node.intgBridgeName(), node.intgBridge());
    }
    print("");
    print("[External Bridge Status]");
    Device extBridge = deviceService.getDevice(node.extBridge());
    if (extBridge != null) {
        print("%s %s=%s available=%s %s", deviceService.isAvailable(extBridge.id()) ? MSG_OK : MSG_ERROR, node.extBridgeName(), extBridge.id(), deviceService.isAvailable(extBridge.id()), extBridge.annotations());
        printPortState(deviceService, node.extBridge(), node.extToIntgPatchPortName());
    } else {
        print("%s %s=%s is not available", MSG_ERROR, node.extBridgeName(), node.extBridge());
    }
    print("");
    print("[Local Bridge Status]");
    Device localBridge = deviceService.getDevice(node.localBridge());
    if (localBridge != null) {
        print("%s %s=%s available=%s %s", deviceService.isAvailable(localBridge.id()) ? MSG_OK : MSG_ERROR, node.localBridgeName(), localBridge.id(), deviceService.isAvailable(localBridge.id()), localBridge.annotations());
        printPortState(deviceService, node.localBridge(), node.localToIntgPatchPortName());
    }
    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_OK : MSG_ERROR, node.tunBridgeName(), tunBridge.id(), deviceService.isAvailable(tunBridge.id()), tunBridge.annotations());
        printPortState(deviceService, node.tunBridge(), node.tunToIntgPatchPortName());
        if (node.dataIp() != null) {
            printPortState(deviceService, node.tunBridge(), node.vxlanPortName());
            printPortState(deviceService, node.tunBridge(), node.grePortName());
            printPortState(deviceService, node.tunBridge(), node.genevePortName());
        }
    }
}
Also used : K8sNode(org.onosproject.k8snode.api.K8sNode) Device(org.onosproject.net.Device) K8sNodeService(org.onosproject.k8snode.api.K8sNodeService) DeviceService(org.onosproject.net.device.DeviceService)

Aggregations

K8sNodeService (org.onosproject.k8snode.api.K8sNodeService)7 K8sNode (org.onosproject.k8snode.api.K8sNode)6 ApplicationId (org.onosproject.core.ApplicationId)3 CoreService (org.onosproject.core.CoreService)3 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 EndpointAddress (io.fabric8.kubernetes.api.model.EndpointAddress)2 EndpointPort (io.fabric8.kubernetes.api.model.EndpointPort)2 EndpointSubset (io.fabric8.kubernetes.api.model.EndpointSubset)2 Endpoints (io.fabric8.kubernetes.api.model.Endpoints)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 Service (io.fabric8.kubernetes.api.model.Service)2 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)2 Dictionary (java.util.Dictionary)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Set (java.util.Set)2 ExecutorService (java.util.concurrent.ExecutorService)2 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)2