Search in sources :

Example 1 with OpenstackNodeAdminService

use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.

the class OpenstackConfigStatefulSnatCommand method syncRules.

private void syncRules() {
    // All handlers in this application reacts the node complete event and
    // tries to re-configure flow rules for the complete node.
    OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
    OpenstackNodeAdminService osNodeAdminService = get(OpenstackNodeAdminService.class);
    if (osNodeService == null) {
        error("Failed to re-install flow rules for OpenStack networking.");
        return;
    }
    osNodeService.completeNodes().forEach(osNode -> {
        OpenstackNode updated = osNode.updateState(NodeState.INIT);
        osNodeAdminService.updateNode(updated);
    });
}
Also used : OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Example 2 with OpenstackNodeAdminService

use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.

the class OpenstackConfigArpModeCommand method syncRules.

private void syncRules() {
    // All handlers in this application reacts the node complete event and
    // tries to re-configure flow rules for the complete node.
    OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
    OpenstackNodeAdminService osNodeAdminService = get(OpenstackNodeAdminService.class);
    if (osNodeService == null) {
        error("Failed to re-install flow rules for OpenStack networking.");
        return;
    }
    osNodeService.completeNodes().forEach(osNode -> {
        OpenstackNode updated = osNode.updateState(NodeState.INIT);
        osNodeAdminService.updateNode(updated);
    });
}
Also used : OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Example 3 with OpenstackNodeAdminService

use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.

the class OpenstackFlowTraceCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackNodeAdminService osNodeService = get(OpenstackNodeAdminService.class);
    InstancePortAdminService instancePortService = get(InstancePortAdminService.class);
    OpenstackNetworkAdminService osNetService = get(OpenstackNetworkAdminService.class);
    Optional<InstancePort> srcInstance = instancePortService.instancePorts().stream().filter(port -> port.ipAddress().toString().equals(srcIp)).findAny();
    if (!srcInstance.isPresent()) {
        print(NO_ELEMENT);
        return;
    }
    OpenstackNode srcNode = osNodeService.node(srcInstance.get().deviceId());
    if (srcNode == null || srcNode.sshAuthInfo() == null) {
        log.error("Openstack node {} is null or has no SSH authentication information.\n" + " Please refers to the sample network-cfg.json in " + "OpenstackNode app to push SSH authentication information", srcNode == null ? "" : srcNode.hostname());
        return;
    }
    if (dstIp.equals(osNetService.gatewayIp(srcInstance.get().portId()))) {
        dstIp = srcIp;
    }
    // print uplink flow trace result
    String requestStringUplink = traceRequestString(srcIp, dstIp, srcInstance.get(), osNetService, true);
    print(FLOW_TRACE_REQUEST_STRING_UPLINK + requestStringUplink);
    String requestStringDownlink = traceRequestString(srcIp, dstIp, srcInstance.get(), osNetService, false);
    print(FLOW_TRACE_REQUEST_STRING_DOWNLINK + requestStringDownlink);
    String traceResult = sendTraceRequestToNode(requestStringUplink + '\n' + requestStringDownlink, srcNode);
    print(traceResult);
}
Also used : OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) Argument(org.apache.karaf.shell.api.action.Argument) OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService) AbstractShellCommand.get(org.onosproject.cli.AbstractShellCommand.get) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) InstancePortAdminService(org.onosproject.openstacknetworking.api.InstancePortAdminService) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Optional(java.util.Optional) Completion(org.apache.karaf.shell.api.action.Completion) OpenstackNetworkingUtil.traceRequestString(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.traceRequestString) OpenstackNetworkingUtil.sendTraceRequestToNode(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.sendTraceRequestToNode) OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService) InstancePortAdminService(org.onosproject.openstacknetworking.api.InstancePortAdminService) InstancePort(org.onosproject.openstacknetworking.api.InstancePort) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) OpenstackNetworkingUtil.traceRequestString(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.traceRequestString) OpenstackNetworkAdminService(org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService)

Example 4 with OpenstackNodeAdminService

use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.

the class OpenstackSyncRulesCommand method doExecute.

@Override
protected void doExecute() {
    // All handlers in this application reacts the node complete event and
    // tries to re-configure flow rules for the complete node.
    OpenstackNodeAdminService osNodeService = get(OpenstackNodeAdminService.class);
    if (osNodeService == null) {
        error("Failed to re-install flow rules for OpenStack networking.");
        return;
    }
    // we first initialize the COMPUTE node, in order to feed all instance ports
    // by referring to ports' information obtained from neutron server
    osNodeService.completeNodes(COMPUTE).forEach(osNode -> syncRulesBaseForNode(osNodeService, osNode));
    osNodeService.completeNodes(GATEWAY).forEach(osNode -> syncRulesBaseForNode(osNodeService, osNode));
    print("Successfully requested re-installing flow rules.");
}
Also used : OpenstackNodeAdminService(org.onosproject.openstacknode.api.OpenstackNodeAdminService)

Example 5 with OpenstackNodeAdminService

use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.

the class OpenstackNodeInitCommand method doExecute.

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

Aggregations

OpenstackNodeAdminService (org.onosproject.openstacknode.api.OpenstackNodeAdminService)5 OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)4 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)3 Optional (java.util.Optional)1 Argument (org.apache.karaf.shell.api.action.Argument)1 Command (org.apache.karaf.shell.api.action.Command)1 Completion (org.apache.karaf.shell.api.action.Completion)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)1 AbstractShellCommand.get (org.onosproject.cli.AbstractShellCommand.get)1 InstancePort (org.onosproject.openstacknetworking.api.InstancePort)1 InstancePortAdminService (org.onosproject.openstacknetworking.api.InstancePortAdminService)1 OpenstackNetworkAdminService (org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService)1 OpenstackNetworkingUtil.sendTraceRequestToNode (org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.sendTraceRequestToNode)1 OpenstackNetworkingUtil.traceRequestString (org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.traceRequestString)1