maojianwei | 42e2344 | 2016-02-15 10:40:48 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2015-present Open Networking Foundation |
maojianwei | 42e2344 | 2016-02-15 10:40:48 +0800 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onosproject.fnl.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.commands.Command; |
| 19 | import org.onosproject.fnl.intf.NetworkDiagnostic; |
| 20 | import org.onosproject.fnl.intf.NetworkDiagnosticService; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.net.device.DeviceService; |
| 23 | import org.onosproject.net.flow.FlowRuleService; |
| 24 | import org.onosproject.net.host.HostService; |
| 25 | import 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.") |
| 35 | public 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 | } |