Skip to content
Snippets Groups Projects
Commit 1722663a authored by Shudong Zhou's avatar Shudong Zhou
Browse files

BSC-3426 Add log message for port status change

parent 6d3e72a3
No related branches found
No related tags found
No related merge requests found
...@@ -1106,19 +1106,31 @@ public class Controller implements IFloodlightProviderService, ...@@ -1106,19 +1106,31 @@ public class Controller implements IFloodlightProviderService,
// Message handlers // Message handlers
// **************** // ****************
@LogMessageDocs({
@LogMessageDoc(message="Port modified on switch {switch}: {port} ",
explanation="Received notification from switch about port status change"),
@LogMessageDoc(message="Port added on switch {switch}: {port} ",
explanation="Received notification from switch about a new port addition"),
@LogMessageDoc(message="Port deleted on switch {switch}: port_no = {port} ",
explanation="Received notification from switch about a port removal"),
@LogMessageDoc(level="ERROR",
message="Failure adding update to queue",
explanation="Failed to add port status change to internal queue for processing",
recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
})
protected void handlePortStatusMessage(IOFSwitch sw, OFPortStatus m) { protected void handlePortStatusMessage(IOFSwitch sw, OFPortStatus m) {
short portNumber = m.getDesc().getPortNumber(); short portNumber = m.getDesc().getPortNumber();
OFPhysicalPort port = m.getDesc(); OFPhysicalPort port = m.getDesc();
if (m.getReason() == (byte)OFPortReason.OFPPR_MODIFY.ordinal()) { if (m.getReason() == (byte)OFPortReason.OFPPR_MODIFY.ordinal()) {
sw.setPort(port); sw.setPort(port);
log.debug("Port #{} modified for {}", portNumber, sw); log.info("Port modified on switch {}: {}", sw, port);
} else if (m.getReason() == (byte)OFPortReason.OFPPR_ADD.ordinal()) { } else if (m.getReason() == (byte)OFPortReason.OFPPR_ADD.ordinal()) {
sw.setPort(port); sw.setPort(port);
log.debug("Port #{} added for {}", portNumber, sw); log.info("Port added on switch {}: {}", sw, port);
} else if (m.getReason() == } else if (m.getReason() ==
(byte)OFPortReason.OFPPR_DELETE.ordinal()) { (byte)OFPortReason.OFPPR_DELETE.ordinal()) {
sw.deletePort(portNumber); sw.deletePort(portNumber);
log.debug("Port #{} deleted for {}", portNumber, sw); log.info("Port deleted on switch {}: port_no = {}", sw, portNumber);
} }
SwitchUpdate update = new SwitchUpdate(sw, SwitchUpdateType.PORTCHANGED); SwitchUpdate update = new SwitchUpdate(sw, SwitchUpdateType.PORTCHANGED);
try { try {
......
...@@ -26,14 +26,15 @@ import net.floodlightcontroller.core.web.serializers.UShortSerializer; ...@@ -26,14 +26,15 @@ import net.floodlightcontroller.core.web.serializers.UShortSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize; import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.util.HexString;
/** /**
* Represents ofp_phy_port * Represents ofp_phy_port
* @author David Erickson (daviderickson@cs.stanford.edu) - Mar 25, 2010 * @author David Erickson (daviderickson@cs.stanford.edu) - Mar 25, 2010
*/ */
public class OFPhysicalPort { public class OFPhysicalPort {
public static int MINIMUM_LENGTH = 48; public final static int MINIMUM_LENGTH = 48;
public static int OFP_ETH_ALEN = 6; public final static int OFP_ETH_ALEN = 6;
public enum OFPortConfig { public enum OFPortConfig {
OFPPC_PORT_DOWN (1 << 0) { OFPPC_PORT_DOWN (1 << 0) {
...@@ -467,4 +468,35 @@ public class OFPhysicalPort { ...@@ -467,4 +468,35 @@ public class OFPhysicalPort {
} }
return true; return true;
} }
@Override
public String toString() {
String linkState, linkSpeed;
if ((state & OFPortState.OFPPS_LINK_DOWN.getValue()) != 0) {
linkState = "down";
} else {
linkState = "up";
}
if ((currentFeatures & OFPortFeatures.OFPPF_10GB_FD.getValue()) != 0) {
linkSpeed = "10G";
} else if ((currentFeatures & OFPortFeatures.OFPPF_1GB_FD.getValue()) != 0) {
linkSpeed = "1G";
} else if ((currentFeatures & OFPortFeatures.OFPPF_1GB_HD.getValue()) != 0) {
linkSpeed = "1G(half-duplex)";
} else if ((currentFeatures & OFPortFeatures.OFPPF_100MB_FD.getValue()) != 0) {
linkSpeed = "100M";
} else if ((currentFeatures & OFPortFeatures.OFPPF_100MB_HD.getValue()) != 0) {
linkSpeed = "100M(half-duplex)";
} else if ((currentFeatures & OFPortFeatures.OFPPF_10MB_FD.getValue()) != 0) {
linkSpeed = "10M";
} else if ((currentFeatures & OFPortFeatures.OFPPF_10MB_HD.getValue()) != 0) {
linkSpeed = "10M(half-duplex)";
} else {
linkSpeed = "unknown";
}
return "port " + name + " (" + portNumber + ")" +
", mac " + HexString.toHexString(hardwareAddress) +
", state " + linkState +
", speed " + linkSpeed;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment