Fix for Bug 262 - goes with controller Gerrit3929 30/3930/1
authorEd Warnicke <eaw@cisco.com>
Thu, 26 Dec 2013 01:48:22 +0000 (17:48 -0800)
committerEd Warnicke <eaw@cisco.com>
Thu, 26 Dec 2013 01:48:22 +0000 (17:48 -0800)
Needed to fix from http://git.opendaylight.org/gerrit/3929

Change-Id: Ibd5873f79482d6e23b9733f4a67b01db71ec9077
Signed-off-by: Ed Warnicke <eaw@cisco.com>
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/PortConvertor.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/lldp/LLDPSpeakerPopListener.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/PortTranslatorUtil.java

index 4062221050795a5e91375d9ce67cf633a8e7403b..f4f8e78ec424f85e9603ef0f7c8263686ea1525a 100644 (file)
@@ -128,11 +128,11 @@ public final class PortConvertor {
         boolean isBlocked = false; // (1),
         boolean isLive = false; // (2);
 
-        if (state.getIntValue() == 0) {
+        if (state.isLinkDown()) {
             isLinkDown = true;
-        } else if (state.getIntValue() == 1) {
+        } else if (state.isBlocked()) {
             isBlocked = true;
-        } else if (state.getIntValue() == 2) {
+        } else if (state.isLive()) {
             isLive = true;
         }
         portState = new PortState(isLinkDown, isBlocked, isLive);
index abc65038b4090ee2c82c2ea525bd8c854ba2454b..a2c3b73cc63cebe8b7c42ca7b66f0aa97e067031 100644 (file)
@@ -26,7 +26,7 @@ public class LLDPSpeakerPopListener<T> implements PopListener<T> {
                        ncb.addAugmentation(FlowCapableNodeConnector.class, fcncb.build());
                        PortState portState = flowConnector.getState();
                        PortConfig portConfig = flowConnector.getConfiguration();
-                       if((portState ==null || !portState.equals(PortState.LinkDown)) && (portConfig == null || !portConfig.isPORTDOWN())) {
+                       if((portState ==null || !portState.isLinkDown()) && (portConfig == null || !portConfig.isPORTDOWN())) {
                                LLDPSpeaker.getInstance().addNodeConnector(nodeConnectorInstanceId,ncb.build());
                        } else {
                                LLDPSpeaker.getInstance().removeNodeConnector(nodeConnectorInstanceId,ncb.build());
index 9aee3af8b6309b65de05ec6d34a93bcd925a743d..760c43f39f7a6a44a89f954853c6d7ad0cdd6f6f 100644 (file)
@@ -1,5 +1,7 @@
 package org.opendaylight.openflowplugin.openflow.md.util;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
 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.PortState;
@@ -16,18 +18,14 @@ public class PortTranslatorUtil {
         return napf;
     }
 
-    public static  org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState translatePortState(PortState state) {
-        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState nstate = null;
-        if(state != null) {
-            if(state.isBlocked()) {
-                nstate = org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState.Blocked;
-            } else if (state.isLinkDown()) {
-                nstate = org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState.LinkDown;
-            } else if (state.isLive()) {
-                nstate = org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState.Live;
-            }
+    public static  State translatePortState(PortState state) {
+        StateBuilder nstate = new StateBuilder();
+        if(state !=null) {
+            nstate.setBlocked(state.isBlocked());
+            nstate.setLinkDown(state.isLinkDown());
+            nstate.setLive(state.isLive());
         }
-        return nstate;
+        return nstate.build();
     }
 
     public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig translatePortConfig(PortConfig pc) {