[AETHER-76] Complete T3 offline mode
- For the performance improvement, T3 offline mode uses snapshots of the network states
called Network Information Base (NIB) instead of runtime interactions with ONOS core
during troubleshooting a Trellis system.
- Enables NIB to be manually filled with the followings via T3-load commands.
- Static dump files of onos-diagnostics (t3-load-file).
- Returns of API calls to live ONOS stores (t3-load-snapshot).
- Enables NIB to be auto-filled with live ONOS stores.
- When T3-execution commands (e.g. pingall) found NIB is invalid.
- Partially tested with some mininet topos for Trellis
(https://github.com/opennetworkinglab/routing/tree/master/trellis).
- Usage instruction docs (https://docs.trellisfabric.org/troubleshooting.html).
Change-Id: I2bb546bdde454a034338cd896388fa0b37d868be
(cherry picked from commit c3803e7fad5fb28ecf3e83253f183a34936be4a0)
diff --git a/app/src/main/java/org/onosproject/t3/api/AbstractNib.java b/app/src/main/java/org/onosproject/t3/api/AbstractNib.java
new file mode 100644
index 0000000..652c974
--- /dev/null
+++ b/app/src/main/java/org/onosproject/t3/api/AbstractNib.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.t3.api;
+
+/**
+ * Base abstraction of Network Information Base (NIB).
+ */
+public abstract class AbstractNib {
+
+ protected NibProfile nibProfile;
+
+ /**
+ * Sets a profile describing this NIB.
+ *
+ * @param nibProfile NIB profile
+ */
+ public void setProfile(NibProfile nibProfile) {
+ this.nibProfile = nibProfile;
+ }
+
+ /**
+ * Returns the current profile of this NIB.
+ *
+ * @return NIB profile
+ */
+ public NibProfile getProfile() {
+ return nibProfile;
+ }
+
+ /**
+ * Checks this NIB is valid.
+ *
+ * @return true (valid) only if this NIB is already filled with any source. false means invalid
+ */
+ public boolean isValid() {
+ if (nibProfile != null) {
+ return nibProfile.isValid();
+ } else {
+ return false;
+ }
+ }
+
+}
diff --git a/app/src/main/java/org/onosproject/t3/api/DeviceNib.java b/app/src/main/java/org/onosproject/t3/api/DeviceNib.java
index 618724a..aca8418 100644
--- a/app/src/main/java/org/onosproject/t3/api/DeviceNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/DeviceNib.java
@@ -32,7 +32,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.device.DeviceService} for offline data.
*/
-public class DeviceNib {
+public class DeviceNib extends AbstractNib {
private Map<Device, Set<Port>> devicePortMap;
diff --git a/app/src/main/java/org/onosproject/t3/api/DriverNib.java b/app/src/main/java/org/onosproject/t3/api/DriverNib.java
index 4c88a20..edee901 100644
--- a/app/src/main/java/org/onosproject/t3/api/DriverNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/DriverNib.java
@@ -26,7 +26,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.driver.DriverService} for offline data.
*/
-public class DriverNib {
+public class DriverNib extends AbstractNib {
private Map<DeviceId, String> deviceDriverMap;
diff --git a/app/src/main/java/org/onosproject/t3/api/EdgePortNib.java b/app/src/main/java/org/onosproject/t3/api/EdgePortNib.java
index f24668f..060f9c4 100644
--- a/app/src/main/java/org/onosproject/t3/api/EdgePortNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/EdgePortNib.java
@@ -28,7 +28,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.edge.EdgePortService} for offline data.
*/
-public class EdgePortNib {
+public class EdgePortNib extends AbstractNib {
private Map<DeviceId, Set<ConnectPoint>> edgePorts;
diff --git a/app/src/main/java/org/onosproject/t3/api/FlowNib.java b/app/src/main/java/org/onosproject/t3/api/FlowNib.java
index aecb57c..b9f2226 100644
--- a/app/src/main/java/org/onosproject/t3/api/FlowNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/FlowNib.java
@@ -28,7 +28,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.flow.FlowRuleService} for offline data.
*/
-public class FlowNib {
+public class FlowNib extends AbstractNib {
// TODO with method optimization, store into subdivided structures at the first load
private Set<FlowEntry> flows;
diff --git a/app/src/main/java/org/onosproject/t3/api/GroupNib.java b/app/src/main/java/org/onosproject/t3/api/GroupNib.java
index 64d6575..b1fb563 100644
--- a/app/src/main/java/org/onosproject/t3/api/GroupNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/GroupNib.java
@@ -28,7 +28,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.group.GroupService} for offline data.
*/
-public class GroupNib {
+public class GroupNib extends AbstractNib {
// TODO with method optimization, store into subdivided structures at the first load
private Set<Group> groups;
diff --git a/app/src/main/java/org/onosproject/t3/api/HostNib.java b/app/src/main/java/org/onosproject/t3/api/HostNib.java
index 5b5eab2..2ba68d1 100644
--- a/app/src/main/java/org/onosproject/t3/api/HostNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/HostNib.java
@@ -31,7 +31,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.host.HostService} for offline data.
*/
-public class HostNib {
+public class HostNib extends AbstractNib {
// TODO with method optimization, store into subdivided structures at the first load
private Set<Host> hosts;
diff --git a/app/src/main/java/org/onosproject/t3/api/LinkNib.java b/app/src/main/java/org/onosproject/t3/api/LinkNib.java
index 02acb54..622a187 100644
--- a/app/src/main/java/org/onosproject/t3/api/LinkNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/LinkNib.java
@@ -28,7 +28,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.link.LinkService} for offline data.
*/
-public class LinkNib {
+public class LinkNib extends AbstractNib {
// TODO with method optimization, store into subdivided structures at the first load
private Set<Link> links;
diff --git a/app/src/main/java/org/onosproject/t3/api/MastershipNib.java b/app/src/main/java/org/onosproject/t3/api/MastershipNib.java
index 5101d52..733c590 100644
--- a/app/src/main/java/org/onosproject/t3/api/MastershipNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/MastershipNib.java
@@ -27,7 +27,7 @@
* and supports alternative functions to
* {@link org.onosproject.mastership.MastershipService} for offline data.
*/
-public class MastershipNib {
+public class MastershipNib extends AbstractNib {
private Map<DeviceId, NodeId> deviceMasterMap;
diff --git a/app/src/main/java/org/onosproject/t3/api/MulticastRouteNib.java b/app/src/main/java/org/onosproject/t3/api/MulticastRouteNib.java
index b9d106d..0bcdc1f 100644
--- a/app/src/main/java/org/onosproject/t3/api/MulticastRouteNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/MulticastRouteNib.java
@@ -29,7 +29,7 @@
* and supports alternative functions to
* {@link org.onosproject.mcast.api.MulticastRouteService} for offline data.
*/
-public class MulticastRouteNib {
+public class MulticastRouteNib extends AbstractNib {
private Map<McastRoute, McastRouteData> mcastRoutes;
diff --git a/app/src/main/java/org/onosproject/t3/api/NetworkConfigNib.java b/app/src/main/java/org/onosproject/t3/api/NetworkConfigNib.java
index 9624fb7..f3de961 100644
--- a/app/src/main/java/org/onosproject/t3/api/NetworkConfigNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/NetworkConfigNib.java
@@ -31,7 +31,7 @@
* and supports alternative functions to
* {@link org.onosproject.net.config.NetworkConfigService} for offline data.
*/
-public class NetworkConfigNib {
+public class NetworkConfigNib extends AbstractNib {
private static final Logger log = getLogger(NetworkConfigNib.class);
diff --git a/app/src/main/java/org/onosproject/t3/api/NibProfile.java b/app/src/main/java/org/onosproject/t3/api/NibProfile.java
new file mode 100644
index 0000000..146d98a
--- /dev/null
+++ b/app/src/main/java/org/onosproject/t3/api/NibProfile.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.t3.api;
+
+import java.text.SimpleDateFormat;
+
+/**
+ * Basic descriptions about a single Network information Base (NIB) instance.
+ */
+public class NibProfile {
+ // default false means the contents of this NIB are empty at the instantiation
+ private boolean valid = false;
+ private String date;
+ private SourceType sourceType;
+
+ public enum SourceType {
+ /**
+ * Provided by dump files.
+ */
+ FILE,
+ /**
+ * Provided by a running system.
+ */
+ SNAPSHOT
+ }
+
+ public NibProfile(long date, SourceType sourceType) {
+ this.valid = true;
+ this.date = new SimpleDateFormat("dd-MM-yyyy hh:mm").format(date);
+ this.sourceType = sourceType;
+ }
+
+ /**
+ * Returns the validity state of this NIB.
+ *
+ * @return true once this profile is initialized
+ */
+ public boolean isValid() {
+ return valid;
+ }
+
+ /**
+ * Returns the time this NIB has been filled.
+ *
+ * @return string representation for the time
+ */
+ public String date() {
+ return date;
+ }
+
+ /**
+ * Returns the type of the source used to fill this NIB.
+ *
+ * @return source type
+ */
+ public SourceType sourceType() {
+ return sourceType;
+ }
+
+}
diff --git a/app/src/main/java/org/onosproject/t3/api/RouteNib.java b/app/src/main/java/org/onosproject/t3/api/RouteNib.java
index 3edabd3..01e6e61 100644
--- a/app/src/main/java/org/onosproject/t3/api/RouteNib.java
+++ b/app/src/main/java/org/onosproject/t3/api/RouteNib.java
@@ -32,7 +32,7 @@
* and supports alternative functions to
* {@link org.onosproject.routeservice.RouteService} for offline data.
*/
-public class RouteNib {
+public class RouteNib extends AbstractNib {
// TODO with method optimization, store into subdivided structures at the first load
// unresolved Route is treated as ResolvedRoute with nextHopMac null
diff --git a/app/src/main/java/org/onosproject/t3/api/TroubleshootService.java b/app/src/main/java/org/onosproject/t3/api/TroubleshootService.java
index 9838e04..3ab6052 100644
--- a/app/src/main/java/org/onosproject/t3/api/TroubleshootService.java
+++ b/app/src/main/java/org/onosproject/t3/api/TroubleshootService.java
@@ -36,7 +36,7 @@
* Requests a static trace be performed between all hosts in the network, given a type of traffic.
*
* @param type the etherType of the traffic we want to trace.
- * @return a trace result
+ * @return trace result
*/
List<StaticPacketTrace> pingAll(EthType.EtherType type);
@@ -44,7 +44,7 @@
* Requests a static trace be performed between all hosts in the network, given a type of traffic.
*
* @param type the etherType of the traffic we want to trace.
- * @return a trace result
+ * @return trace result
*/
Generator<Set<StaticPacketTrace>> pingAllGenerator(EthType.EtherType type);
@@ -52,7 +52,7 @@
* Requests a static trace be performed for all mcast Routes in the network.
*
* @param vlanId the vlanId configured for multicast.
- * @return a set of trace result yielded one by one.
+ * @return set of trace result yielded one by one.
*/
Generator<Set<StaticPacketTrace>> traceMcast(VlanId vlanId);
@@ -62,7 +62,7 @@
* @param sourceHost source host
* @param destinationHost destination host
* @param type the etherType of the traffic we want to trace.
- * @return a trace result
+ * @return trace result
*/
Set<StaticPacketTrace> trace(HostId sourceHost, HostId destinationHost, EthType.EtherType type);
@@ -72,7 +72,7 @@
*
* @param packet description of packet
* @param in point at which packet starts
- * @return a trace result
+ * @return trace result
*/
StaticPacketTrace trace(TrafficSelector packet, ConnectPoint in);
@@ -80,20 +80,22 @@
* Requests list of static trace to be performed for all mcast routes in the network.
*
* @param vlanId the vlan id configured for multicast
- * @return a list of trace result
+ * @return list of trace result
*/
List<Set<StaticPacketTrace>> getMulitcastTrace(VlanId vlanId);
/**
- * Checks the availability of all NIBs of the manager.
+ * Checks the validity of NIBs applied to the manager.
*
- * @return true if any NIB objects is unavailable
+ * @return true only if all NIBs are in the valid state.
*/
- boolean checkNibsUnavailable();
+ boolean checkNibValidity();
/**
- * Applies created NIBs to the manager.
+ * Returns a summary describing all the NIBs applied to the manager.
+ *
+ * @return string for the summary
*/
- void applyNibs();
+ String printNibSummary();
}