Processing of OF Messages PacketIn, FlowRemoved, PortStatus, Experimenter 03/2203/2
authorYugandhar <ysarraju@in.ibm.com>
Mon, 28 Oct 2013 07:05:38 +0000 (12:35 +0530)
committerYugandhar <ysarraju@in.ibm.com>
Wed, 30 Oct 2013 07:04:13 +0000 (12:34 +0530)
Change-Id: I493ad22b5964ec3632ae111a313c3e5850a8a079
Signed-off-by: Yugandhar <ysarraju@in.ibm.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/ConnectionConductorImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionContext.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/session/SessionContextOFImpl.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/ConnectionConductorImplTest.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/session/MessageDispatchServiceImplTest.java

index ea9c2f6c7681a5fe1a7646861230748f8c470166..cd50acc4fdef9b4b03b625aa8b80b3f6adb1f1f7 100644 (file)
@@ -11,12 +11,12 @@ package org.opendaylight.openflowplugin.openflow.md.core;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
-import org.opendaylight.openflowplugin.openflow.core.IMessageListener;
 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
 import org.opendaylight.openflowplugin.openflow.md.core.session.SessionManager;
@@ -76,7 +76,7 @@ public class ConnectionConductorImpl implements OpenflowProtocolListener,
 
     private SessionContext sessionContext;
 
-    private ImmutableMap<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping;
+    private Map<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping;
 
     private boolean isFirstHelloNegotiation = true;
 
@@ -161,14 +161,14 @@ public class ConnectionConductorImpl implements OpenflowProtocolListener,
 
     @Override
     public void onExperimenterMessage(ExperimenterMessage experimenterMessage) {
-        // TODO Auto-generated method stub
         LOG.debug("experimenter received, type: "
                 + experimenterMessage.getExpType());
+        notifyListeners(ExperimenterMessage.class, experimenterMessage);
     }
 
     @Override
-    public void onFlowRemovedMessage(FlowRemovedMessage arg0) {
-        // TODO Auto-generated method stub
+    public void onFlowRemovedMessage(FlowRemovedMessage message) {
+        notifyListeners(FlowRemovedMessage.class, message);
     }
 
 
@@ -323,8 +323,9 @@ public class ConnectionConductorImpl implements OpenflowProtocolListener,
     }
 
     @Override
-    public void onPortStatusMessage(PortStatusMessage arg0) {
-        // TODO Auto-generated method stub
+    public void onPortStatusMessage(PortStatusMessage message) {
+        this.getSessionContext().processPortStatusMsg(message);
+        notifyListeners(PortStatusMessage.class, message);
     }
 
     @Override
@@ -482,7 +483,7 @@ public class ConnectionConductorImpl implements OpenflowProtocolListener,
      * @param listenerMapping the listenerMapping to set
      */
     public void setListenerMapping(
-            ImmutableMap<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping) {
+            Map<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping) {
         //TODO: adjust the listener interface
         this.listenerMapping = listenerMapping;
     }
@@ -495,9 +496,15 @@ public class ConnectionConductorImpl implements OpenflowProtocolListener,
         Collection<IMDMessageListener> listeners = listenerMapping.get(messageType);
         if (listeners != null) {
                 for (IMDMessageListener listener : listeners) {
-                //TODO : need to add unit-tests
-                //listener.receive(this.getAuxiliaryKey(), this.getSessionContext(), message);
-            }
+                    // Pass cookie only for PACKT_IN
+                    if ( messageType.equals("PacketInMessage.class")){
+                        listener.receive(this.getAuxiliaryKey(), this.getSessionContext(), message);
+                    } else {
+                        listener.receive(null, this.getSessionContext(), message);
+                    }
+                }
+        } else {
+            LOG.warn("No listeners for this message Type {}", messageType);
         }
     }
 
index 5b607ea5b4820838c6a4960f88ded94834321df6..838bf653f445157cf43df4771aa7ec429cf534b1 100644 (file)
@@ -8,13 +8,16 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.session;
 
-
-import java.util.Map.Entry;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 
 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus;
 
 /**
  * @author mirehak
@@ -75,6 +78,55 @@ public interface SessionContext {
      */
     public SwitchConnectionDistinguisher getSessionKey();
 
+    /**
+     * Returns a map containing all OFPhysicalPorts of this switch.
+     * @return The Map of OFPhysicalPort
+     */
+    public Map<Long, Port> getPhysicalPorts();
+
+    /**
+     * Returns a Set containing all port IDs of this switch.
+     * @return The Set of port ID
+     */
+    public Set<Long> getPorts();
+
+    /**
+     * Returns OFPhysicalPort of the specified portNumber of this switch.
+     * @param portNumber The port ID
+     * @return OFPhysicalPort for the specified PortNumber
+     */
+    public Port getPhysicalPort(Long portNumber);
+
+    /**
+     * Returns the bandwidth of the specified portNumber of this switch.
+     * @param portNumber the port ID
+     * @return bandwidth
+     */
+    public Boolean getPortBandwidth(Long portNumber);
+
+    /**
+     * Returns True if the port is enabled,
+     * @param portNumber
+     * @return True if the port is enabled
+     */
+    public boolean isPortEnabled(long portNumber);
+
+    /**
+     * Returns True if the port is enabled.
+     * @param port
+     * @return True if the port is enabled
+     */
+    public boolean isPortEnabled(Port port);
+
+    /**
+     * Returns a list containing all enabled ports of this switch.
+     * @return: List containing all enabled ports of this switch
+     */
+    public List<Port> getEnabledPorts();
+
+    public void processPortStatusMsg(PortStatus arg0);
+
+
     // TODO:: add listeners here, manager will set them and conductor use them
 
     /**
index 96dee119422fa90b69546f92468d06941e83254c..f53ca2676f0599fca4392812f267b2454945f8f2 100644 (file)
@@ -8,7 +8,11 @@
 
 package org.opendaylight.openflowplugin.openflow.md.core.session;
 
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
@@ -17,6 +21,8 @@ import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductor;
 import org.opendaylight.openflowplugin.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Port;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus;
 
 /**
  * @author mirehak
@@ -30,6 +36,8 @@ public class SessionContextOFImpl implements SessionContext {
     private SwitchConnectionDistinguisher sessionKey;
     private IMessageDispatchService mdService;
     private final AtomicLong xid;
+    private final Map<Long, Port> physicalPorts;
+    private final Map<Long, Boolean> portBandwidth;
 
     /**
      * default ctor
@@ -38,6 +46,8 @@ public class SessionContextOFImpl implements SessionContext {
         auxiliaryConductors = new ConcurrentHashMap<>();
         mdService = new MessageDispatchServiceImpl(this);
         xid = new AtomicLong();
+        this.physicalPorts = new HashMap<Long, Port>();
+        this.portBandwidth = new HashMap<Long, Boolean>();
     }
 
     @Override
@@ -121,4 +131,94 @@ public class SessionContextOFImpl implements SessionContext {
     public Long getNextXid() {
         return xid.incrementAndGet();
     }
+
+    @Override
+    public Map<Long, Port> getPhysicalPorts() {
+        return this.physicalPorts;
+    }
+
+    @Override
+    public Set<Long> getPorts() {
+        return this.physicalPorts.keySet();
+    }
+
+    @Override
+    public Port getPhysicalPort(Long portNumber) {
+        return this.physicalPorts.get(portNumber);
+    }
+
+    @Override
+    public Boolean getPortBandwidth(Long portNumber) {
+        return this.portBandwidth.get(portNumber);
+    }
+
+    @Override
+    public boolean isPortEnabled(long portNumber) {
+        return isPortEnabled(physicalPorts.get(portNumber));
+    }
+
+    @Override
+    public boolean isPortEnabled(Port port) {
+        if (port == null) {
+            return false;
+        }
+        if (port.getConfig().isPortDown()) {
+            return false;
+        }
+        if (port.getState().isLinkDown()) {
+            return false;
+        }
+        if (port.getState().isBlocked()) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public List<Port> getEnabledPorts() {
+        List<Port> result = new ArrayList<Port>();
+        synchronized (this.physicalPorts) {
+            for (Port port : physicalPorts.values()) {
+                if (isPortEnabled(port)) {
+                    result.add(port);
+                }
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public void processPortStatusMsg(PortStatus msg) {
+        Port port = msg;
+        if (msg.getReason().getIntValue() == 2) {
+            updatePhysicalPort(port);
+        } else if (msg.getReason().getIntValue() == 0) {
+            updatePhysicalPort(port);
+        } else if (msg.getReason().getIntValue() == 1) {
+            deletePhysicalPort(port);
+        }
+
+    }
+
+    private void updatePhysicalPort(Port port) {
+        Long portNumber = port.getPortNo();
+        physicalPorts.put(portNumber, port);
+        portBandwidth
+                .put(portNumber,
+                        ( (port.getCurrentFeatures().is_100gbFd())
+                          |(port.getCurrentFeatures().is_100mbFd()) | (port.getCurrentFeatures().is_100mbHd())
+                          | (port.getCurrentFeatures().is_10gbFd()) | (port.getCurrentFeatures().is_10mbFd())
+                          | (port.getCurrentFeatures().is_10mbHd()) | (port.getCurrentFeatures().is_1gbFd())
+                          | (port.getCurrentFeatures().is_1gbHd()) | (port.getCurrentFeatures().is_1tbFd())
+                          | (port.getCurrentFeatures().is_40gbFd()) | (port.getCurrentFeatures().isAutoneg())
+                          | (port.getCurrentFeatures().isCopper()) | (port.getCurrentFeatures().isFiber())
+                          | (port.getCurrentFeatures().isOther()) | (port.getCurrentFeatures().isPause())
+                          | (port.getCurrentFeatures().isPauseAsym()) ) );
+    }
+
+    private void deletePhysicalPort(Port port) {
+        Long portNumber = port.getPortNo();
+        physicalPorts.remove(portNumber);
+        portBandwidth.remove(portNumber);
+    }
 }
index 9c8488a8b213a2bb27dcec5ee8973e9459e731e2..852b5035645a9aa3e1d0b1a9d1991b3f714992c8 100644 (file)
@@ -11,6 +11,9 @@ package org.opendaylight.openflowplugin.openflow.md.core;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Stack;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
@@ -22,16 +25,30 @@ import org.junit.Test;
 import org.opendaylight.openflowplugin.openflow.md.core.plan.ConnectionAdapterStackImpl;
 import org.opendaylight.openflowplugin.openflow.md.core.plan.EventFactory;
 import org.opendaylight.openflowplugin.openflow.md.core.plan.SwitchTestEvent;
+import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.HelloElementType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.ElementsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,6 +69,12 @@ public class ConnectionConductorImplTest {
     private Thread libSimulation;
     private ScheduledThreadPoolExecutor pool = new ScheduledThreadPoolExecutor(
             8);
+    private int experimenterMessageCounter;
+    private int packetinMessageCounter;
+    private int flowremovedMessageCounter;
+    private int portstatusAddMessageCounter;
+    private int portstatusDeleteMessageCounter;
+    private int portstatusModifyMessageCounter;
 
     /**
      * @throws java.lang.Exception
@@ -263,8 +286,19 @@ public class ConnectionConductorImplTest {
      */
     @Test
     public void testOnFlowRemovedMessage() {
-        // fail("Not yet implemented");
-        // TODO:: add test
+        IMDMessageListener objFms = new FlowRemovedMessageService() ;
+        Map<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping = new HashMap<Class<? extends DataObject>, Collection<IMDMessageListener>>();
+        Collection<IMDMessageListener> existingValues = new ArrayList<IMDMessageListener>();
+        existingValues.add(objFms);
+        listenerMapping.put(FlowRemovedMessage.class, existingValues);
+        connectionConductor.setListenerMapping(listenerMapping);
+        FlowRemovedMessageBuilder builder1 = new FlowRemovedMessageBuilder();
+        builder1.setXid(1L);
+        connectionConductor.onFlowRemovedMessage(builder1.build());
+        Assert.assertEquals(1, flowremovedMessageCounter);
+        builder1.setXid(2L);
+        connectionConductor.onFlowRemovedMessage(builder1.build());
+        Assert.assertEquals(2, flowremovedMessageCounter);
     }
 
     /**
@@ -296,8 +330,19 @@ public class ConnectionConductorImplTest {
      */
     @Test
     public void testOnPacketInMessage() {
-        // fail("Not yet implemented");
-        // TODO:: add test
+        IMDMessageListener objPms = new PacketInMessageService() ;
+        Map<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping = new HashMap<Class<? extends DataObject>, Collection<IMDMessageListener>>();
+        Collection<IMDMessageListener> existingValues = new ArrayList<IMDMessageListener>();
+        existingValues.add(objPms);
+        listenerMapping.put(PacketInMessage.class, existingValues);
+        connectionConductor.setListenerMapping(listenerMapping);
+        PacketInMessageBuilder builder1 = new PacketInMessageBuilder();
+        builder1.setBufferId((long)1);
+        connectionConductor.onPacketInMessage(builder1.build());
+        Assert.assertEquals(1, packetinMessageCounter);
+        builder1.setBufferId((long)2);
+        connectionConductor.onPacketInMessage(builder1.build());
+        Assert.assertEquals(2, packetinMessageCounter);
     }
 
     /**
@@ -307,8 +352,28 @@ public class ConnectionConductorImplTest {
      */
     @Test
     public void testOnPortStatusMessage() {
-        // fail("Not yet implemented");
-        // TODO:: add test
+        GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
+        builder.setDatapathId(new BigInteger("102030405060"));
+        builder.setAuxiliaryId((short) 0);
+        OFSessionUtil.registerSession(connectionConductor,
+                builder.build(), (short)0x04);
+        IMDMessageListener objPSms = new PortStatusMessageService() ;
+        Map<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping = new HashMap<Class<? extends DataObject>, Collection<IMDMessageListener>>();
+        Collection<IMDMessageListener> existingValues = new ArrayList<IMDMessageListener>();
+        existingValues.add(objPSms);
+        listenerMapping.put(PortStatusMessage.class, existingValues);
+        connectionConductor.setListenerMapping(listenerMapping);
+        PortStatusMessageBuilder builder1 = new PortStatusMessageBuilder();
+        PortFeatures features = new PortFeatures(true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false);
+        builder1.setPortNo(90L).setReason(PortReason.OFPPRADD).setCurrentFeatures(features);
+        connectionConductor.onPortStatusMessage(builder1.build());
+        Assert.assertEquals(1, portstatusAddMessageCounter);
+        builder1.setPortNo(90L).setReason(PortReason.OFPPRMODIFY).setCurrentFeatures(features);
+        connectionConductor.onPortStatusMessage(builder1.build());
+        Assert.assertEquals(1, portstatusModifyMessageCounter);
+        builder1.setPortNo(90L).setReason(PortReason.OFPPRDELETE).setCurrentFeatures(features);
+        connectionConductor.onPortStatusMessage(builder1.build());
+        Assert.assertEquals(1, portstatusDeleteMessageCounter);
     }
 
     /**
@@ -574,4 +639,66 @@ public class ConnectionConductorImplTest {
 
         return getFeaturesOutputBuilder;
     }
+
+    private class ExperimenterMessageService implements IMDMessageListener {
+        @Override
+        public void receive(SwitchConnectionDistinguisher cookie, SessionContext sw, DataObject msg) {
+            LOG.debug("Received a packet in Experimenter Service");
+            experimenterMessageCounter++;
+        }
+    }
+
+    private class PacketInMessageService implements IMDMessageListener {
+        @Override
+        public void receive(SwitchConnectionDistinguisher cookie, SessionContext sw, DataObject msg) {
+            LOG.debug("Received a packet in PacketIn Service");
+            packetinMessageCounter++;
+        }
+    }
+
+    private class FlowRemovedMessageService implements IMDMessageListener {
+        @Override
+        public void receive(SwitchConnectionDistinguisher cookie, SessionContext sw, DataObject msg) {
+            LOG.debug("Received a packet in FlowRemoved Service");
+            flowremovedMessageCounter++;
+        }
+    }
+
+    private class PortStatusMessageService implements IMDMessageListener {
+        @Override
+        public void receive(SwitchConnectionDistinguisher cookie, SessionContext sw, DataObject msg) {
+            LOG.debug("Received a packet in PortStatus Service");
+            if ( (((PortStatusMessage)msg).getReason().equals(PortReason.OFPPRADD))  ) {
+                portstatusAddMessageCounter++;
+            } else if (((PortStatusMessage)msg).getReason().equals(PortReason.OFPPRDELETE)){
+                portstatusDeleteMessageCounter++;
+            } else if (((PortStatusMessage)msg).getReason().equals(PortReason.OFPPRMODIFY)) {
+                portstatusModifyMessageCounter++;
+            }
+        }
+    }
+
+    /**
+     * Test method for
+     * {@link org.opendaylight.openflowplugin.openflow.md.core.ConnectionConductorImpl#onExperimenterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage)}
+     * .
+     * @throws InterruptedException
+     */
+    @Test
+    public void testOnExperimenterMessage() throws InterruptedException {
+        IMDMessageListener objEms = new ExperimenterMessageService() ;
+        Map<Class<? extends DataObject>, Collection<IMDMessageListener>> listenerMapping = new HashMap<Class<? extends DataObject>, Collection<IMDMessageListener>>();
+        Collection<IMDMessageListener> existingValues = new ArrayList<IMDMessageListener>();
+        existingValues.add(objEms);
+        listenerMapping.put(ExperimenterMessage.class, existingValues);
+        connectionConductor.setListenerMapping(listenerMapping);
+        ExperimenterMessageBuilder builder1 = new ExperimenterMessageBuilder();
+        builder1.setExperimenter(84L).setExpType(4L);
+        connectionConductor.onExperimenterMessage(builder1.build());
+        Assert.assertEquals(1, experimenterMessageCounter);
+        builder1.setExperimenter(85L).setExpType(4L);
+        connectionConductor.onExperimenterMessage(builder1.build());
+        Assert.assertEquals(2, experimenterMessageCounter);
+    }
+
 }
index d4074d13b64d2983ab071b2fc99d4a9c2d1137e9..88aab1cf1cb2cb47e4a8c2e621f81e2f9fb159a7 100644 (file)
@@ -2,6 +2,7 @@ package org.opendaylight.openflowplugin.openflow.md.core.session;
 
 import java.math.BigInteger;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -36,7 +37,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatus;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetAsyncInput;
@@ -230,6 +233,54 @@ class MockSessionContext implements SessionContext {
         return null;
     }
 
+    @Override
+    public Map<Long, Port> getPhysicalPorts() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Set<Long> getPorts() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Port getPhysicalPort(Long portNumber) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Boolean getPortBandwidth(Long portNumber) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean isPortEnabled(long portNumber) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean isPortEnabled(Port port) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public List<Port> getEnabledPorts() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void processPortStatusMsg(PortStatus arg0) {
+        // TODO Auto-generated method stub
+
+    }
+
 }
 
 class MockConnectionConductor implements ConnectionConductor {