blob: f2ac8f62b3436b513bac07b7cc59fd8f281d4a79 [file] [log] [blame]
maojianwei42e23442016-02-15 10:40:48 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
maojianwei42e23442016-02-15 10:40:48 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.fnl.cli;
17
Ray Milkey86ad7bb2018-09-27 12:32:28 -070018import org.apache.karaf.shell.api.action.Command;
Ray Milkey7a2dee52018-09-28 10:58:28 -070019import org.apache.karaf.shell.api.action.lifecycle.Service;
maojianwei42e23442016-02-15 10:40:48 +080020import org.onosproject.fnl.intf.NetworkDiagnostic;
21import org.onosproject.fnl.intf.NetworkDiagnosticService;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.device.DeviceService;
24import org.onosproject.net.flow.FlowRuleService;
25import org.onosproject.net.host.HostService;
26import org.onosproject.net.link.LinkService;
27
28/**
29 * Search for all potential routing loops.
30 */
Ray Milkey7a2dee52018-09-28 10:58:28 -070031@Service
maojianwei42e23442016-02-15 10:40:48 +080032@Command(scope = "onos",
33 name = "ts-check-loops",
34 description = "Check if there are some routing loops in the network",
35 detailedDescription = "Report the header of loop-trigger packet, " +
36 "DevicesIds and FlowEntries.")
37public class TsCheckLoop extends AbstractShellCommand {
38
39 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070040 protected void doExecute() {
maojianwei42e23442016-02-15 10:40:48 +080041 NetworkDiagnosticService service = getService(NetworkDiagnosticService.class);
42
43 DeviceService ds = getService(DeviceService.class);
44 HostService hs = getService(HostService.class);
45 FlowRuleService frs = getService(FlowRuleService.class);
46 LinkService ls = getService(LinkService.class);
47
48 service.findAnomalies(NetworkDiagnostic.Type.LOOP)
49 .forEach(loop -> print(loop.toString()));
50 }
51}