Bgp and Pcep maintaiability
Change-Id: I2c14cc29d4900ef2f0fbffd4761b0d78e282910f
diff --git a/providers/bgp/BUCK b/providers/bgp/BUCK
index 403bcbe..b5f516e 100644
--- a/providers/bgp/BUCK
+++ b/providers/bgp/BUCK
@@ -1,6 +1,7 @@
BUNDLES = [
'//providers/bgp/cfg:onos-providers-bgp-cfg',
'//providers/bgp/topology:onos-providers-bgp-topology',
+ '//providers/bgp/cli:onos-providers-bgp-cli',
'//protocols/bgp/api:onos-protocols-bgp-api',
'//protocols/bgp/ctl:onos-protocols-bgp-ctl',
'//protocols/bgp/bgpio:onos-protocols-bgp-bgpio',
diff --git a/providers/bgp/app/app.xml b/providers/bgp/app/app.xml
index ddf438a..e7b1ac1 100755
--- a/providers/bgp/app/app.xml
+++ b/providers/bgp/app/app.xml
@@ -25,6 +25,7 @@
<artifact>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-bgp-provider-cli/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcepio/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
diff --git a/providers/bgp/app/features.xml b/providers/bgp/app/features.xml
index 3bace0e..d50537a 100755
--- a/providers/bgp/app/features.xml
+++ b/providers/bgp/app/features.xml
@@ -23,6 +23,7 @@
<bundle>mvn:${project.groupId}/onos-bgp-ctl/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-controller-api/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-topology/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-bgp-provider-cli/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-bgp-provider-cfg/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcepio/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-pcep-api/${project.version}</bundle>
diff --git a/providers/bgp/app/pom.xml b/providers/bgp/app/pom.xml
index 7e93df3..b9605e2 100755
--- a/providers/bgp/app/pom.xml
+++ b/providers/bgp/app/pom.xml
@@ -46,6 +46,11 @@
<artifactId>onos-bgp-provider-topology</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-bgp-provider-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-app-pce</artifactId>
diff --git a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
index f185f65..504930d 100644
--- a/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
+++ b/providers/bgp/cfg/src/main/java/org/onosproject/provider/bgp/cfg/impl/BgpAppConfig.java
@@ -24,6 +24,8 @@
import org.onosproject.bgp.controller.BgpController;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.config.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
@@ -41,6 +43,7 @@
BgpCfg bgpConfig = null;
+ protected final Logger log = LoggerFactory.getLogger(BgpAppConfig.class);
public static final String ROUTER_ID = "routerId";
public static final String LOCAL_AS = "localAs";
public static final String MAX_SESSION = "maxSession";
@@ -170,10 +173,11 @@
if (flowSpecCapability() != null) {
String flowSpec = flowSpecCapability();
if ((!flowSpec.equals("IPV4")) && (!flowSpec.equals("VPNV4")) && (!flowSpec.equals("IPV4_VPNV4"))) {
+ log.debug("Flow specification capabality is false");
return false;
}
}
-
+ log.debug("Flow specification capabality is true");
return true;
}
@@ -303,10 +307,11 @@
!validateRemoteAs(nodes.get(i).asNumber()) ||
!validatePeerHoldTime(nodes.get(i).holdTime()) ||
!(connectMode.equals(PEER_CONNECT_ACTIVE) || connectMode.equals(PEER_CONNECT_PASSIVE))) {
+ log.debug("BGP peer configration false");
return false;
}
}
-
+ log.debug("BGP peer configration true");
return true;
}
@@ -317,7 +322,6 @@
*/
public List<BgpPeerConfig> bgpPeer() {
List<BgpPeerConfig> nodes = new ArrayList<BgpPeerConfig>();
-
JsonNode jsonNodes = object.get(BGP_PEER);
if (jsonNodes == null) {
return null;
diff --git a/providers/bgp/cli/BUCK b/providers/bgp/cli/BUCK
new file mode 100644
index 0000000..64ae7f9
--- /dev/null
+++ b/providers/bgp/cli/BUCK
@@ -0,0 +1,16 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//incubator/api:onos-incubator-api',
+ '//providers/bgp/cfg:onos-providers-bgp-cfg',
+ '//providers/bgp/topology:onos-providers-bgp-topology',
+ '//protocols/bgp/api:onos-protocols-bgp-api',
+ '//protocols/bgp/ctl:onos-protocols-bgp-ctl',
+ '//protocols/bgp/bgpio:onos-protocols-bgp-bgpio',
+ '//lib:org.apache.karaf.shell.console',
+ '//cli:onos-cli',
+]
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+)
+
diff --git a/providers/bgp/cli/pom.xml b/providers/bgp/cli/pom.xml
new file mode 100644
index 0000000..76b92b7
--- /dev/null
+++ b/providers/bgp/cli/pom.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016-present Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-bgp-providers</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-bgp-provider-cli</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>BGP cli implementation</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-bgp-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-bgp-provider-cfg</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-bgp-ctl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+<build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.onosproject.bgp.*</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+</plugins>
+</build>
+</project>
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
new file mode 100644
index 0000000..d34c80e
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpConfiguration.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.bgp.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.bgp.controller.BgpCfg;
+import org.onosproject.bgp.controller.BgpConnectPeer;
+import org.onosproject.bgp.controller.BgpController;
+import org.onosproject.bgp.controller.BgpPeerCfg;
+import org.onosproject.cli.AbstractShellCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+import java.util.TreeMap;
+
+
+@Command(scope = "onos", name = "bgp", description = "lists configuration")
+public class BgpConfiguration extends AbstractShellCommand {
+ private static final Logger log = LoggerFactory.getLogger(BgpConfiguration.class);
+ private static final String CONFIGURATION = "configuration";
+ private static final String PEER = "peer";
+ protected BgpController bgpController;
+ protected BgpConnectPeer bgpConnectPeer;
+ protected BgpPeerCfg bgpPeerCfg;
+ protected BgpCfg bgpCfg;
+ @Argument(index = 0, name = "name",
+ description = "configuration" + "\n" + "peer",
+ required = true, multiValued = false)
+ String name = null;
+ @Argument(index = 1, name = "peer",
+ description = "peerIp",
+ required = false, multiValued = false)
+ String peer = null;
+
+ @Override
+ protected void execute() {
+ switch (name) {
+ case CONFIGURATION:
+ displayBgpConfiguration();
+ break;
+ case PEER:
+ displayBgpPeerConfiguration();
+ break;
+ default:
+ System.out.print("Unknown command...!!");
+ break;
+ }
+ }
+
+ private void displayBgpConfiguration() {
+ try {
+
+ this.bgpController = get(BgpController.class);
+ bgpCfg = bgpController.getConfig();
+ print("RouterID = %s, ASNumber = %s, MaxSession = %s, HoldingTime = %s, LsCapabality = %s," +
+ " LargeAsCapabality = %s, FlowSpecCapabality = %s", bgpCfg.getRouterId(),
+ bgpCfg.getAsNumber(), bgpCfg.getMaxSession(), bgpCfg.getHoldTime(),
+ bgpCfg.getLsCapability(), bgpCfg.getLargeASCapability(), bgpCfg.flowSpecCapability());
+
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP configuration: {}", e.getMessage());
+ }
+ }
+
+ private void displayBgpPeerConfiguration() {
+ try {
+ this.bgpController = get(BgpController.class);
+ BgpCfg bgpCfg = bgpController.getConfig();
+ if (bgpCfg == null) {
+ return;
+ }
+ TreeMap<String, BgpPeerCfg> displayPeerTree = bgpCfg.getPeerTree();
+ Set<String> peerKey = displayPeerTree.keySet();
+ if (peer != null) {
+ if (peerKey.size() > 0) {
+ for (String peerIdKey : peerKey) {
+ bgpPeerCfg = displayPeerTree.get(peerIdKey);
+ bgpConnectPeer = bgpPeerCfg.connectPeer();
+ if (peerIdKey.equals(peer)) {
+ print("PeerRouterID = %s, PeerHoldingTime = %s, ASNumber = %s, PeerState = %s," +
+ " PeerPort = %s, ConnectRetryCounter = %s",
+ peer, bgpPeerCfg.getHoldtime(), bgpPeerCfg.getAsNumber(),
+ bgpPeerCfg.getState(), bgpConnectPeer.getPeerPort(),
+ bgpConnectPeer.getConnectRetryCounter());
+ }
+ }
+ }
+ } else {
+ if (peerKey.size() > 0) {
+ for (String peerIdKey : peerKey) {
+ bgpPeerCfg = displayPeerTree.get(peerIdKey);
+ bgpConnectPeer = bgpPeerCfg.connectPeer();
+ print("PeerRouterID = %s, PeerHoldingTime = %s, ASNumber = %s, PeerState = %s, PeerPort = %s," +
+ " ConnectRetryCounter = %s",
+ bgpPeerCfg.getPeerRouterId(), bgpPeerCfg.getHoldtime(), bgpPeerCfg.getAsNumber(),
+ bgpPeerCfg.getState(), bgpConnectPeer.getPeerPort(),
+ bgpConnectPeer.getConnectRetryCounter());
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP peer configuration: {}", e.getMessage());
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
new file mode 100644
index 0000000..2f129ba
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpExceptions.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.bgp.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.bgp.controller.BgpController;
+import org.onosproject.cli.AbstractShellCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+@Command(scope = "onos", name = "bgp-exception", description = "Displays Exceptions")
+public class BgpExceptions extends AbstractShellCommand {
+ public static final String ACTIVESESSION = "activesession";
+ public static final String CLOSEDSESSION = "closedsession";
+ private static final Logger log = LoggerFactory.getLogger(BgpExceptions.class);
+ protected BgpController bgpController;
+ @Argument(index = 0, name = "name",
+ description = "activesession" + "\n" + "closedsession",
+ required = true, multiValued = false)
+ String name = null;
+ @Argument(index = 1, name = "peerIp",
+ description = "peerId",
+ required = false, multiValued = false)
+ String peerId = null;
+ private Set<String> activeSessionExceptionkeySet;
+ private Set<String> closedSessionExceptionKeySet;
+
+ @Override
+ protected void execute() {
+ switch (name) {
+ case ACTIVESESSION:
+ displayActiveSessionException();
+ break;
+ case CLOSEDSESSION:
+ displayClosedSessionException();
+ break;
+ default:
+ System.out.print("Unknown Command");
+ break;
+ }
+ }
+
+ private void displayActiveSessionException() {
+ try {
+ this.bgpController = get(BgpController.class);
+ Map<String, List<String>> activeSessionExceptionMap = bgpController.activeSessionMap();
+ activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
+ if (activeSessionExceptionkeySet.size() > 0) {
+ if (peerId != null) {
+ if (activeSessionExceptionkeySet.contains(peerId)) {
+ for (String peerIdKey : activeSessionExceptionkeySet) {
+ List activeSessionExceptionlist = activeSessionExceptionMap.get(peerIdKey);
+ System.out.println(activeSessionExceptionlist);
+ }
+ } else {
+ System.out.print("Wrong argument");
+ }
+ } else {
+ activeSessionExceptionkeySet = activeSessionExceptionMap.keySet();
+ if (activeSessionExceptionkeySet.size() > 0) {
+ for (String peerId : activeSessionExceptionkeySet) {
+ print("PeerId = %s, Exception = %s ", peerId, activeSessionExceptionMap.get(peerId));
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP exceptions: {}", e.getMessage());
+ }
+ }
+
+ private void displayClosedSessionException() {
+ try {
+ this.bgpController = get(BgpController.class);
+ Map<String, List<String>> closedSessionExceptionMap = bgpController.closedSessionMap();
+ closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
+ if (closedSessionExceptionKeySet.size() > 0) {
+ if (peerId != null) {
+ if (closedSessionExceptionKeySet.contains(peerId)) {
+ for (String peerIdKey : closedSessionExceptionKeySet) {
+ List closedSessionExceptionlist = closedSessionExceptionMap.get(peerIdKey);
+ print("Exceptions = %s", closedSessionExceptionlist);
+ }
+ } else {
+ System.out.print("Wrong argument");
+ }
+ } else {
+ closedSessionExceptionKeySet = closedSessionExceptionMap.keySet();
+ if (closedSessionExceptionKeySet.size() > 0) {
+ for (String peerId : closedSessionExceptionKeySet) {
+ print("PeerId = %s, Exception = %s", peerId, closedSessionExceptionMap.get(peerId));
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying resons for session closure: {}", e.getMessage());
+ }
+ }
+
+
+}
+
+
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java
new file mode 100644
index 0000000..3e5fb68
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/BgpLocalRibDisplay.java
@@ -0,0 +1,406 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.bgp.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.bgp.controller.BgpController;
+import org.onosproject.bgp.controller.BgpLocalRib;
+import org.onosproject.bgpio.protocol.BgpLSNlri;
+
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails;
+import org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib;
+import org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier;
+import org.onosproject.bgpio.protocol.linkstate.NodeDescriptors;
+import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
+import org.onosproject.bgpio.types.IPv4AddressTlv;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.types.LinkStateAttributes;
+import org.onosproject.bgpio.types.MpReachNlri;
+import org.onosproject.bgpio.types.AutonomousSystemTlv;
+import org.onosproject.bgpio.types.IsIsNonPseudonode;
+import org.onosproject.bgpio.types.LocalPref;
+import org.onosproject.bgpio.types.Origin;
+import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV4;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrMaxLinkBandwidth;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrUnRsrvdLinkBandwidth;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrTeDefaultMetric;
+import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric;
+import org.onosproject.cli.AbstractShellCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Arrays;
+
+
+
+@Command(scope = "onos", name = "bgp-rib", description = "lists RIB configuration")
+public class BgpLocalRibDisplay extends AbstractShellCommand {
+ private static final Logger log = LoggerFactory.getLogger(BgpLocalRibDisplay.class);
+ private static final String NODETREE = "nodes";
+ private static final String LINKTREE = "links";
+ private static final String PREFIXTREE = "prefix";
+ private static final String VPNNODETREE = "vpnnodes";
+ private static final String VPNLINKTREE = "vpnlinkS";
+ private static final String VPNPREFIXTREE = "vpnprefix";
+ protected Origin origin;
+ protected LocalPref localPref;
+ protected BgpAttrRouterIdV4 bgpAttrRouterIdV4;
+ protected IsIsNonPseudonode isIsNonPseudonode;
+ protected AutonomousSystemTlv autonomousSystemTlv;
+ protected IPv4AddressTlv iPv4AddressTlv;
+ protected BgpLinkAttrMaxLinkBandwidth bgpLinkAttrMaxLinkBandwidth;
+ protected BgpLinkAttrUnRsrvdLinkBandwidth bgpLinkAttrUnRsrvdLinkBandwidth;
+ protected BgpLinkAttrTeDefaultMetric bgpLinkAttrTeDefaultMetric;
+ protected BgpLinkAttrIgpMetric bgpLinkAttrIgpMetric;
+ protected PathAttrNlriDetailsLocalRib pathAttrNlriDetailsLocalRib;
+ protected MpReachNlri mpReachNlri;
+ protected PathAttrNlriDetails pathAttrNlriDetails;
+ protected BgpNodeLSNlriVer4.ProtocolType protocolType;
+ protected BgpController bgpController = get(BgpController.class);
+ protected BgpLocalRib bgpLocalRib = bgpController.bgpLocalRib();
+ Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> nodeTreeMap = bgpLocalRib.nodeTree();
+ Set<BgpNodeLSIdentifier> nodekeySet = nodeTreeMap.keySet();
+ Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib> linkTreeMap = bgpLocalRib.linkTree();
+ Set<BgpLinkLSIdentifier> linkkeySet = linkTreeMap.keySet();
+ @Argument(index = 0, name = "name",
+ description = "nodetree" + "\n" + "linktree" + "\n" + "prefixtree" + "\n" + "vpnnodetree" + "\n" +
+ "vpnlinktree" + "\n" + "vpnprefixtree", required = true, multiValued = false)
+ String name = null;
+ @Argument(index = 1, name = "numberofentries",
+ description = "numberofentries", required = false, multiValued = false)
+ int numberofentries;
+ @Argument(index = 2, name = "vpnId",
+ description = "vpnId", required = false, multiValued = false)
+ String vpnId = null;
+ private int count = 0;
+
+ @Override
+ protected void execute() {
+ switch (name) {
+ case NODETREE:
+ displayNodes();
+ break;
+ case LINKTREE:
+ displayLinks();
+ break;
+ case PREFIXTREE:
+ displayPrefix();
+ break;
+ case VPNNODETREE:
+ displayVpnNodes();
+ break;
+ case VPNLINKTREE:
+ displayVpnLinks();
+ break;
+ case VPNPREFIXTREE:
+ displayVpnPrefix();
+ break;
+ default:
+ System.out.print("Unknown Command");
+ break;
+ }
+
+ }
+
+ private void displayNodes() {
+ try {
+ int counter = 0;
+ print("Total number of entries = %s", nodeTreeMap.size());
+ for (BgpNodeLSIdentifier nodes : nodekeySet) {
+ if (numberofentries > nodeTreeMap.size() || numberofentries < 0) {
+ System.out.print("Wrong Argument");
+ break;
+ } else if (counter < numberofentries) {
+ pathAttrNlriDetailsLocalRib = nodeTreeMap.get(nodes);
+ displayNode();
+ counter++;
+ } else if (counter == 0) {
+ pathAttrNlriDetailsLocalRib = nodeTreeMap.get(nodes);
+ displayNode();
+
+
+ }
+
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP nodes: {}", e.getMessage());
+ }
+
+ }
+
+
+ private void displayLinks() {
+ try {
+ int counter = 0;
+ print("Total Number of entries = %d", linkTreeMap.size());
+ for (BgpLinkLSIdentifier links : linkkeySet) {
+ if (numberofentries > linkTreeMap.size() || numberofentries < 0) {
+ System.out.print("Wrong Argument");
+ break;
+ } else if (counter < numberofentries) {
+ pathAttrNlriDetailsLocalRib = linkTreeMap.get(links);
+ print("Total number of entries = %d", linkTreeMap.size());
+ displayLink();
+ counter++;
+ } else if (counter == 0) {
+ pathAttrNlriDetailsLocalRib = linkTreeMap.get(links);
+ displayLink();
+ }
+
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP links: {}", e.getMessage());
+ }
+ }
+
+ private void displayPrefix() {
+ try {
+ this.bgpController = get(BgpController.class);
+ bgpLocalRib = bgpController.bgpLocalRib();
+ Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib> prefixmap = bgpLocalRib.prefixTree();
+ Set<BgpPrefixLSIdentifier> prefixkeySet = prefixmap.keySet();
+ for (BgpPrefixLSIdentifier prefix : prefixkeySet) {
+ pathAttrNlriDetailsLocalRib = prefixmap.get(prefix);
+ pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
+ print("No of entries = %d", prefixmap.size());
+ System.out.print(pathAttrNlriDetailsLocalRib.toString());
+
+ }
+
+
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP prefixes: {}", e.getMessage());
+
+ }
+ }
+
+ private void displayVpnNodes() {
+ try {
+ this.bgpController = get(BgpController.class);
+ bgpLocalRib = bgpController.bgpLocalRib();
+ Map<RouteDistinguisher, Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnNode =
+ bgpLocalRib.vpnNodeTree();
+ Set<RouteDistinguisher> vpnNodekeySet = vpnNode.keySet();
+ for (RouteDistinguisher vpnNodes : vpnNodekeySet) {
+ boolean invalidProcess = true;
+ if (vpnId != null && vpnId.trim().equals(vpnNodes.hashCode())) {
+ invalidProcess = false;
+ displayNodes();
+ }
+ if (invalidProcess) {
+ print("%s\n", "Id " + vpnId + "does not exist...!!!");
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP nodes based on VPN : {}", e.getMessage());
+ }
+
+ }
+
+ private void displayVpnLinks() {
+ try {
+ this.bgpController = get(BgpController.class);
+ bgpLocalRib = bgpController.bgpLocalRib();
+ Map<RouteDistinguisher, Map<BgpLinkLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnLink =
+ bgpLocalRib.vpnLinkTree();
+ Set<RouteDistinguisher> vpnLinkkeySet = vpnLink.keySet();
+ for (RouteDistinguisher vpnLinks : vpnLinkkeySet) {
+ boolean invalidProcess = true;
+ if (vpnId != null && vpnId.trim().equals(vpnLinks.hashCode())) {
+ invalidProcess = false;
+ displayLinks();
+ }
+ if (invalidProcess) {
+ print("%s\n", "Id " + vpnId + "does not exist...!!!");
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP links based on VPN : {}", e.getMessage());
+ }
+ }
+
+ private void displayVpnPrefix() {
+ try {
+ this.bgpController = get(BgpController.class);
+ bgpLocalRib = bgpController.bgpLocalRib();
+ Map<RouteDistinguisher, Map<BgpPrefixLSIdentifier, PathAttrNlriDetailsLocalRib>> vpnPrefix =
+ bgpLocalRib.vpnPrefixTree();
+ Set<RouteDistinguisher> vpnPrefixkeySet = vpnPrefix.keySet();
+ for (RouteDistinguisher vpnprefixId : vpnPrefixkeySet) {
+ boolean invalidProcess = true;
+ if (vpnId != null && vpnId.trim().equals(vpnprefixId.hashCode())) {
+ invalidProcess = false;
+ displayPrefix();
+ }
+ if (invalidProcess) {
+ print("%s\n", "Id " + vpnId + "does not exist...!!!");
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying BGP prefixes based on VPN : {}", e.getMessage());
+ }
+ }
+
+ private void displayNode() {
+
+
+ pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
+ List<BgpValueType> bgpValueTypeList = pathAttrNlriDetails.pathAttributes();
+ protocolType = pathAttrNlriDetails.protocolID();
+ Iterator<BgpValueType> itrBgpValueType = bgpValueTypeList.iterator();
+ while (itrBgpValueType.hasNext()) {
+ BgpValueType bgpValueType = itrBgpValueType.next();
+ if (bgpValueType instanceof Origin) {
+ origin = (Origin) bgpValueType;
+ } else if (bgpValueType instanceof LocalPref) {
+ localPref = (LocalPref) bgpValueType;
+ } else if (bgpValueType instanceof LinkStateAttributes) {
+ LinkStateAttributes linkStateAttributes = (LinkStateAttributes) bgpValueType;
+ List linkStateAttribiuteList = linkStateAttributes.linkStateAttributes();
+ Iterator<BgpValueType> linkStateAttribiteIterator = linkStateAttribiuteList.iterator();
+ while (linkStateAttribiteIterator.hasNext()) {
+ BgpValueType bgpValueType1 = linkStateAttribiteIterator.next();
+ if (bgpValueType1 instanceof BgpAttrRouterIdV4) {
+ bgpAttrRouterIdV4 = (BgpAttrRouterIdV4) bgpValueType1;
+ }
+ }
+ } else if (bgpValueType instanceof MpReachNlri) {
+ mpReachNlri = (MpReachNlri) bgpValueType;
+ List<BgpLSNlri> bgpLSNlris = mpReachNlri.mpReachNlri();
+ Iterator<BgpLSNlri> bgpLsnlrisIterator = bgpLSNlris.iterator();
+ while (bgpLsnlrisIterator.hasNext()) {
+ BgpLSNlri bgpLSNlri = bgpLsnlrisIterator.next();
+ if (bgpLSNlri instanceof BgpNodeLSNlriVer4) {
+ BgpNodeLSNlriVer4 bgpNodeLSNlriVer4 = (BgpNodeLSNlriVer4) bgpLSNlri;
+ BgpNodeLSIdentifier bgpNodeLSIdentifier = bgpNodeLSNlriVer4.getLocalNodeDescriptors();
+ NodeDescriptors nodeDescriptors = bgpNodeLSIdentifier.getNodedescriptors();
+ List<BgpValueType> bgpvalueTypesList = nodeDescriptors.getSubTlvs();
+ Iterator<BgpValueType> bgpValueTypeIterator = bgpvalueTypesList.iterator();
+ while (bgpValueTypeIterator.hasNext()) {
+ BgpValueType valueType = bgpValueTypeIterator.next();
+ if (valueType instanceof IsIsNonPseudonode) {
+ isIsNonPseudonode = (IsIsNonPseudonode) valueType;
+
+ }
+ }
+ }
+ }
+ }
+ }
+ print("RibAsNumber = %s,PeerIdentifier = %s,RibIpAddress = %s,ProtocolType = %s,Origin = %s,LocalPref = %s," +
+ "RouterID = %s,IsoNodeID = %s,NextHop = %s", pathAttrNlriDetailsLocalRib.localRibAsNum(),
+ pathAttrNlriDetailsLocalRib.localRibIdentifier(), pathAttrNlriDetailsLocalRib.localRibIpAddress(),
+ protocolType.toString(), origin.origin(), localPref.localPref(), bgpAttrRouterIdV4.attrRouterId(),
+ Arrays.toString(isIsNonPseudonode.getIsoNodeId()), mpReachNlri.nexthop4());
+ }
+
+ private void displayLink() {
+
+ pathAttrNlriDetails = pathAttrNlriDetailsLocalRib.localRibNlridetails();
+ List<BgpValueType> valueTypes = pathAttrNlriDetails.pathAttributes();
+ Iterator<BgpValueType> itrBgpValueType = valueTypes.iterator();
+ while (itrBgpValueType.hasNext()) {
+ BgpValueType bgpValueType = itrBgpValueType.next();
+ if (bgpValueType instanceof Origin) {
+ origin = (Origin) bgpValueType;
+ } else if (bgpValueType instanceof LocalPref) {
+ localPref = (LocalPref) bgpValueType;
+ } else if (bgpValueType instanceof LinkStateAttributes) {
+ LinkStateAttributes linkStateAttributes = (LinkStateAttributes) bgpValueType;
+ List linkStateAttributelist = linkStateAttributes.linkStateAttributes();
+ Iterator<BgpValueType> linkStateAttributeIterator = linkStateAttributelist.iterator();
+ while (linkStateAttributeIterator.hasNext()) {
+ BgpValueType bgpValueType1 = linkStateAttributeIterator.next();
+ if (bgpValueType1 instanceof BgpAttrRouterIdV4) {
+ bgpAttrRouterIdV4 = (BgpAttrRouterIdV4) bgpValueType1;
+ } else if (bgpValueType1 instanceof BgpLinkAttrMaxLinkBandwidth) {
+ bgpLinkAttrMaxLinkBandwidth = (BgpLinkAttrMaxLinkBandwidth) bgpValueType1;
+ } else if (bgpValueType1 instanceof BgpLinkAttrUnRsrvdLinkBandwidth) {
+ bgpLinkAttrUnRsrvdLinkBandwidth = (BgpLinkAttrUnRsrvdLinkBandwidth) bgpValueType1;
+ } else if (bgpValueType1 instanceof BgpLinkAttrTeDefaultMetric) {
+ bgpLinkAttrTeDefaultMetric = (BgpLinkAttrTeDefaultMetric) bgpValueType1;
+ } else if (bgpValueType1 instanceof BgpLinkAttrIgpMetric) {
+ bgpLinkAttrIgpMetric = (BgpLinkAttrIgpMetric) bgpValueType1;
+ }
+
+ }
+ } else if (bgpValueType instanceof MpReachNlri) {
+ mpReachNlri = (MpReachNlri) bgpValueType;
+ List<BgpLSNlri> bgpLSNlris = mpReachNlri.mpReachNlri();
+ Iterator<BgpLSNlri> bgpLsnlrisIterator = bgpLSNlris.iterator();
+ while (bgpLsnlrisIterator.hasNext()) {
+ BgpLSNlri bgpLSNlri = bgpLsnlrisIterator.next();
+ if (bgpLSNlri instanceof BgpLinkLsNlriVer4) {
+ BgpLinkLsNlriVer4 bgpLinkLsNlriVer4 = (BgpLinkLsNlriVer4) bgpLSNlri;
+ BgpLinkLSIdentifier bgpLinkLSIdentifier = bgpLinkLsNlriVer4.getLinkIdentifier();
+ NodeDescriptors localnodeDescriptors = bgpLinkLSIdentifier.localNodeDescriptors();
+ NodeDescriptors remotenodeDescriptors = bgpLinkLSIdentifier.remoteNodeDescriptors();
+ List<BgpValueType> linkDescriptors = bgpLinkLSIdentifier.linkDescriptors();
+ List<BgpValueType> subTlvList = localnodeDescriptors.getSubTlvs();
+ Iterator<BgpValueType> subTlvIterator = subTlvList.iterator();
+ while (subTlvIterator.hasNext()) {
+ BgpValueType valueType = subTlvIterator.next();
+ if (valueType instanceof IsIsNonPseudonode) {
+ isIsNonPseudonode = (IsIsNonPseudonode) valueType;
+ } else if (valueType instanceof AutonomousSystemTlv) {
+ autonomousSystemTlv = (AutonomousSystemTlv) valueType;
+ }
+ }
+ List<BgpValueType> remotevalueTypes = remotenodeDescriptors.getSubTlvs();
+ Iterator<BgpValueType> remoteValueTypesIterator = remotevalueTypes.iterator();
+ while (remoteValueTypesIterator.hasNext()) {
+ BgpValueType valueType = remoteValueTypesIterator.next();
+ if (valueType instanceof IsIsNonPseudonode) {
+ isIsNonPseudonode = (IsIsNonPseudonode) valueType;
+ } else if (valueType instanceof AutonomousSystemTlv) {
+ autonomousSystemTlv = (AutonomousSystemTlv) valueType;
+ }
+ }
+ Iterator<BgpValueType> listIterator = linkDescriptors.iterator();
+ while (listIterator.hasNext()) {
+ BgpValueType valueType = listIterator.next();
+ if (valueType instanceof IPv4AddressTlv) {
+ iPv4AddressTlv = (IPv4AddressTlv) valueType;
+ }
+
+ }
+ }
+ }
+ }
+ }
+ print("PeerIdentifier = %s,Origin = %s,LocalPref = %s,RouterID = %s,MaxBandwidth = %s," +
+ "UnreservedBandwidth = %s,DefaultMetric = %s,IGPMetric = %s,IsoNodeID = %s,ASNum = %s," +
+ "IPAddress = %s,NextHop = %s", pathAttrNlriDetailsLocalRib.localRibIdentifier(),
+ origin.origin(), localPref.localPref(), bgpAttrRouterIdV4.attrRouterId(),
+ bgpLinkAttrMaxLinkBandwidth.linkAttrMaxLinkBandwidth(),
+ bgpLinkAttrUnRsrvdLinkBandwidth.getLinkAttrUnRsrvdLinkBandwidth().toString(),
+ bgpLinkAttrTeDefaultMetric.attrLinkDefTeMetric(), bgpLinkAttrIgpMetric.attrLinkIgpMetric(),
+ Arrays.toString(isIsNonPseudonode.getIsoNodeId()), autonomousSystemTlv.getAsNum(),
+ iPv4AddressTlv.address(), mpReachNlri.nexthop4().toString(),
+ pathAttrNlriDetailsLocalRib.localRibIpAddress(), origin.origin(), localPref.localPref(),
+ bgpAttrRouterIdV4.attrRouterId());
+
+ }
+}
\ No newline at end of file
diff --git a/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java
new file mode 100644
index 0000000..10d3b8c
--- /dev/null
+++ b/providers/bgp/cli/src/main/java/org/onosproject/bgp/cli/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Created by root1 on 23/8/16.
+ */
+package org.onosproject.bgp.cli;
\ No newline at end of file
diff --git a/providers/bgp/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/providers/bgp/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..6695a01
--- /dev/null
+++ b/providers/bgp/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,15 @@
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+ <command>
+ <action class="org.onosproject.bgp.cli.BgpConfiguration"/>
+ </command>
+ <command>
+ <action class="org.onosproject.bgp.cli.BgpLocalRibDisplay"/>
+ </command>
+ <command>
+ <action class="org.onosproject.bgp.cli.BgpExceptions"/>
+ </command>
+ </command-bundle>
+
+</blueprint>
diff --git a/providers/bgp/pom.xml b/providers/bgp/pom.xml
index be59ed7..9f04125 100644
--- a/providers/bgp/pom.xml
+++ b/providers/bgp/pom.xml
@@ -27,6 +27,7 @@
<module>topology</module>
<module>cfg</module>
<module>app</module>
+ <module>cli</module>
</modules>
<dependencies>
diff --git a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
index e8cd0fe..2619661 100644
--- a/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
+++ b/providers/bgp/topology/src/test/java/org/onosproject/provider/bgp/topology/impl/BgpControllerAdapter.java
@@ -26,6 +26,7 @@
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.protocol.BgpMessage;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -109,6 +110,26 @@
}
@Override
+ public void activeSessionExceptionAdd(String peerId, String exception) {
+ return;
+ }
+
+ @Override
+ public void closedSessionExceptionAdd(String peerId, String exception) {
+ return;
+ }
+
+ @Override
+ public Map<String, List<String>> activeSessionMap() {
+ return null;
+ }
+
+ @Override
+ public Map<String, List<String>> closedSessionMap() {
+ return null;
+ }
+
+ @Override
public void addListener(BgpNodeListener listener) {
// TODO Auto-generated method stub
}
diff --git a/providers/pcep/BUCK b/providers/pcep/BUCK
index c5b609d..ce77c96 100644
--- a/providers/pcep/BUCK
+++ b/providers/pcep/BUCK
@@ -1,6 +1,7 @@
BUNDLES = [
'//providers/pcep/topology:onos-providers-pcep-topology',
'//providers/pcep/tunnel:onos-providers-pcep-tunnel',
+ '//providers/pcep/cli:onos-providers-pcep-cli',
'//protocols/pcep/api:onos-protocols-pcep-api',
'//protocols/pcep/pcepio:onos-protocols-pcep-pcepio',
'//protocols/pcep/ctl:onos-protocols-pcep-ctl',
diff --git a/providers/pcep/app/app.xml b/providers/pcep/app/app.xml
index 1bdef05..1acc35d 100644
--- a/providers/pcep/app/app.xml
+++ b/providers/pcep/app/app.xml
@@ -25,4 +25,5 @@
<artifact>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/onos-pcep-provider-cli/${project.version}</artifact>
</app>
diff --git a/providers/pcep/app/features.xml b/providers/pcep/app/features.xml
index 002f7f6..7f846be 100644
--- a/providers/pcep/app/features.xml
+++ b/providers/pcep/app/features.xml
@@ -24,5 +24,6 @@
<bundle>mvn:${project.groupId}/onos-pcep-controller-impl/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-topology/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-pcep-provider-tunnel/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/onos-pcep-provider-cli/${project.version}</bundle>
</feature>
</features>
diff --git a/providers/pcep/app/pom.xml b/providers/pcep/app/pom.xml
index f3b2d08..4d2439f 100644
--- a/providers/pcep/app/pom.xml
+++ b/providers/pcep/app/pom.xml
@@ -53,6 +53,11 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
+ <artifactId>onos-pcep-provider-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
<artifactId>onos-pcep-provider-tunnel</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/providers/pcep/cli/BUCK b/providers/pcep/cli/BUCK
new file mode 100644
index 0000000..93199e4
--- /dev/null
+++ b/providers/pcep/cli/BUCK
@@ -0,0 +1,12 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//incubator/api:onos-incubator-api',
+ '//protocols/pcep/ctl:onos-protocols-pcep-ctl',
+ '//protocols/pcep/api:onos-protocols-pcep-api',
+ '//lib:org.apache.karaf.shell.console',
+ '//cli:onos-cli',
+]
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+)
diff --git a/providers/pcep/cli/pom.xml b/providers/pcep/cli/pom.xml
new file mode 100644
index 0000000..b9b04bc
--- /dev/null
+++ b/providers/pcep/cli/pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016-present Open Networking Laboratory
+ ~
+ ~ 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.
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-pcep-providers</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>onos-pcep-provider-cli</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>PCEP cli implementation</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-pcep-controller-impl</artifactId>
+ <version>1.9.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
new file mode 100644
index 0000000..420dd0c
--- /dev/null
+++ b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/PcepSessionCommand.java
@@ -0,0 +1,264 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * 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.pcep.cli;
+
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.pcep.controller.PcepClientController;
+import org.onosproject.pcep.controller.PcepErrorDetail;
+import org.onosproject.pcep.controller.PcepErrorType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.TreeMap;
+
+
+@Command(scope = "onos", name = "pcep", description = "Pcep Session Info")
+public class PcepSessionCommand extends AbstractShellCommand {
+ private static final Logger log = LoggerFactory.getLogger(PcepSessionCommand.class);
+ private static final String SESSION = "session";
+ private static final String EXCEPTION = "exception";
+ private static final String ERROR = "error";
+ private PcepClientController pcepClientController;
+ private byte sessionId;
+ private Set<String> pcepSessionKeySet;
+ private Set<String> pcepSessionIdKeySet;
+ private Integer sessionIdValue = 0;
+ private String sessionStatus;
+ private List pcepSessionExceptions = new ArrayList();
+ private Set<String> pcepSessionFailurekeySet;
+ private PcepErrorDetail pcepErrorDetail;
+ private PcepErrorType pcepErrorType;
+ private Map<Integer, String> sessionEstablishmentFailureMap = new TreeMap<>();
+ private Map<Integer, String> unknownObjectMap = new TreeMap<>();
+ private Map<Integer, String> notSupportedObjectMap = new TreeMap<>();
+ private Map<Integer, String> policyViolationMap = new TreeMap<>();
+ private Map<Integer, String> mandatoryObjectMissingMap = new TreeMap<>();
+ private Map<Integer, String> receptionOfInvalidObjectMap = new TreeMap<>();
+ private Map<Integer, String> invalidOperationMap = new TreeMap<>();
+ private Set<Integer> pcepErrorMsgKey;
+ private Integer pcepErrorValue = 0;
+
+ @Argument(index = 0, name = "name",
+ description = "session" + "\n" + "exception" + "\n" + "error",
+ required = true, multiValued = false)
+ String name = null;
+ @Argument(index = 1, name = "peer",
+ description = "peerIp",
+ required = false, multiValued = false)
+ String peer = null;
+
+ @Override
+ protected void execute() {
+ switch (name) {
+ case SESSION:
+ displayPcepSession();
+ break;
+ case EXCEPTION:
+ displayPcepSessionFailureReason();
+ break;
+ case ERROR:
+ displayPcepErrorMsgs();
+ break;
+ default:
+ System.out.print("Unknown Command");
+ break;
+ }
+ }
+
+ private void displayPcepSession() {
+ try {
+ this.pcepClientController = get(PcepClientController.class);
+ Map<String, String> pcepSessionMap = pcepClientController.getPcepSessionMap();
+ Map<String, Byte> pcepSessionIdMap = pcepClientController.getPcepSessionIdMap();
+ pcepSessionKeySet = pcepSessionMap.keySet();
+ pcepSessionIdKeySet = pcepSessionIdMap.keySet();
+ if (peer != null) {
+ if (pcepSessionKeySet.size() > 0) {
+ if (pcepSessionKeySet.contains(peer)) {
+ for (String pcepSessionPeer : pcepSessionKeySet) {
+ if (pcepSessionPeer.equals(peer)) {
+ for (String pcepSessionId : pcepSessionIdKeySet) {
+ if (pcepSessionId.equals(peer)) {
+ sessionId = pcepSessionIdMap.get(pcepSessionId);
+ sessionStatus = pcepSessionMap.get(pcepSessionPeer);
+ if (sessionId < 0) {
+ sessionIdValue = sessionId + 256;
+ } else {
+ sessionIdValue = (int) sessionId;
+ }
+ }
+ }
+ print("SessionIp = %s, Status = %s, sessionId = %s", pcepSessionPeer, sessionStatus, sessionIdValue);
+ }
+ }
+ } else {
+ System.out.print("Wrong Peer IP");
+ }
+ }
+ } else {
+ if (pcepSessionKeySet.size() > 0) {
+ for (String pcepSessionPeer : pcepSessionKeySet) {
+ for (String pcepSessionId : pcepSessionIdKeySet) {
+ if (pcepSessionId.equals(pcepSessionPeer)) {
+ sessionId = pcepSessionIdMap.get(pcepSessionId);
+ sessionStatus = pcepSessionMap.get(pcepSessionPeer);
+ if (sessionId < 0) {
+ sessionIdValue = sessionId + 256;
+ } else {
+ sessionIdValue = (int) sessionId;
+ }
+ }
+ }
+ print("SessionIp = %s, Status = %s, sessionId = %s", pcepSessionPeer, sessionStatus, sessionIdValue);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying PCEP session information: {}", e.getMessage());
+ }
+ }
+
+ private void displayPcepSessionFailureReason() {
+ try {
+ this.pcepClientController = get(PcepClientController.class);
+ Map<String, List<String>> pcepSessionFailureReasonMap = pcepClientController.getPcepExceptions();
+ pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
+ if (pcepSessionFailurekeySet.size() > 0) {
+ if (peer != null) {
+ if (pcepSessionFailurekeySet.contains(peer)) {
+ for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
+ if (pcepSessionPeerId.equals(peer)) {
+ pcepSessionExceptions = pcepSessionFailureReasonMap.get(pcepSessionPeerId);
+ print("PeerId = %s, FailureReason = %s", pcepSessionPeerId, pcepSessionExceptions);
+ }
+ }
+ } else {
+ System.out.print("Wrong Peer IP");
+ }
+
+ } else {
+ pcepSessionFailurekeySet = pcepSessionFailureReasonMap.keySet();
+ if (pcepSessionFailurekeySet.size() > 0) {
+ for (String pcepSessionPeerId : pcepSessionFailurekeySet) {
+ pcepSessionExceptions = pcepSessionFailureReasonMap.get(pcepSessionPeerId);
+ print("PeerId = %s, FailureReason = %s", pcepSessionPeerId, pcepSessionExceptions);
+ }
+ }
+ }
+
+ }
+
+
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying PCEP session failure reasons: {}", e.getMessage());
+ }
+
+ }
+
+
+ private void displayPcepErrorMsgs() {
+ try {
+ this.pcepClientController = get(PcepClientController.class);
+ Map<Integer, Integer> pcepErrorMsgMap = pcepClientController.getPcepErrorMsg();
+ pcepErrorMsgKey = pcepErrorMsgMap.keySet();
+ if (pcepErrorMsgKey.size() > 0) {
+ for (Integer errorType : pcepErrorMsgKey) {
+ pcepErrorValue = pcepErrorMsgMap.get(errorType);
+ pcepErrorType = PcepErrorType.values()[errorType];
+ switch (pcepErrorType) {
+ case SESSIONESTABLISHMENTFAILURE:
+ sessionEstablishmentFailureMap = pcepErrorDetail.sessionEstablishmentFailure();
+ Set<Integer> sessionFailureKeySet = sessionEstablishmentFailureMap.keySet();
+ for (Integer sessionFailureKey : sessionFailureKeySet) {
+ if (sessionFailureKey == pcepErrorValue) {
+ System.out.print(sessionEstablishmentFailureMap.get(sessionFailureKey));
+ }
+ }
+ case CAPABALITYNOTSUPPORTED:
+ System.out.print("Capability not supported");
+ case UNKNOWNOBJECT:
+ unknownObjectMap = pcepErrorDetail.unknownObject();
+ Set<Integer> unknownObjectKeySet = unknownObjectMap.keySet();
+ for (Integer unknownObjectKey : unknownObjectKeySet) {
+ if (unknownObjectKey == pcepErrorValue) {
+ System.out.print(unknownObjectMap.get(unknownObjectKey));
+ }
+ }
+ case NOTSUPPORTEDOBJECT:
+ notSupportedObjectMap = pcepErrorDetail.notSupportedObject();
+ Set<Integer> notSupportedObjectKeySet = notSupportedObjectMap.keySet();
+ for (Integer notSupportedObjectKey : notSupportedObjectKeySet) {
+ if (notSupportedObjectKey == pcepErrorValue) {
+ System.out.print(notSupportedObjectMap.get(notSupportedObjectKey));
+ }
+ }
+ case POLICYVIOLATION:
+ policyViolationMap = pcepErrorDetail.policyViolation();
+ Set<Integer> policyViolationKeySet = policyViolationMap.keySet();
+ for (Integer policyViolationKey : policyViolationKeySet) {
+ if (policyViolationKey == pcepErrorValue) {
+ System.out.print(policyViolationMap.get(policyViolationKey));
+ }
+ }
+ case MANDATORYOBJECTMISSING:
+ mandatoryObjectMissingMap = pcepErrorDetail.mandatoryObjectMissing();
+ Set<Integer> mandatoryObjectMissingKeySet = mandatoryObjectMissingMap.keySet();
+ for (Integer mandatoryObjectMissingKey : mandatoryObjectMissingKeySet) {
+ if (mandatoryObjectMissingKey == pcepErrorValue) {
+ System.out.print(mandatoryObjectMissingMap.get(mandatoryObjectMissingKey));
+ }
+ }
+ case SYNCHRONIZEDPATHCOMPUTATIONREQUESTMISSING:
+ System.out.print("Synchronized path computation request missing");
+ case UNKNOWNREQUESTREFERENCE:
+ System.out.print("Unknown request reference");
+ case ESTABLISHINGSECONDPCEPSESSION:
+ System.out.print("Attempt to establish a second PCEP session");
+ case RECEPTIONOFINVALIDOBJECT:
+ receptionOfInvalidObjectMap = pcepErrorDetail.receptionOfInvalidObject();
+ Set<Integer> receptionOfInvalidObjectKeySet = receptionOfInvalidObjectMap.keySet();
+ for (Integer receptionOfInvalidObjectKey : receptionOfInvalidObjectKeySet) {
+ if (receptionOfInvalidObjectKey == pcepErrorValue) {
+ System.out.print(receptionOfInvalidObjectMap.get(receptionOfInvalidObjectKey));
+ }
+ }
+ case INVALIDOPERATION:
+ invalidOperationMap = pcepErrorDetail.invalidOperation();
+ Set<Integer> invalidOperationKeySet = invalidOperationMap.keySet();
+ for (Integer invalidOperationKey : invalidOperationKeySet) {
+ if (invalidOperationKey == pcepErrorValue) {
+ System.out.print(invalidOperationMap.get(invalidOperationKey));
+ }
+ }
+ case VIRTUALNETWORKTLVMISSING:
+ System.out.print("VIRTUAL-NETWORK TLV missing");
+ default:
+ System.out.print("Unknown error message");
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.debug("Error occurred while displaying PCEP error messages received: {}", e.getMessage());
+ }
+ }
+}
diff --git a/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java
new file mode 100644
index 0000000..2dd3a6d
--- /dev/null
+++ b/providers/pcep/cli/src/main/java/org/onosproject/pcep/cli/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Created by root1 on 23/8/16.
+ */
+package org.onosproject.pcep.cli;
\ No newline at end of file
diff --git a/providers/pcep/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/providers/pcep/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
new file mode 100644
index 0000000..aef97fd
--- /dev/null
+++ b/providers/pcep/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -0,0 +1,10 @@
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+
+ <command>
+ <action class="org.onosproject.pcep.cli.PcepSessionCommand"/>
+ </command>
+ </command-bundle>
+
+</blueprint>
diff --git a/providers/pcep/pom.xml b/providers/pcep/pom.xml
index a48bce5..491d5bb 100644
--- a/providers/pcep/pom.xml
+++ b/providers/pcep/pom.xml
@@ -27,5 +27,6 @@
<module>topology</module>
<module>tunnel</module>
<module>app</module>
+ <module>cli</module>
</modules>
</project>
\ No newline at end of file
diff --git a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java b/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
index 459ebc9..86487d9 100644
--- a/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
+++ b/providers/pcep/topology/src/test/java/org/onosproject/provider/pcep/topology/impl/PcepClientControllerAdapter.java
@@ -15,12 +15,7 @@
*/
package org.onosproject.provider.pcep.topology.impl;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
@@ -48,6 +43,15 @@
import com.google.common.collect.Sets;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.List;
+import java.util.Map;
+
import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19;
import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5;
@@ -306,6 +310,32 @@
}
@Override
+ public Map<String, List<String>> getPcepExceptions() {
+ return null;
+ }
+
+ @Override
+ public Map<Integer, Integer> getPcepErrorMsg() {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getPcepSessionMap() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Byte> getPcepSessionIdMap() {
+ return null;
+ }
+
+ @Override
+ public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
+ return;
+ }
+
+
+ @Override
public boolean allocateLocalLabel(Tunnel tunnel) {
// TODO Auto-generated method stub
return false;
diff --git a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
index a541734..4bcba82 100644
--- a/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
+++ b/providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientControllerAdapter.java
@@ -21,6 +21,8 @@
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.List;
+import java.util.Map;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
@@ -299,6 +301,31 @@
}
@Override
+ public Map<String, List<String>> getPcepExceptions() {
+ return null;
+ }
+
+ @Override
+ public Map<Integer, Integer> getPcepErrorMsg() {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getPcepSessionMap() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Byte> getPcepSessionIdMap() {
+ return null;
+ }
+
+ @Override
+ public void peerErrorMsg(String peerId, Integer errorType, Integer errValue) {
+ return;
+ }
+
+ @Override
public boolean allocateLocalLabel(Tunnel tunnel) {
// TODO Auto-generated method stub
return false;