blob: c38a79cbf22f686084644ed2b0e10c0ad28c4a72 [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
18import org.apache.karaf.shell.commands.Command;
19import org.onosproject.fnl.intf.NetworkDiagnostic;
20import org.onosproject.fnl.intf.NetworkDiagnosticService;
21import org.onosproject.cli.AbstractShellCommand;
22import org.onosproject.net.device.DeviceService;
23import org.onosproject.net.flow.FlowRuleService;
24import org.onosproject.net.host.HostService;
25import org.onosproject.net.link.LinkService;
26
27/**
28 * Search for all potential routing loops.
29 */
30@Command(scope = "onos",
31 name = "ts-check-loops",
32 description = "Check if there are some routing loops in the network",
33 detailedDescription = "Report the header of loop-trigger packet, " +
34 "DevicesIds and FlowEntries.")
35public class TsCheckLoop extends AbstractShellCommand {
36
37 @Override
38 protected void execute() {
39 NetworkDiagnosticService service = getService(NetworkDiagnosticService.class);
40
41 DeviceService ds = getService(DeviceService.class);
42 HostService hs = getService(HostService.class);
43 FlowRuleService frs = getService(FlowRuleService.class);
44 LinkService ls = getService(LinkService.class);
45
46 service.findAnomalies(NetworkDiagnostic.Type.LOOP)
47 .forEach(loop -> print(loop.toString()));
48 }
49}