Skip to content

Commit 42e2344

Browse files
MaoJianweitomikazi
authored andcommitted
ONOS Network Troubleshooting System
Newest Commit changes: 1. Add unit tests. 2. Fix review comments. 3. Add support to BUCK. Could you please make a Code Review, we wish to hear anything from you :) Thank you very much! ---------------------------------------------------- ONOS Network Troubleshooting System Modularity design. In present, include these tow module: 1. Routing Loop Detection Welcome your contribution for more modules in the future... Beijing University of Posts and Telecommunications new: withdraw blackhole tracing for redesign; fix obvious checkstyle problem. Change-Id: Id6d3aa0bc00c8da8ac046e6903f17cfdf954d919
1 parent 0f4d63a commit 42e2344

File tree

30 files changed

+2531
-1
lines changed

30 files changed

+2531
-1
lines changed

apps/network-troubleshoot/BUCK

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BUNDLES = [
2+
'//apps/network-troubleshoot/api:onos-apps-network-troubleshoot-api',
3+
'//apps/network-troubleshoot/cli:onos-apps-network-troubleshoot-cli',
4+
'//apps/network-troubleshoot/core:onos-apps-network-troubleshoot-core',
5+
]
6+
7+
onos_app (
8+
title = 'Network TroubleShoot SubSystem',
9+
description = 'ONOS Network TroubleShoot SubSystem',
10+
category = 'Core',
11+
url = 'https://wiki.onosproject.org/display/ONOS/Network+TroubleShooting+Module',
12+
included_bundles = BUNDLES,
13+
)

apps/network-troubleshoot/api/BUCK

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
COMPILE_DEPS = [
2+
'//lib:CORE_DEPS',
3+
]
4+
5+
TEST_DEPS = [
6+
'//lib:TEST_ADAPTERS',
7+
]
8+
9+
osgi_jar_with_tests (
10+
deps = COMPILE_DEPS,
11+
test_deps = TEST_DEPS,
12+
)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2014-present Open Networking Laboratory
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<parent>
24+
<groupId>org.onosproject</groupId>
25+
<artifactId>onos-network-troubleshoot</artifactId>
26+
<version>1.10.0-SNAPSHOT</version>
27+
</parent>
28+
29+
<artifactId>onos-network-troubleshoot-api</artifactId>
30+
<packaging>bundle</packaging>
31+
32+
<description>ONOS Network TroubleShoot SubSystem API</description>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>junit</groupId>
37+
<artifactId>junit</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.onosproject</groupId>
41+
<artifactId>onlab-junit</artifactId>
42+
<scope>test</scope>
43+
</dependency>
44+
</dependencies>
45+
</project>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Copyright 2015-present Open Networking Laboratory
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.base;
17+
18+
import org.onosproject.net.ConnectPoint;
19+
import org.onosproject.net.DeviceId;
20+
import org.onosproject.net.HostId;
21+
import org.onosproject.net.flow.FlowEntry;
22+
import org.onosproject.net.flow.criteria.Criterion;
23+
24+
import java.util.ArrayList;
25+
import java.util.Collections;
26+
import java.util.List;
27+
import java.util.Set;
28+
29+
/**
30+
* Common utility functions and constants.
31+
*/
32+
public final class NetworkDiagnosticUtils {
33+
34+
private NetworkDiagnosticUtils() {
35+
// no instantiation
36+
}
37+
38+
/**
39+
* Returns a list of flow entries sorted by priority in descending order.
40+
*
41+
* @param flowEntries flow entries to be sorted
42+
* @return flow entries in descending order
43+
*/
44+
public static List<FlowEntry> sortFlowTable(Iterable<FlowEntry> flowEntries) {
45+
46+
List<FlowEntry> flows = new ArrayList<>();
47+
flowEntries.forEach(flows::add);
48+
49+
Collections.sort(flows,
50+
(f1, f2) -> f2.priority() - f1.priority());
51+
return flows;
52+
}
53+
54+
/**
55+
* Returns a list of match fields sorted by their types in ascending order.
56+
*
57+
* @param criterionSet the criteria to be sorted
58+
* @return the list of criteria in ascending order
59+
*/
60+
public static List<Criterion> sortCriteria(Set<Criterion> criterionSet) {
61+
62+
List<Criterion> array = new ArrayList<>(criterionSet);
63+
Collections.sort(array,
64+
(c1, c2) -> c1.type().compareTo(c2.type()));
65+
return array;
66+
}
67+
68+
/**
69+
* Returns true if the given connect point is a device point.
70+
*
71+
* @param connectPoint the connect point to be checked
72+
* @return true if the connect point is a device point
73+
*/
74+
public static boolean isDevice(ConnectPoint connectPoint) {
75+
return connectPoint.elementId() instanceof DeviceId;
76+
}
77+
78+
/**
79+
* Returns true if the given connect point is a host point.
80+
*
81+
* @param connectPoint the connect point to be checked
82+
* @return true if the connect point is a host point
83+
*/
84+
public static boolean isHost(ConnectPoint connectPoint) {
85+
// TODO - not debug yet
86+
return connectPoint.elementId() instanceof HostId;
87+
}
88+
}

0 commit comments

Comments
 (0)