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;
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;
import org.opendaylight.controller.sal.authorization.UserLevel;
import org.opendaylight.controller.sal.core.Config;
+import org.opendaylight.controller.sal.core.Description;
+import org.opendaylight.controller.sal.core.ForwardingMode;
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.Property;
+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;
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;
String userName = request.getUserPrincipal().getName();
Privilege privilege = DaylightWebUtil.getContainerPrivilege(userName, containerName, this);
- ISwitchManager switchManager = (ISwitchManager) ServiceHelper
- .getInstance(ISwitchManager.class, containerName, this);
+ ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName,
+ this);
List<Map<String, String>> nodeData = new ArrayList<Map<String, String>>();
if (switchManager != null && privilege != Privilege.NONE) {
for (Switch device : switchManager.getNetworkDevices()) {
HashMap<String, String> nodeDatum = new HashMap<String, String>();
Node node = device.getNode();
- Tier tier = (Tier) switchManager.getNodeProp(node,
- Tier.TierPropName);
-
+ Tier tier = (Tier) switchManager.getNodeProp(node, Tier.TierPropName);
nodeDatum.put("containerName", containerName);
- nodeDatum.put("nodeName",
- switchManager.getNodeDescription(node));
+ Description description = (Description) switchManager.getNodeProp(node, Description.propertyName);
+ String desc = (description == null) ? "" : description.getValue();
+ nodeDatum.put("nodeName", desc);
nodeDatum.put("nodeId", node.toString());
- int tierNumber = (tier == null) ? TierHelper.unknownTierNumber
- : tier.getValue();
- nodeDatum.put("tierName", TierHelper.getTierName(tierNumber)
- + " (Tier-" + tierNumber + ")");
+ int tierNumber = (tier == null) ? TierHelper.unknownTierNumber : tier.getValue();
+ nodeDatum.put("tierName", TierHelper.getTierName(tierNumber) + " (Tier-" + tierNumber + ")");
nodeDatum.put("tier", tierNumber + "");
- SwitchConfig sc = switchManager.getSwitchConfig(device
- .getNode().toString());
- String modeStr = (sc != null) ? sc.getMode() : "0";
+ String modeStr = "0";
+ ForwardingMode mode = (ForwardingMode) switchManager.getNodeProp(node, ForwardingMode.name);
+ if (mode != null) {
+ modeStr = String.valueOf(mode.getValue());
+ }
nodeDatum.put("mode", modeStr);
nodeDatum.put("json", gson.toJson(nodeDatum));
- nodeDatum.put("mac", HexEncode.bytesToHexString(device
- .getDataLayerAddress()));
+ nodeDatum.put("mac", HexEncode.bytesToHexString(device.getDataLayerAddress()));
StringBuffer sb1 = new StringBuffer();
- Set<NodeConnector> nodeConnectorSet = device
- .getNodeConnectors();
+ Set<NodeConnector> nodeConnectorSet = device.getNodeConnectors();
if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
Map<Short, String> portList = new HashMap<Short, String>();
List<String> intfList = new ArrayList<String>();
for (NodeConnector nodeConnector : nodeConnectorSet) {
- String nodeConnectorNumberToStr = nodeConnector.getID()
- .toString();
- Name ncName = ((Name) switchManager
- .getNodeConnectorProp(nodeConnector,
- Name.NamePropName));
+ String nodeConnectorNumberToStr = nodeConnector.getID().toString();
+ Name ncName = ((Name) switchManager.getNodeConnectorProp(nodeConnector, Name.NamePropName));
Config portStatus = ((Config) switchManager
.getNodeConnectorProp(nodeConnector,
Config.ConfigPropName));
+ State portState = ((State) switchManager
+ .getNodeConnectorProp(nodeConnector,
+ State.StatePropName));
String nodeConnectorName = (ncName != null) ? ncName
.getValue() : "";
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>";
}
}
try {
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
- SwitchConfig cfg = new SwitchConfig(nodeId, nodeName, tier,
- operationMode);
- switchManager.updateSwitchConfig(cfg);
- resultBean.setStatus(true);
- resultBean.setMessage("Updated node information successfully");
+ Map<String, Property> nodeProperties = new HashMap<String, Property>();
+ Property desc = new Description(nodeName);
+ nodeProperties.put(desc.getName(), desc);
+ Property nodeTier = new Tier(Integer.parseInt(tier));
+ nodeProperties.put(nodeTier.getName(), nodeTier);
+ if (containerName.equals(GlobalConstants.DEFAULT.toString())) {
+ Property mode = new ForwardingMode(Integer.parseInt(operationMode));
+ nodeProperties.put(mode.getName(), mode);
+ }
+ SwitchConfig cfg = new SwitchConfig(nodeId, nodeProperties);
+ Status result = switchManager.updateNodeConfig(cfg);
+ if (!result.isSuccess()) {
+ resultBean.setStatus(false);
+ resultBean.setMessage(result.getDescription());
+ } else {
+ resultBean.setStatus(true);
+ resultBean.setMessage("Updated node information successfully");
+ }
} catch (Exception e) {
resultBean.setStatus(false);
resultBean.setMessage("Error updating node information. "
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
SubnetConfig cfgObject = new SubnetConfig(gatewayName,
- gatewayIPAddress, new ArrayList<String>());
+ gatewayIPAddress, new HashSet<String>());
Status result = switchManager.addSubnet(cfgObject);
if (result.isSuccess()) {
resultBean.setStatus(true);
.getInstance(ISwitchManager.class, containerName, this);
String description = "";
if (switchManager != null) {
- description = switchManager.getNodeDescription(Node
- .fromString(nodeId));
+ Description desc = (Description) switchManager.getNodeProp(Node.fromString(nodeId), Description.propertyName);
+ if(desc != null) {
+ description = desc.getValue();
+ }
}
return (description.isEmpty() || description.equalsIgnoreCase("none")) ? nodeId
: description;