-Added Status field in CLI for port stats
diff --git a/cli/cli/desc/version200/core.py b/cli/cli/desc/version200/core.py
index ac8f1c9..4e255e5 100755
--- a/cli/cli/desc/version200/core.py
+++ b/cli/cli/desc/version200/core.py
@@ -2232,25 +2232,25 @@
REALTIME_PORT_FORMAT = {
'realtime_port' : {
'field-orderings' : {
- 'default' : [ 'Idx', 'switch', 'portNumber', 'receiveBytes',
+ 'default' : [ 'Idx', 'switch', 'portNumber','portStatus', 'receiveBytes',
'receivePackets', 'receiveErrors', 'receiveDropped',
'receiveCRCErrors', 'receiveOverrunErrors',
'receiveFrameErrors', 'transmitBytes',
'transmitPackets', 'transmitErrors',
'transmitDropped', 'collisions' ],
- 'details' : [ 'Idx', 'switch', 'portNumber', 'receiveBytes',
+ 'details' : [ 'Idx', 'switch', 'portNumber','portStatus', 'receiveBytes',
'receivePackets', 'receiveErrors', 'receiveDropped',
'receiveCRCErrors', 'receiveOverrunErrors',
'receiveFrameErrors', 'transmitBytes',
'transmitPackets', 'transmitErrors',
'transmitDropped', 'collisions' ],
- 'scoped' : [ 'Idx', 'portNumber', 'receiveBytes',
+ 'scoped' : [ 'Idx', 'portNumber','portStatus', 'receiveBytes',
'receivePackets', 'receiveErrors', 'receiveDropped',
'receiveCRCErrors', 'receiveOverrunErrors',
'receiveFrameErrors', 'transmitBytes',
'transmitPackets', 'transmitErrors',
'transmitDropped', 'collisions' ],
- 'brief' : [ 'Idx', 'switch', 'portNumber',
+ 'brief' : [ 'Idx', 'switch', 'portNumber','portStatus',
'receiveBytes', 'receivePackets', 'receiveErrors',
'transmitBytes', 'transmitPackets', 'transmitErrors',
]
@@ -2300,7 +2300,10 @@
},
'length' : { 'verbose-name' : 'Length'
},
+ 'portStatus' : { 'verbose-name' : 'Status'
+ },
}
+
},
}
diff --git a/src/main/java/net/floodlightcontroller/core/web/OFPortStatsEntryMod.java b/src/main/java/net/floodlightcontroller/core/web/OFPortStatsEntryMod.java
index 77dea99..a1ce334 100644
--- a/src/main/java/net/floodlightcontroller/core/web/OFPortStatsEntryMod.java
+++ b/src/main/java/net/floodlightcontroller/core/web/OFPortStatsEntryMod.java
@@ -1,5 +1,6 @@
package net.floodlightcontroller.core.web;
+import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.web.serializers.OFPortStatsEntrySerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@@ -8,15 +9,21 @@
@JsonSerialize(using = OFPortStatsEntrySerializer.class)
public class OFPortStatsEntryMod {
private OFPortStatsEntry portStatsEntry = null;
+ private IOFSwitch sw= null;
public OFPortStatsEntryMod() {
}
- public OFPortStatsEntryMod(OFPortStatsEntry portStatsEntry) {
+ public OFPortStatsEntryMod(OFPortStatsEntry portStatsEntry, IOFSwitch switch1) {
this.portStatsEntry = portStatsEntry;
+ this.sw = switch1;
}
public OFPortStatsEntry getPortStatsEntry() {
return portStatsEntry;
}
+
+ public IOFSwitch getSwitch(){
+ return this.sw;
+ }
}
diff --git a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
index 094d305..c8ff917 100644
--- a/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
+++ b/src/main/java/net/floodlightcontroller/core/web/SwitchResourceBase.java
@@ -130,7 +130,7 @@
portStats = new ArrayList<OFPortStatsEntryMod>();
for(OFStatsReply value : values){
for (OFPortStatsEntry entry : ((OFPortStatsReply)value).getEntries()) {
- OFPortStatsEntryMod entryMod = new OFPortStatsEntryMod(entry);
+ OFPortStatsEntryMod entryMod = new OFPortStatsEntryMod(entry, sw);
portStats.add(entryMod);
}
}
diff --git a/src/main/java/net/floodlightcontroller/core/web/serializers/OFPortStatsEntrySerializer.java b/src/main/java/net/floodlightcontroller/core/web/serializers/OFPortStatsEntrySerializer.java
index cf3062a..259f7f2 100644
--- a/src/main/java/net/floodlightcontroller/core/web/serializers/OFPortStatsEntrySerializer.java
+++ b/src/main/java/net/floodlightcontroller/core/web/serializers/OFPortStatsEntrySerializer.java
@@ -2,6 +2,8 @@
import java.io.IOException;
+import net.floodlightcontroller.core.IOFSwitch;
+import net.floodlightcontroller.core.internal.OFSwitchImplBase;
import net.floodlightcontroller.core.web.OFPortStatsEntryMod;
import org.codehaus.jackson.JsonGenerationException;
@@ -20,9 +22,12 @@
public void serialize(OFPortStatsEntryMod portStatModEntry, JsonGenerator jGen,
SerializerProvider sp) throws IOException, JsonGenerationException {
+ IOFSwitch sw = portStatModEntry.getSwitch();
OFPortStatsEntry portStatEntry = portStatModEntry.getPortStatsEntry();
jGen.writeStartObject();
jGen.writeNumberField("portNumber", portStatEntry.getPortNo().getPortNumber());
+ jGen.writeStringField("portStatus", ((OFSwitchImplBase) sw).portEnabled(
+ portStatEntry.getPortNo().getPortNumber()) ? "up" : "down");
jGen.writeNumberField("receivePackets", portStatEntry.getRxPackets().getValue());
jGen.writeNumberField("transmitPackets", portStatEntry.getTxPackets().getValue());
jGen.writeNumberField("receiveBytes", portStatEntry.getRxBytes().getValue());