Search in sources :

Example 1 with K8sNodeAdminService

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

the class K8sSyncRulesCommand method doExecute.

@Override
protected void doExecute() {
    K8sNodeAdminService adminService = get(K8sNodeAdminService.class);
    if (adminService == null) {
        error("Failed to re-install flow rules for kubernetes networking.");
        return;
    }
    adminService.completeNodes().forEach(node -> syncRulesBaseForNode(adminService, node));
    print("Successfully requested re-installing flow rules.");
}
Also used : K8sNodeAdminService(org.onosproject.k8snode.api.K8sNodeAdminService)

Example 2 with K8sNodeAdminService

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

the class K8sNodeInitCommand method doExecute.

@Override
protected void doExecute() {
    K8sNodeService nodeService = get(K8sNodeService.class);
    K8sNodeAdminService nodeAdminService = get(K8sNodeAdminService.class);
    if ((!isAll && !isIncomplete && hostnames == null) || (isAll && isIncomplete) || (isIncomplete && hostnames != null) || (hostnames != null && isAll)) {
        print("Please specify one of hostname, --all, and --incomplete options.");
        return;
    }
    if (isAll) {
        hostnames = nodeService.nodes().stream().map(K8sNode::hostname).toArray(String[]::new);
    } else if (isIncomplete) {
        hostnames = nodeService.nodes().stream().filter(node -> node.state() != COMPLETE).map(K8sNode::hostname).toArray(String[]::new);
    }
    for (String hostname : hostnames) {
        K8sNode node = nodeService.node(hostname);
        if (node == null) {
            print("Unable to find %s", hostname);
            continue;
        }
        print("Initializing %s", hostname);
        K8sNode updated = node.updateState(INIT);
        nodeAdminService.updateNode(updated);
    }
    print("Done.");
}
Also used : K8sNode(org.onosproject.k8snode.api.K8sNode) K8sNodeService(org.onosproject.k8snode.api.K8sNodeService) K8sNodeAdminService(org.onosproject.k8snode.api.K8sNodeAdminService)

Aggregations

K8sNodeAdminService (org.onosproject.k8snode.api.K8sNodeAdminService)2 K8sNode (org.onosproject.k8snode.api.K8sNode)1 K8sNodeService (org.onosproject.k8snode.api.K8sNodeService)1