Add operational port status
[controller.git] / opendaylight / web / devices / src / main / java / org / opendaylight / controller / devices / web / Devices.java
index 534c2c293c9c9fecc9bf8467fc74d0e237261ac9..34aef8af9f1c15989c0e0dedb966a9e31d7f71ee 100644 (file)
@@ -16,17 +16,11 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentMap;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.codehaus.jackson.map.ObjectMapper;
-import org.opendaylight.controller.web.DaylightWebUtil;
-import org.opendaylight.controller.web.IDaylightWeb;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
 import org.opendaylight.controller.forwarding.staticrouting.IForwardingStaticRouting;
 import org.opendaylight.controller.forwarding.staticrouting.StaticRouteConfig;
 import org.opendaylight.controller.sal.authorization.Privilege;
@@ -35,6 +29,7 @@ import org.opendaylight.controller.sal.core.Config;
 import org.opendaylight.controller.sal.core.Name;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.core.State;
 import org.opendaylight.controller.sal.core.Tier;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
 import org.opendaylight.controller.sal.utils.HexEncode;
@@ -46,6 +41,13 @@ import org.opendaylight.controller.switchmanager.SpanConfig;
 import org.opendaylight.controller.switchmanager.SubnetConfig;
 import org.opendaylight.controller.switchmanager.Switch;
 import org.opendaylight.controller.switchmanager.SwitchConfig;
+import org.opendaylight.controller.web.DaylightWebUtil;
+import org.opendaylight.controller.web.IDaylightWeb;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import com.google.gson.Gson;
 
@@ -135,6 +137,9 @@ public class Devices implements IDaylightWeb {
                         Config portStatus = ((Config) switchManager
                                 .getNodeConnectorProp(nodeConnector,
                                         Config.ConfigPropName));
+                        State portState = ((State) switchManager
+                                .getNodeConnectorProp(nodeConnector,
+                                        State.StatePropName));
 
                         String nodeConnectorName = (ncName != null) ? ncName
                                 .getValue() : "";
@@ -142,10 +147,15 @@ public class Devices implements IDaylightWeb {
 
                         if (portStatus != null) {
                             if (portStatus.getValue() == Config.ADMIN_UP) {
-                                nodeConnectorName = "<span style='color:green;'>"
-                                        + nodeConnectorName + "</span>";
+                                if (portState.getValue() == State.EDGE_UP) {
+                                    nodeConnectorName = "<span class='admin-up'>"
+                                            + nodeConnectorName + "</span>";
+                                } else if (portState.getValue() == State.EDGE_DOWN) {
+                                    nodeConnectorName = "<span class='edge-down'>"
+                                            + nodeConnectorName + "</span>";
+                                }
                             } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
-                                nodeConnectorName = "<span style='color:red;'>"
+                                nodeConnectorName = "<span class='admin-down'>"
                                         + nodeConnectorName + "</span>";
                             }
                         }