import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.codehaus.jackson.map.ObjectMapper;
import org.opendaylight.controller.connectionmanager.IConnectionManager;
import org.opendaylight.controller.forwarding.staticrouting.IForwardingStaticRouting;
import org.opendaylight.controller.forwarding.staticrouting.StaticRouteConfig;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
for (NodeConnector nodeConnector : nodeConnectorSet) {
String nodeConnectorNumberToStr = nodeConnector.getID().toString();
Name ncName = ((Name) switchManager.getNodeConnectorProp(nodeConnector, Name.NamePropName));
- Config portStatus = ((Config) switchManager.getNodeConnectorProp(nodeConnector,
+ Config portConfig = ((Config) switchManager.getNodeConnectorProp(nodeConnector,
Config.ConfigPropName));
State portState = ((State) switchManager.getNodeConnectorProp(nodeConnector,
State.StatePropName));
String nodeConnectorName = (ncName != null) ? ncName.getValue() : "";
nodeConnectorName += " (" + nodeConnector.getID() + ")";
- if (portStatus != null) {
- if (portStatus.getValue() == Config.ADMIN_UP) {
- if (portState.getValue() == State.EDGE_UP) {
+ if (portConfig != null) {
+ if (portConfig.getValue() == Config.ADMIN_UP) {
+ if (portState != null && portState.getValue() == State.EDGE_UP) {
nodeConnectorName = "<span class='admin-up'>" + nodeConnectorName + "</span>";
- } else if (portState.getValue() == State.EDGE_DOWN) {
+ } else if (portState == null || portState.getValue() == State.EDGE_DOWN) {
nodeConnectorName = "<span class='edge-down'>" + nodeConnectorName + "</span>";
}
- } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
+ } else if (portConfig.getValue() == Config.ADMIN_DOWN) {
nodeConnectorName = "<span class='admin-down'>" + nodeConnectorName + "</span>";
}
}
Set<Node> nodes = connectionManager.getLocalNodes();
List<NodeJsonBean> result = new LinkedList<NodeJsonBean>();
+ if (nodes == null) {
+ return result;
+ }
for (Node node : nodes) {
Description descriptionProperty = (Description) switchManager.getNodeProp(node, "description");
- String description = descriptionProperty.getValue();
+ String description = node.toString();
+ if (descriptionProperty != null) {
+ description = descriptionProperty.getValue();
+ }
NodeJsonBean nodeBean = new NodeJsonBean();
nodeBean.setNodeId(node.getNodeIDString());
nodeBean.setNodeType(node.getType());
return result;
}
- @RequestMapping(value = "/connect/{nodeId}", method = RequestMethod.POST)
+ @RequestMapping(value = "/connect/{nodeId:.+}", method = RequestMethod.POST)
@ResponseBody
public Status addNode(HttpServletRequest request, @PathVariable("nodeId") String nodeId,
@RequestParam(required = true) String ipAddress, @RequestParam(required = true) String port,
return new Status(StatusCode.SUCCESS);
}
- @RequestMapping(value = "/disconnect/{nodeId}", method = RequestMethod.POST)
+ @RequestMapping(value = "/disconnect/{nodeId:.+}", method = RequestMethod.POST)
@ResponseBody
public Status removeNode(HttpServletRequest request, @PathVariable("nodeId") String nodeId,
@RequestParam(required = true) String nodeType) {
return "forward:" + "/";
}
-}
\ No newline at end of file
+}