X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fweb%2Fdevices%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fdevices%2Fweb%2FDevices.java;h=781242a969b0a0f5964a7223672e1b08a74f60fb;hp=ca1dd971378e490b6e096521071d622fe985a38d;hb=b919fb3aefb42e1207d757e8bb6386e8251e479a;hpb=18a0612ed336b6499956fb15e65da295cb4b899d diff --git a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java index ca1dd97137..781242a969 100644 --- a/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java +++ b/opendaylight/web/devices/src/main/java/org/opendaylight/controller/devices/web/Devices.java @@ -10,6 +10,7 @@ package org.opendaylight.controller.devices.web; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -115,7 +116,14 @@ public class Devices implements IDaylightWeb { nodeDatum.put("tierName", TierHelper.getTierName(tierNumber) + " (Tier-" + tierNumber + ")"); nodeDatum.put("tier", tierNumber + ""); String modeStr = "0"; - ForwardingMode mode = (ForwardingMode) switchManager.getNodeProp(node, ForwardingMode.name); + ForwardingMode mode = null; + if (!containerName.equals(GlobalConstants.DEFAULT.toString())) { + ISwitchManager switchManagerDefault = (ISwitchManager) ServiceHelper.getInstance( + ISwitchManager.class, GlobalConstants.DEFAULT.toString(), this); + mode = (ForwardingMode) switchManagerDefault.getNodeProp(node, ForwardingMode.name); + } else { + mode = (ForwardingMode) switchManager.getNodeProp(node, ForwardingMode.name); + } if (mode != null) { modeStr = String.valueOf(mode.getValue()); } @@ -248,6 +256,7 @@ public class Devices implements IDaylightWeb { } else { resultBean.setStatus(true); resultBean.setMessage("Updated node information successfully"); + DaylightWebUtil.auditlog("Node", userName, "updated", nodeId + " to "+ nodeName, containerName); } } catch (Exception e) { resultBean.setStatus(false); @@ -330,6 +339,7 @@ public class Devices implements IDaylightWeb { if (addStaticRouteResult.isSuccess()) { result.setStatus(true); result.setMessage("Static Route saved successfully"); + DaylightWebUtil.auditlog("Static Route", userName, "added", routeName, containerName); } else { result.setStatus(false); result.setMessage(addStaticRouteResult.getDescription()); @@ -373,6 +383,7 @@ public class Devices implements IDaylightWeb { resultBean.setMessage(result.getDescription()); break; } + DaylightWebUtil.auditlog("Static Route", userName, "removed", route, containerName); } } catch (Exception e) { resultBean.setStatus(false); @@ -438,11 +449,12 @@ public class Devices implements IDaylightWeb { ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, containerName, this); SubnetConfig cfgObject = new SubnetConfig(gatewayName, - gatewayIPAddress, new ArrayList()); + gatewayIPAddress, new HashSet()); Status result = switchManager.addSubnet(cfgObject); if (result.isSuccess()) { resultBean.setStatus(true); resultBean.setMessage("Added gateway address successfully"); + DaylightWebUtil.auditlog("Subnet Gateway", userName, "added", gatewayName, containerName); } else { resultBean.setStatus(false); resultBean.setMessage(result.getDescription()); @@ -483,6 +495,7 @@ public class Devices implements IDaylightWeb { resultBean.setMessage(result.getDescription()); break; } + DaylightWebUtil.auditlog("Subnet Gateway", userName, "removed", subnet, containerName); } } catch (Exception e) { resultBean.setStatus(false); @@ -518,6 +531,7 @@ public class Devices implements IDaylightWeb { resultBean.setStatus(true); resultBean .setMessage("Added ports to subnet gateway address successfully"); + DaylightWebUtil.auditlog("Ports to Subnet Gateway", userName, "added",nodeId+"/"+ ports, containerName); } else { resultBean.setStatus(false); resultBean.setMessage(result.getDescription()); @@ -556,6 +570,7 @@ public class Devices implements IDaylightWeb { resultBean.setStatus(true); resultBean .setMessage("Deleted port from subnet gateway address successfully"); + DaylightWebUtil.auditlog("Ports from Subnet Gateway", userName, "removed", nodePort, containerName); } else { resultBean.setStatus(false); resultBean.setMessage(result.getDescription()); @@ -621,7 +636,7 @@ public class Devices implements IDaylightWeb { @RequestMapping(value = "/nodeports") @ResponseBody - public Map getNodePorts(HttpServletRequest request, + public List getNodePorts(HttpServletRequest request, @RequestParam(required = false) String container) { String containerName = (container == null) ? GlobalConstants.DEFAULT .toString() : container; @@ -632,18 +647,16 @@ public class Devices implements IDaylightWeb { return null; } - ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, containerName, this); if (switchManager == null) { return null; } - - Map nodes = new HashMap(); - Map port; + List nodeJsonBeans = new ArrayList(); for (Switch node : switchManager.getNetworkDevices()) { - port = new HashMap(); // new port + NodeJsonBean nodeJsonBean = new NodeJsonBean(); + List port = new ArrayList(); Set nodeConnectorSet = node.getNodeConnectors(); if (nodeConnectorSet != null) { @@ -651,15 +664,17 @@ public class Devices implements IDaylightWeb { String nodeConnectorName = ((Name) switchManager .getNodeConnectorProp(nodeConnector, Name.NamePropName)).getValue(); - port.put((Short) nodeConnector.getID(), nodeConnectorName + port.add(nodeConnectorName + "(" + nodeConnector.getID() + ")"); } } - - nodes.put(node.getNode().toString(), port); + nodeJsonBean.setNodeId(node.getNode().toString()); + nodeJsonBean.setNodeName(getNodeDesc(node.getNode().toString(), containerName)); + nodeJsonBean.setNodePorts(port); + nodeJsonBeans.add(nodeJsonBean); } - return nodes; + return nodeJsonBeans; } @RequestMapping(value = "/spanPorts/add", method = RequestMethod.GET) @@ -687,6 +702,7 @@ public class Devices implements IDaylightWeb { if (result.isSuccess()) { resultBean.setStatus(true); resultBean.setMessage("SPAN Port added successfully"); + DaylightWebUtil.auditlog("SPAN Port", userName, "added", cfgObject.getNodeId(), containerName); } else { resultBean.setStatus(false); resultBean.setMessage(result.getDescription()); @@ -732,6 +748,7 @@ public class Devices implements IDaylightWeb { resultBean.setMessage(result.getDescription()); break; } + DaylightWebUtil.auditlog("SPAN Port", userName, "removed", cfgObject.getNodeId(), containerName); } } } catch (Exception e) {