addStaticFlowInternal(allowARP, true); // skip validation on internal static flow name
}
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.opendaylight.controller.switchmanager.ISwitchManagerAware#modeChangeNotify(org.opendaylight.controller.sal.core.Node,
+ * boolean)
+ *
+ * This method can be called from within the OSGi framework context,
+ * given the programming operation can take sometime, it not good
+ * pratice to have in it's context operations that can take time,
+ * hence moving off to a different thread for async processing.
+ */
@Override
- public void modeChangeNotify(Node node, boolean proactive) {
- List<FlowConfig> defaultConfigs = new ArrayList<FlowConfig>();
-
- List<String> puntAction = new ArrayList<String>();
- puntAction.add(ActionType.CONTROLLER.toString());
-
- FlowConfig allowARP = new FlowConfig();
- allowARP.setInstallInHw(true);
- allowARP.setName(FlowConfig.INTERNALSTATICFLOWBEGIN + "Punt ARP" + FlowConfig.INTERNALSTATICFLOWEND);
- allowARP.setPriority("1");
- allowARP.setNode(node);
- allowARP.setEtherType("0x" + Integer.toHexString(EtherTypes.ARP.intValue()).toUpperCase());
- allowARP.setActions(puntAction);
- defaultConfigs.add(allowARP);
-
- FlowConfig allowLLDP = new FlowConfig();
- allowLLDP.setInstallInHw(true);
- allowLLDP.setName(FlowConfig.INTERNALSTATICFLOWBEGIN + "Punt LLDP" + FlowConfig.INTERNALSTATICFLOWEND);
- allowLLDP.setPriority("1");
- allowLLDP.setNode(node);
- allowLLDP.setEtherType("0x" + Integer.toHexString(EtherTypes.LLDP.intValue()).toUpperCase());
- allowLLDP.setActions(puntAction);
- defaultConfigs.add(allowLLDP);
-
- List<String> dropAction = new ArrayList<String>();
- dropAction.add(ActionType.DROP.toString());
-
- FlowConfig dropAllConfig = new FlowConfig();
- dropAllConfig.setInstallInHw(true);
- dropAllConfig.setName(FlowConfig.INTERNALSTATICFLOWBEGIN + "Catch-All Drop" + FlowConfig.INTERNALSTATICFLOWEND);
- dropAllConfig.setPriority("0");
- dropAllConfig.setNode(node);
- dropAllConfig.setActions(dropAction);
- defaultConfigs.add(dropAllConfig);
-
- log.info("Forwarding mode for node {} set to {}", node, (proactive ? "proactive" : "reactive"));
- for (FlowConfig fc : defaultConfigs) {
- Status status = (proactive) ? addStaticFlowInternal(fc, false) : removeStaticFlow(fc);
- if (status.isSuccess()) {
- log.info("{} Proactive Static flow: {}", (proactive ? "Installed" : "Removed"), fc.getName());
- } else {
- log.warn("Failed to {} Proactive Static flow: {}", (proactive ? "install" : "remove"), fc.getName());
+ public void modeChangeNotify(final Node node, final boolean proactive) {
+ Callable<Status> modeChangeCallable = new Callable<Status>() {
+ @Override
+ public Status call() throws Exception {
+ List<FlowConfig> defaultConfigs = new ArrayList<FlowConfig>();
+
+ List<String> puntAction = new ArrayList<String>();
+ puntAction.add(ActionType.CONTROLLER.toString());
+
+ FlowConfig allowARP = new FlowConfig();
+ allowARP.setInstallInHw(true);
+ allowARP.setName(FlowConfig.INTERNALSTATICFLOWBEGIN + "Punt ARP" + FlowConfig.INTERNALSTATICFLOWEND);
+ allowARP.setPriority("1");
+ allowARP.setNode(node);
+ allowARP.setEtherType("0x" + Integer.toHexString(EtherTypes.ARP.intValue())
+ .toUpperCase());
+ allowARP.setActions(puntAction);
+ defaultConfigs.add(allowARP);
+
+ FlowConfig allowLLDP = new FlowConfig();
+ allowLLDP.setInstallInHw(true);
+ allowLLDP.setName(FlowConfig.INTERNALSTATICFLOWBEGIN + "Punt LLDP" + FlowConfig.INTERNALSTATICFLOWEND);
+ allowLLDP.setPriority("1");
+ allowLLDP.setNode(node);
+ allowLLDP.setEtherType("0x" + Integer.toHexString(EtherTypes.LLDP.intValue())
+ .toUpperCase());
+ allowLLDP.setActions(puntAction);
+ defaultConfigs.add(allowLLDP);
+
+ List<String> dropAction = new ArrayList<String>();
+ dropAction.add(ActionType.DROP.toString());
+
+ FlowConfig dropAllConfig = new FlowConfig();
+ dropAllConfig.setInstallInHw(true);
+ dropAllConfig.setName(FlowConfig.INTERNALSTATICFLOWBEGIN + "Catch-All Drop"
+ + FlowConfig.INTERNALSTATICFLOWEND);
+ dropAllConfig.setPriority("0");
+ dropAllConfig.setNode(node);
+ dropAllConfig.setActions(dropAction);
+ defaultConfigs.add(dropAllConfig);
+
+ log.info("Forwarding mode for node {} set to {}", node, (proactive ? "proactive" : "reactive"));
+ for (FlowConfig fc : defaultConfigs) {
+ Status status = (proactive) ? addStaticFlowInternal(fc, false) : removeStaticFlow(fc);
+ if (status.isSuccess()) {
+ log.info("{} Proactive Static flow: {}", (proactive ? "Installed" : "Removed"), fc.getName());
+ } else {
+ log.warn("Failed to {} Proactive Static flow: {}", (proactive ? "install" : "remove"),
+ fc.getName());
+ }
+ }
+ return new Status(StatusCode.SUCCESS);
}
- }
+ };
+
+ /*
+ * Execute the work outside the caller context, this could be an
+ * expensive operation and we don't want to block the caller for it.
+ */
+ this.executor.submit(modeChangeCallable);
}
/**
org.opendaylight.controller.usermanager,
org.opendaylight.controller.web,
com.google.gson,
+ com.google.gson.reflect,
javax.annotation,
javax.naming,
javax.servlet,
package org.opendaylight.controller.devices.web;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.springframework.web.bind.annotation.ResponseBody;
import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
@Controller
@RequestMapping("/")
// Add switch portName value (non-configuration field)
config.put("nodeName",
getNodeDesc(config_data.get("nodeId"), containerName));
+ NodeConnector spanPortNodeConnector = NodeConnector.fromString(config_data.get("spanPort"));
+ Name ncName = ((Name) switchManager.getNodeConnectorProp(spanPortNodeConnector,
+ Name.NamePropName));
+ String spanPortName = (ncName != null) ? ncName.getValue() : "";
+ config.put("spanPortName", spanPortName);
}
config.put("json", config_json);
spanConfigs.add(config);
Gson gson = new Gson();
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
- String[] spans = spanPortsToDelete.split("###");
- resultBean.setStatus(true);
- resultBean.setMessage("SPAN Port(s) deleted successfully");
- for (String span : spans) {
- if (!span.isEmpty()) {
- SpanConfig cfgObject = gson
- .fromJson(span, SpanConfig.class);
- Status result = switchManager.removeSpanConfig(cfgObject);
- if (!result.isSuccess()) {
- resultBean.setStatus(false);
- resultBean.setMessage(result.getDescription());
- break;
- }
- DaylightWebUtil.auditlog("SPAN Port", userName, "removed", cfgObject.getNodeId(), containerName);
+ Type collectionType = new TypeToken<List<SpanPortJsonBean>>() {}.getType();
+ List<SpanPortJsonBean> jsonBeanList = gson.fromJson(spanPortsToDelete, collectionType);
+ for (SpanPortJsonBean jsonBean : jsonBeanList) {
+ SpanConfig cfgObject = gson
+ .fromJson(gson.toJson(jsonBean), SpanConfig.class);
+ Status result = switchManager.removeSpanConfig(cfgObject);
+ if (!result.isSuccess()) {
+ resultBean.setStatus(false);
+ resultBean.setMessage(result.getDescription());
+ break;
}
+ DaylightWebUtil.auditlog("SPAN Port", userName, "removed", cfgObject.getNodeId(), containerName);
}
+ resultBean.setStatus(true);
+ resultBean.setMessage("SPAN Port(s) deleted successfully");
} catch (Exception e) {
resultBean.setStatus(false);
resultBean.setMessage("Error occurred while deleting span port. "
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.devices.web;
+
+public class SpanPortJsonBean {
+
+ private String nodeId;
+ private String spanPort;
+
+ public String getNodeId() {
+ return nodeId;
+ }
+
+ public void setNodeId(String nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ public String getSpanPort() {
+ return spanPort;
+ }
+
+ public void setSpanPort(String spanPort) {
+ this.spanPort = spanPort;
+ }
+
+}
return false;
}
checkedCheckBoxes.each(function(index, value) {
- spanPortsToDelete.push(decodeURIComponent(checkedCheckBoxes[index].getAttribute("spanPort")));
+ var spanPortObj = {};
+ spanPortObj['spanPortJson'] = decodeURIComponent(checkedCheckBoxes[index].getAttribute("spanPort"));
+ spanPortObj['spanPortNodeName'] = checkedCheckBoxes[index].getAttribute("spanPortNode");
+ spanPortObj['spanPortPortName'] = checkedCheckBoxes[index].getAttribute("spanPortPort");
+
+ spanPortsToDelete.push(spanPortObj);
});
one.f.switchmanager.spanPortConfig.modal.removeMultiple.dialog(spanPortsToDelete);
});
// bind remove rule button
$('#'+one.f.switchmanager.spanPortConfig.id.modal.remove, $modal).click(this, function(e) {
var requestData = {};
- var spanPorts="";
- $(spanPortsToDelete).each(function(){
- spanPorts = spanPorts + "###" + this.toString();
+ var spanPorts = [];
+ $(spanPortsToDelete).each(function(index, spanPort) {
+ spanPorts.push(JSON.parse(spanPort.spanPortJson));
});
- requestData["spanPortsToDelete"] = spanPorts.slice(3,spanPorts.length);
-
+ requestData["spanPortsToDelete"] = JSON.stringify(spanPorts);
+
var url = one.f.switchmanager.rootUrl + "/spanPorts/delete";
one.f.switchmanager.spanPortConfig.ajax.main(url, requestData, function(response) {
$modal.modal('hide');
var p = 'Remove the following Span Port(s)?';
//creata a BS label for each rule and append to list
- var spanPortList = JSON.parse("["+spanPortToDelete.toString()+"]");
- $(spanPortList).each(function(){
+ $(spanPortToDelete).each(function(index, spanPortItem) {
var $span = $(document.createElement('span'));
- $span.append(this.nodeId+"-"+this.spanPort);
+ $span.append(this.spanPortNodeName+"-"+this.spanPortPortName);
p += '<br/>' + $span[0].outerHTML;
});
$p.append(p);
sortable: true
},
{
- property: 'spanPort',
+ property: 'spanPortName',
label: 'SPAN Port',
sortable: true
},
data: data.nodeData,
formatter: function(items) {
$.each(items, function(index, item) {
- item["selector"] = '<input type="checkbox" class="spanPortConfig" spanPort=' + encodeURIComponent(item["json"]) + '></input>';
+ item["selector"] = '<input type="checkbox" class="spanPortConfig" spanPort=' + encodeURIComponent(item["json"]) + ' spanPortNode=' + item["nodeName"] + ' spanPortPort=' + item["spanPortName"] + '></input>';
});
},
delay: 0
},
flows: function(nodeId) {
try {
+ if(one.f.troubleshooting === undefined){
+ return;
+ }
clearTimeout(one.f.troubleshooting.existingNodes.registry.refreshTimer);
$.getJSON(one.main.constants.address.prefix + "/troubleshoot/flowStats?nodeId=" + nodeId, function(content) {
$rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();
},
ports: function(nodeId) {
try {
+ if(one.f.troubleshooting === undefined){
+ return;
+ }
clearTimeout(one.f.troubleshooting.existingNodes.registry.refreshTimer);
$.getJSON(one.main.constants.address.prefix + "/troubleshoot/portStats?nodeId=" + nodeId, function(content) {
$rightBottomDashlet = one.f.troubleshooting.rightBottomDashlet.get();