<module>../../configuration/implementation</module>
<module>../../routing/dijkstra_implementation</module>
<module>../../arphandler</module>
- <module>../../forwardingrulesmanager</module>
+ <module>../../forwardingrulesmanager/api</module>
+ <module>../../forwardingrulesmanager/implementation</module>
<module>../../hosttracker</module>
<module>../../containermanager/api</module>
<module>../../containermanager/implementation</module>
<groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.4.0-SNAPSHOT</version>
- <relativePath>../commons/opendaylight</relativePath>
+ <relativePath>../../commons/opendaylight</relativePath>
</parent>
<groupId>org.opendaylight.controller</groupId>
org.eclipse.osgi.framework.console,
org.osgi.framework
</Import-Package>
- <Bundle-Activator>
- org.opendaylight.controller.forwardingrulesmanager.internal.Activator
- </Bundle-Activator>
- <Require-Bundle>
+ <Require-Bundle>
org.opendaylight.controller.hosttracker
- </Require-Bundle>
+ </Require-Bundle>
<Service-Component>
</Service-Component>
</instructions>
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
private String status;
/*
- * The order of the object data defined below is used directly in the UI built using JSP.
- * Hence try to keep the order in a more logical way.
+ * The order of the object data defined below is used directly in the UI
+ * built using JSP. Hence try to keep the order in a more logical way.
*/
@XmlElement
private String installInHw;
public void setInstallInHw(boolean inHw) {
installInHw = inHw ? "true" : "false";
}
-
+
public String getInstallInHw() {
- return installInHw;
+ return installInHw;
}
public boolean isInternalFlow() {
// Controller generated static flows have name starting with "**"
- return (this.name != null && this.name.startsWith("**"));
+ return (this.name != null && this.name.startsWith("**"));
}
public String getName() {
}
}
- log.debug("Get Nexthop address = {} Type = {}", address, setNHType.toString());
+ log.debug("Get Nexthop address = " + address + " Type = "
+ + setNHType.toString());
if (setNHType == SetNextHopType.RESOLVE_L2RW) {
try {
return InetAddress.getByName(address);
} catch (Exception e) {
- log
- .debug("Exception during nextHopAddress resolution : ",
- e);
+ log.debug("Exception during nextHopAddress resolution : "
+ + e.getMessage());
}
}
}
.compile("([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}");
Matcher mm = macPattern.matcher(mac);
if (!mm.matches()) {
- log
- .debug(
- "Ethernet address {} is not valid. Example: 00:05:b9:7c:81:5f",
- mac);
+ log.debug(
+ "Ethernet address {} is not valid. Example: 00:05:b9:7c:81:5f",
+ mac);
return false;
}
return true;
}
if (sw == null) {
- log
- .debug("switch info is not available. Skip checking if port is part of a switch or not.");
+ log.debug("switch info is not available. Skip checking if port is part of a switch or not.");
return true;
}
// Check against each container's flow
Flow flow = this.getFlow();
- // Configuration is rejected if it conflicts with _all_ the container flows
+ // Configuration is rejected if it conflicts with _all_ the container
+ // flows
for (ContainerFlow cFlow : cFlowList) {
if (cFlow.allowsFlow(flow)) {
- log
- .trace("Config is congruent with at least one container flow");
+ log.trace("Config is congruent with at least one container flow");
return false;
}
}
}
}
if (sw == null) {
- resultStr
- .append(String.format("Node %s not found", node));
+ resultStr.append(String.format("Node %s not found", node));
return false;
}
} else {
if (isPortValid(sw, port) == false) {
resultStr
.append(String
- .format(
- "Ingress port %d is not valid for the Switch",
+ .format("Ingress port %d is not valid for the Switch",
port));
if ((container != null)
&& !container.getName().equals(
if ((dlSrc != null) && !isL2AddressValid(dlSrc)) {
resultStr
.append(String
- .format(
- "Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f",
+ .format("Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f",
dlSrc));
return false;
}
if ((dlDst != null) && !isL2AddressValid(dlDst)) {
resultStr
.append(String
- .format(
- "Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f",
+ .format("Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f",
dlDst));
return false;
}
if (isPortValid(sw, port) == false) {
resultStr
.append(String
- .format(
- "Output port %d is not valid for this switch",
+ .format("Output port %d is not valid for this switch",
port));
if ((container != null)
&& !container.getName().equals(
if (sstr.matches()) {
if (!NetUtils.isIPv4AddressValid(sstr.group(1))) {
resultStr.append(String.format(
- "IP source address %s is not valid", sstr
- .group(1)));
+ "IP source address %s is not valid",
+ sstr.group(1)));
return false;
}
continue;
&& !isVlanPriorityValid(sstr.group(1))) {
resultStr
.append(String
- .format(
- "Vlan priority %s is not in the range 0 - 7",
+ .format("Vlan priority %s is not in the range 0 - 7",
sstr.group(1)));
return false;
}
&& !isL2AddressValid(sstr.group(1))) {
resultStr
.append(String
- .format(
- "Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f",
+ .format("Ethernet source address %s is not valid. Example: 00:05:b9:7c:81:5f",
sstr.group(1)));
return false;
}
&& !isL2AddressValid(sstr.group(1))) {
resultStr
.append(String
- .format(
- "Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f",
+ .format("Ethernet destination address %s is not valid. Example: 00:05:b9:7c:81:5f",
sstr.group(1)));
return false;
}
&& !isTOSBitsValid(sstr.group(1))) {
resultStr
.append(String
- .format(
- "IP ToS bits %s is not in the range 0 - 63",
+ .format("IP ToS bits %s is not in the range 0 - 63",
sstr.group(1)));
return false;
}
&& !isTpPortValid(sstr.group(1))) {
resultStr
.append(String
- .format(
- "Transport destination port %s is not valid",
+ .format("Transport destination port %s is not valid",
sstr.group(1)));
return false;
}
return false;
}
} catch (NumberFormatException e) {
- resultStr.append(String.format("Invalid number format %s", e
- .getMessage()));
+ resultStr.append(String.format("Invalid number format %s",
+ e.getMessage()));
return false;
}
}
public FlowEntry getFlowEntry() {
- return new FlowEntry(FlowConfig.staticFlowsGroup, this.name, this
- .getFlow(), this.getNode());
+ return new FlowEntry(FlowConfig.staticFlowsGroup, this.name,
+ this.getFlow(), this.getNode());
}
public Flow getFlow() {
Match match = new Match();
if (this.ingressPort != null) {
- match.setField(MatchType.IN_PORT, NodeConnectorCreator
- .createOFNodeConnector(Short.parseShort(ingressPort),
- getNode()));
+ match.setField(
+ MatchType.IN_PORT,
+ NodeConnectorCreator.createOFNodeConnector(
+ Short.parseShort(ingressPort), getNode()));
}
if (this.dlSrc != null) {
- match.setField(MatchType.DL_SRC, HexEncode
- .bytesFromHexString(this.dlSrc));
+ match.setField(MatchType.DL_SRC,
+ HexEncode.bytesFromHexString(this.dlSrc));
}
if (this.dlDst != null) {
- match.setField(MatchType.DL_DST, HexEncode
- .bytesFromHexString(this.dlDst));
+ match.setField(MatchType.DL_DST,
+ HexEncode.bytesFromHexString(this.dlDst));
}
if (this.etherType != null) {
match.setField(MatchType.DL_TYPE, Integer.decode(etherType)
match.setField(MatchType.DL_VLAN, Short.parseShort(this.vlanId));
}
if (this.vlanPriority != null) {
- match.setField(MatchType.DL_VLAN_PR, Byte
- .parseByte(this.vlanPriority));
+ match.setField(MatchType.DL_VLAN_PR,
+ Byte.parseByte(this.vlanPriority));
}
if (this.nwSrc != null) {
String parts[] = this.nwSrc.split("/");
match.setField(MatchType.NW_DST, ip, mask);
}
if (this.protocol != null) {
- match.setField(MatchType.NW_PROTO, IPProtocols
- .getProtocolNumberByte(this.protocol));
+ match.setField(MatchType.NW_PROTO,
+ IPProtocols.getProtocolNumberByte(this.protocol));
}
if (this.tosBits != null) {
match.setField(MatchType.NW_TOS, Byte.parseByte(this.tosBits));
}
/*
- * Parses the actions string and return the List of SAL Action
- * No syntax check run, as this function will be called when the
- * config validation check has already been performed
+ * Parses the actions string and return the List of SAL Action No syntax
+ * check run, as this function will be called when the config validation
+ * check has already been performed
*/
private List<Action> getActionList() {
List<Action> actionList = new ArrayList<Action>();
if (n.group(1) != null) {
short ofPort = Short.parseShort(n.group(1));
actionList.add(new Output(NodeConnectorCreator
- .createOFNodeConnector(ofPort, this
- .getNode())));
+ .createOFNodeConnector(ofPort,
+ this.getNode())));
}
}
}
ActionType.SET_VLAN_ID.toString() + "=(.*)").matcher(
actiongrp);
if (sstr.matches()) {
- actionList.add(new SetVlanId(Short
- .parseShort(sstr.group(1))));
+ actionList.add(new SetVlanId(
+ Short.parseShort(sstr.group(1))));
continue;
}
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import org.slf4j.LoggerFactory;
/**
- * Represents a flow applications request Forwarding Rules Manager to install
- * on a network node. A FlowEntry is constituted of a flow (match + actions),
- * the target network node, and the flow name. It also includes a group name.
- * For instance the flows constituting a policy all share the same group name.
+ * Represents a flow applications request Forwarding Rules Manager to install on
+ * a network node. A FlowEntry is constituted of a flow (match + actions), the
+ * target network node, and the flow name. It also includes a group name. For
+ * instance the flows constituting a policy all share the same group name.
*/
public class FlowEntry implements Cloneable, Serializable {
protected static final Logger logger = LoggerFactory
/**
* Return the actual Flow contained in this entry
- *
+ *
* @return the flow
*/
public Flow getFlow() {
/**
* Merges the current Flow with the passed Container Flow
- *
- * Note: Container Flow merging is not an injective function.
- * Be m1 and m2 two different matches, and be f() the flow merge
- * function, such that y1 = f(m1) and y2 = f(m2) are the two merged
- * matches, we may have: y1 = y2
- *
- *
+ *
+ * Note: Container Flow merging is not an injective function. Be m1 and m2
+ * two different matches, and be f() the flow merge function, such that y1 =
+ * f(m1) and y2 = f(m2) are the two merged matches, we may have: y1 = y2
+ *
+ *
* @param containerFlow
* @return this merged FlowEntry
*/
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import org.opendaylight.controller.sal.core.Node;
/**
- * The flow database object representing the flow entry to install on
- * the network node. It contains the original flow entry FRM was
- * requested to install, the container flow with which that entry had
- * to be merged and the resultant merged flow entry, which is the
- * one that was eventually installed on the network node
- *
- * Note: If the container flow is null, the install entry will be a clone
- * of the original entry
- *
+ * The flow database object representing the flow entry to install on the
+ * network node. It contains the original flow entry FRM was requested to
+ * install, the container flow with which that entry had to be merged and the
+ * resultant merged flow entry, which is the one that was eventually installed
+ * on the network node
+ *
+ * Note: If the container flow is null, the install entry will be a clone of the
+ * original entry
+ *
*/
public class FlowEntryInstall {
private FlowEntry original;
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
/**
* Interface that describes methods for installing or removing forwarding rules
* and to access to the flows database.
- *
+ *
*/
public interface IForwardingRulesManager {
/**
- * It requests FRM to install the passed Flow Entry. FRM will request
- * the SDN protocol plugin to install the flow on the network node.
- * Based on the result of this operation FRM will update its database
- * accordingly and will return the proper {@code Status} code.
+ * It requests FRM to install the passed Flow Entry. FRM will request the
+ * SDN protocol plugin to install the flow on the network node. Based on the
+ * result of this operation FRM will update its database accordingly and
+ * will return the proper {@code Status} code.
*
- * @param flow the flow entry to install
- * @return the {@code Status} object indicating the result of this action.
- */
+ * @param flow
+ * the flow entry to install
+ * @return the {@code Status} object indicating the result of this action.
+ */
public Status installFlowEntry(FlowEntry flow);
/**
- * It requests FRM to remove the passed Flow Entry. FRM will request
- * the SDN protocol plugin to uninstall the flow from the network node.
- * Based on the result of this operation FRM will update its database
- * accordingly and will return the proper {@code Status} code.
+ * It requests FRM to remove the passed Flow Entry. FRM will request the SDN
+ * protocol plugin to uninstall the flow from the network node. Based on the
+ * result of this operation FRM will update its database accordingly and
+ * will return the proper {@code Status} code.
*
- * @param flow the flow entry to uninstall
+ * @param flow
+ * the flow entry to uninstall
* @return the {@code Status} object indicating the result of this action
*/
public Status uninstallFlowEntry(FlowEntry flow);
/**
* It requests FRM to replace the currently installed Flow Entry with the
- * new one. It is up to the SDN protocol plugin to decide how to convey
- * this message to the network node. It could be a delete + add or a single
- * modify message depending on the SDN protocol specifications
- * If the current flow is equal to the new one it will be a no op and
- * success code is returned.
+ * new one. It is up to the SDN protocol plugin to decide how to convey this
+ * message to the network node. It could be a delete + add or a single
+ * modify message depending on the SDN protocol specifications If the
+ * current flow is equal to the new one it will be a no op and success code
+ * is returned.
*
- * @param current the current flow entry to modify
- * @param newone the new flow entry which will replace the current one
+ * @param current
+ * the current flow entry to modify
+ * @param newone
+ * the new flow entry which will replace the current one
* @return the {@code Status} object indicating the result of this action
*/
public Status modifyFlowEntry(FlowEntry current, FlowEntry newone);
* It requests the FRM to replace the currently installed Flow Entry with
* the new one. The currently installed entry is derived by the Match
* portion of the passed Flow. FRM looks in its database for a previously
- * installed FlowEntry which Match equals the Match of the passed Flow.
- * If it finds it, it will request the SDN protocol plugin to replace the
- * existing flow with the new one on the network node. If it does not
- * find it, it will request plugin to add the new flow. If the passed entry
- * is not valid an error code is returned.
- * If the existing flow is equal to the passed one it will be a no op and
- * success code is returned.
+ * installed FlowEntry which Match equals the Match of the passed Flow. If
+ * it finds it, it will request the SDN protocol plugin to replace the
+ * existing flow with the new one on the network node. If it does not find
+ * it, it will request plugin to add the new flow. If the passed entry is
+ * not valid an error code is returned. If the existing flow is equal to the
+ * passed one it will be a no op and success code is returned.
*
- * @param newone the new flow entry to install
+ * @param newone
+ * the new flow entry to install
* @return the {@code Status} object indicating the result of this action
*/
public Status modifyOrAddFlowEntry(FlowEntry newone);
/**
* Check whether the passed flow entry conflicts with the Container flows
*
- * @param flow the flow entry to test
+ * @param flow
+ * the flow entry to test
* @return true if conflicts, false otherwise
*/
public boolean checkFlowEntryConflict(FlowEntry flow);
/**
- * Returns the list of Flow entries across network nodes which are part of the
- * same flow group, policy
- *
- * @param group the group name
+ * Returns the list of Flow entries across network nodes which are part of
+ * the same flow group, policy
+ *
+ * @param group
+ * the group name
* @return the list of flow entries belonging to the specified group
*/
public List<FlowEntry> getFlowEntriesForGroup(String group);
/**
- * Add a list of output port to the flow with the specified name on the specified network node
- *
- * @param node the network node
- * @param flowName the flow name
- * @param dstPort the list of ports to be added to the flow output actions
+ * Add a list of output port to the flow with the specified name on the
+ * specified network node
+ *
+ * @param node
+ * the network node
+ * @param flowName
+ * the flow name
+ * @param dstPort
+ * the list of ports to be added to the flow output actions
*/
public void addOutputPort(Node node, String flowName,
List<NodeConnector> dstPort);
/**
- * Remove a list of output port from the flow with the specified name on the specified network node
- *
- * @param node the network node
- * @param flowName the flow name
- * @param dstPortthe list of ports to be removed from the flow output actions
+ * Remove a list of output port from the flow with the specified name on the
+ * specified network node
+ *
+ * @param node
+ * the network node
+ * @param flowName
+ * the flow name
+ * @param dstPortthe
+ * list of ports to be removed from the flow output actions
*/
public void removeOutputPort(Node node, String flowName,
List<NodeConnector> dstPort);
/**
- * Replace the current output port in the specified flow with the specified one
- *
- * @param node the network node
- * @param groupName the group name
- * @param flowName the flow name
- * @param dstPort the new output action port
+ * Replace the current output port in the specified flow with the specified
+ * one
+ *
+ * @param node
+ * the network node
+ * @param groupName
+ * the group name
+ * @param flowName
+ * the flow name
+ * @param dstPort
+ * the new output action port
*/
public void replaceOutputPort(Node node, String flowName,
NodeConnector outPort);
/**
* Returns the output port configured on the specified flow
- *
- * @param node the network node
- * @param flowName the flow name
+ *
+ * @param node
+ * the network node
+ * @param flowName
+ * the flow name
* @return the output action port for the specified flow
*/
public NodeConnector getOutputPort(Node node, String flowName);
/**
- * Returns all the troubleshooting information that applications
- * have set along with the policy they have configured through
- * forwarding rules manger.
+ * Returns all the troubleshooting information that applications have set
+ * along with the policy they have configured through forwarding rules
+ * manger.
*
* @return the collection of troubleshooting objects
*/
/**
* Set the troubleshooting information for the policy
- *
- * @param policyname the flow group name
- * @param o the object containing the troubleshooting information
- * @param add true for adding, false for removing
+ *
+ * @param policyname
+ * the flow group name
+ * @param o
+ * the object containing the troubleshooting information
+ * @param add
+ * true for adding, false for removing
*/
public void setTSPolicyData(String policyName, Object o, boolean add);
/**
- * Returns the troubleshooting information that was set for the specified policy
+ * Returns the troubleshooting information that was set for the specified
+ * policy
*
- * @param groupName the flows group name
+ * @param groupName
+ * the flows group name
* @return the troubleshooting info object
*/
public Object getTSPolicyData(String policyName);
/**
- * Returns the specifications of all the flows configured for all the
+ * Returns the specifications of all the flows configured for all the
* switches on the current container
- *
+ *
* @return the list of flow configurations present in the database
*/
public List<FlowConfig> getStaticFlows();
/**
- * Returns the specifications of all the flows configured for
- * the given switch on the current container
- *
- * @param node the network node identifier
- * @return the list of {@code FlowConfig} objects
+ * Returns the specifications of all the flows configured for the given
+ * switch on the current container
+ *
+ * @param node
+ * the network node identifier
+ * @return the list of {@code FlowConfig} objects
*/
public List<FlowConfig> getStaticFlows(Node node);
/**
- * Returns the specification of the flow configured for the given
- * network node on the current container
- *
- * @param name the flow name
- * @param n the netwrok node identifier
+ * Returns the specification of the flow configured for the given network
+ * node on the current container
+ *
+ * @param name
+ * the flow name
+ * @param n
+ * the netwrok node identifier
* @return the {@code FlowConfig} object
*/
public FlowConfig getStaticFlow(String name, Node n);
/**
- * Returns the list of names of flows configured for the given
- * Network node on the current container
- *
- * @param node the network node identifier
+ * Returns the list of names of flows configured for the given Network node
+ * on the current container
+ *
+ * @param node
+ * the network node identifier
* @return the list of flow names
*/
public List<String> getStaticFlowNamesForNode(Node node);
/**
* Returns the list of Node(s) for which a static flow has been configured
- *
+ *
* @return the list of network nodes
*/
public List<Node> getListNodeWithConfiguredFlows();
public Status saveConfig();
/**
- * Add a flow specified by the {@code FlowConfig} object on the current container
+ * Add a flow specified by the {@code FlowConfig} object on the current
+ * container
*
- * @param config the {@code FlowConfig} object representing the static flow
- * @param restore if set to true, the config object validation will be skipped.
- * Used only internally, always set it to false.
+ * @param config
+ * the {@code FlowConfig} object representing the static flow
+ * @param restore
+ * if set to true, the config object validation will be skipped.
+ * Used only internally, always set it to false.
* @return the {@code Status} object indicating the result of this action.
*/
public Status addStaticFlow(FlowConfig config, boolean restore);
/**
- * Remove a flow specified by the {@code FlowConfig} object on the current container
+ * Remove a flow specified by the {@code FlowConfig} object on the current
+ * container
*
- * @param config the {@code FlowConfig} object representing the static flow
+ * @param config
+ * the {@code FlowConfig} object representing the static flow
* @return the {@code Status} object indicating the result of this action
*/
public Status removeStaticFlow(FlowConfig config);
/**
- * Replace the flow identified by the {@code FlowConfig.name} name for
- * the {@code FlowConfig.node} network node with the new flow specified
- * by {@code FlowConfig} object
- *
- * @param config the {@code FlowConfig} object
+ * Replace the flow identified by the {@code FlowConfig.name} name for the
+ * {@code FlowConfig.node} network node with the new flow specified by
+ * {@code FlowConfig} object
+ *
+ * @param config
+ * the {@code FlowConfig} object
* @returnthe {@code Status} object indicating the result of this action
*/
public Status modifyStaticFlow(FlowConfig config);
/**
* Remove the flow specified by name on the passed network node
- *
- * @param name for the static flow
- * @param node on which the flow is attached
+ *
+ * @param name
+ * for the static flow
+ * @param node
+ * on which the flow is attached
* @return the {@code Status} object indicating the result of this action
*/
public Status removeStaticFlow(String name, Node node);
/**
- * Toggle the installation status of the specified configured flow
- * If the flow configuration status is active, this call will
- * change the flow status to inactive and vice-versa
- *
- * @param configObject the {@code FlowConfig} object
+ * Toggle the installation status of the specified configured flow If the
+ * flow configuration status is active, this call will change the flow
+ * status to inactive and vice-versa
+ *
+ * @param configObject
+ * the {@code FlowConfig} object
* @return the {@code Status} object indicating the result of this action
*/
public Status toggleStaticFlowStatus(FlowConfig configObject);
-
+
/**
- * Toggle the installation status of the specified configured flow
- * If the flow configuration status is active, this call will
- * change the flow status to inactive and vice-versa
- *
- * @param name for the static flow
- * @param node on which the flow is attached
+ * Toggle the installation status of the specified configured flow If the
+ * flow configuration status is active, this call will change the flow
+ * status to inactive and vice-versa
+ *
+ * @param name
+ * for the static flow
+ * @param node
+ * on which the flow is attached
* @return the {@code Status} object indicating the result of this action
*/
public Status toggleStaticFlowStatus(String name, Node node);
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
package org.opendaylight.controller.forwardingrulesmanager;
-
/**
- * The interface which describes the methods forwarding rules manager
- * will call for notifying the listeners of policy installation updates.
- *
+ * The interface which describes the methods forwarding rules manager will call
+ * for notifying the listeners of policy installation updates.
+ *
*/
public interface IForwardingRulesManagerAware {
- /**
- * Inform the listeners that a troubleshooting information was
- * added or removed for the specified policy.
- *
- * @param policyName the policy affected
- * @param add true if the troubleshooting information was added, false otherwise
- */
+ /**
+ * Inform the listeners that a troubleshooting information was added or
+ * removed for the specified policy.
+ *
+ * @param policyName
+ * the policy affected
+ * @param add
+ * true if the troubleshooting information was added, false
+ * otherwise
+ */
public void policyUpdate(String policyName, boolean add);
}
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import java.util.Set;
/**
- * PortGroup is a simple data-structure to represent any arbitrary group of ports
- * on a Switch (that is represented using its switch-ID).
- *
- * PortGroup is used by PortGroupProvider application to signal a set of ports that
- * represent a configured PortGroupConfig.
- *
- *
+ * PortGroup is a simple data-structure to represent any arbitrary group of
+ * ports on a Switch (that is represented using its switch-ID).
+ *
+ * PortGroup is used by PortGroupProvider application to signal a set of ports
+ * that represent a configured PortGroupConfig.
+ *
+ *
*/
public class PortGroup {
private long matrixSwitchId;
/**
* PortGroup Constructor using Switch and Ports.
- *
- * @param matrixSwitchId Switch Id that represents an openflow Switch
- * @param ports Set of short values representing openflow port-ids.
+ *
+ * @param matrixSwitchId
+ * Switch Id that represents an openflow Switch
+ * @param ports
+ * Set of short values representing openflow port-ids.
*/
public PortGroup(long matrixSwitchId, Set<Short> ports) {
super();
/**
* PortGroup Constructor using Switch.
- *
- * @param matrixSwitchId Switch-Id that represents an openflow Switch
+ *
+ * @param matrixSwitchId
+ * Switch-Id that represents an openflow Switch
*/
public PortGroup(long matrixSwitchId) {
this.matrixSwitchId = matrixSwitchId;
/**
* Returns the switchId representing the Switch that makes this PortGroup.
- *
+ *
* @return long switchId
*/
public long getMatrixSwitchId() {
/**
* Assigns a Switch to this PortGroup
- *
- * @param matrixSwitchId Switch-Id that represents an openflow Switch
+ *
+ * @param matrixSwitchId
+ * Switch-Id that represents an openflow Switch
*/
public void setMatrixSwitchId(long matrixSwitchId) {
this.matrixSwitchId = matrixSwitchId;
/**
* Returns the Set of Ports that makes this PortGroup.
- *
+ *
* @return Set of short values representing openflow port-ids.
*/
public Set<Short> getPorts() {
/**
* Assigns a set of openflow ports to this PortGroup
- *
- * @param ports Set of short values representing openflow port-ids.
+ *
+ * @param ports
+ * Set of short values representing openflow port-ids.
*/
public void setPorts(Set<Short> ports) {
this.ports = ports;
/**
* Adds a port to this PortGroup
- *
- * @param port Short value of a openflow port.
+ *
+ * @param port
+ * Short value of a openflow port.
*/
public void addPort(short port) {
ports.add(port);
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import org.opendaylight.controller.sal.core.Node;
/**
- * PortGroupChangeListener listens to the PortGroup updates provided by the PortGroupProvider.
- *
- *
+ * PortGroupChangeListener listens to the PortGroup updates provided by the
+ * PortGroupProvider.
+ *
+ *
*/
public interface PortGroupChangeListener {
/**
- * This method is invoked by PortGroupProvider whenever it detects a change in PortGroup
- * membership for a given PortGroupConfig.
- *
- * @param config Port Group Configuration
- * @param portGroupData HashMap of Node id to PortGroup that represents the updated ports as detected by PortGroupProvider.
- * @param add true indicates that the PortGroup is added. False indicates that the PortGroup is removed.
+ * This method is invoked by PortGroupProvider whenever it detects a change
+ * in PortGroup membership for a given PortGroupConfig.
+ *
+ * @param config
+ * Port Group Configuration
+ * @param portGroupData
+ * HashMap of Node id to PortGroup that represents the updated
+ * ports as detected by PortGroupProvider.
+ * @param add
+ * true indicates that the PortGroup is added. False indicates
+ * that the PortGroup is removed.
*/
void portGroupChanged(PortGroupConfig config,
Map<Node, PortGroup> portGroupData, boolean add);
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import java.util.List;
/**
- * PortGroupConfig class represents the User's Configuration with a Opaque Regular Expression
- * String that is parsed and handled by PortGroupProvider.
- *
- * Typically, the opaque matchString will be a Regular Expression String supported by a particular
- * PortGroupProvider based on Customer requirements.
- *
- *
- *
+ * PortGroupConfig class represents the User's Configuration with a Opaque
+ * Regular Expression String that is parsed and handled by PortGroupProvider.
+ *
+ * Typically, the opaque matchString will be a Regular Expression String
+ * supported by a particular PortGroupProvider based on Customer requirements.
+ *
+ *
+ *
*/
public class PortGroupConfig implements Serializable {
private static final long serialVersionUID = 1L;
}
/**
- * Constructor to create a Port Group Configuration using a Group Name and an Opaque
- * String that is managed by PortGroupProvider.
- *
- * @param name Group Name representing a Port Group configuration
- * @param matchString An Opaque String managed by PortGroupProvider
+ * Constructor to create a Port Group Configuration using a Group Name and
+ * an Opaque String that is managed by PortGroupProvider.
+ *
+ * @param name
+ * Group Name representing a Port Group configuration
+ * @param matchString
+ * An Opaque String managed by PortGroupProvider
*/
public PortGroupConfig(String name, String matchString) {
super();
/**
* Returns the user configured PortGroup Configuration name.
- *
+ *
* @return Configuration Name
*/
public String getName() {
/**
* Assigns a name to the configuration
- * @param name configuration name
+ *
+ * @param name
+ * configuration name
*/
public void setName(String name) {
this.name = name;
/**
* Returns the Opaque string
+ *
* @return
*/
public String getMatchString() {
/**
* Assigns an opaque String to the Configuration.
- *
- * @param matchString Opaque string handled by PortGroupProvider
+ *
+ * @param matchString
+ * Opaque string handled by PortGroupProvider
*/
public void setMatchString(String matchString) {
this.matchString = matchString;
}
/**
- * Returns the names of all the configurable fields in PortGroupConfig.
- * This method is typically used by NorthBound apis.
- *
+ * Returns the names of all the configurable fields in PortGroupConfig. This
+ * method is typically used by NorthBound apis.
+ *
* @return List of Field names that can be configured.
*/
public static List<String> getFieldsNames() {
for (Field fld : PortGroupConfig.class.getDeclaredFields()) {
fieldList.add(fld.getName());
}
- //remove static field(s)
+ // remove static field(s)
fieldList.remove(0);
fieldList.remove(0);
}
/**
- * Returns the names of all the configurable fields in PortGroupConfig in human readable format for UI purposes.
- * This method is typically used by Web/UI apis.
- *
- * @return List of Human readable Strings that corresponds to the configurable field names.
+ * Returns the names of all the configurable fields in PortGroupConfig in
+ * human readable format for UI purposes. This method is typically used by
+ * Web/UI apis.
+ *
+ * @return List of Human readable Strings that corresponds to the
+ * configurable field names.
*/
public static List<String> getPrettyFieldsNames() {
List<String> fieldList = new ArrayList<String>();
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
import org.opendaylight.controller.sal.core.Node;
/**
- * PortGroupProvider interface provides all the necessary blueprint for a custom application to implement
- * in order to provide Port Grouping Service. Custom Application that implements this interface will have
- * to handle the opaque match criteria passed to it via PortGroupConfig.
- *
- *
- *
+ * PortGroupProvider interface provides all the necessary blueprint for a custom
+ * application to implement in order to provide Port Grouping Service. Custom
+ * Application that implements this interface will have to handle the opaque
+ * match criteria passed to it via PortGroupConfig.
+ *
+ *
+ *
*/
public interface PortGroupProvider {
/**
- * This method is invoked by the Controller towards the Provider when a new port group is configured.
- *
- * @param config New PortGroupConfig object created by user Configuration.
+ * This method is invoked by the Controller towards the Provider when a new
+ * port group is configured.
+ *
+ * @param config
+ * New PortGroupConfig object created by user Configuration.
* @return true if successful. false otherwise.
*/
public boolean createPortGroupConfig(PortGroupConfig config);
/**
- * This method is invoked by the Controller towards the Provider when an existing port group is deleted.
- *
- * @param config Existing Port Group Configuration deleted by the user.
+ * This method is invoked by the Controller towards the Provider when an
+ * existing port group is deleted.
+ *
+ * @param config
+ * Existing Port Group Configuration deleted by the user.
* @return true if successful. false otherwise.
*/
public boolean deletePortGroupConfig(PortGroupConfig config);
/**
- * Returns the complete mapping database corresponds to a PortGroup Configuration.
- * Its the PortGroupProvider Application's responsibility to manage the Switches & the Set of its Ports that
- * correspond to each of the Configuration and return it to the Controller when requested.
- *
- * @param config User Configuration
+ * Returns the complete mapping database corresponds to a PortGroup
+ * Configuration. Its the PortGroupProvider Application's responsibility to
+ * manage the Switches & the Set of its Ports that correspond to each of the
+ * Configuration and return it to the Controller when requested.
+ *
+ * @param config
+ * User Configuration
* @see PortGroupConfig
- * @return Database of Switch-Id to PortGroup mapping that corresponds to the Port Group User Configuration.
+ * @return Database of Switch-Id to PortGroup mapping that corresponds to
+ * the Port Group User Configuration.
*/
public Map<Node, PortGroup> getPortGroupData(PortGroupConfig config);
/**
- * Returns PortGroup data for a given Switch and user Configuration.
- * Its the PortGroupProvider Application's responsibility to manage the Switches & the Set of its Ports that
- * correspond to each of the Configuration and return it to the Controller when requested.
- *
- * @param config User Configuration
- * @param matrixSwitchId Switch Id that represents an openflow Switch
+ * Returns PortGroup data for a given Switch and user Configuration. Its the
+ * PortGroupProvider Application's responsibility to manage the Switches &
+ * the Set of its Ports that correspond to each of the Configuration and
+ * return it to the Controller when requested.
+ *
+ * @param config
+ * User Configuration
+ * @param matrixSwitchId
+ * Switch Id that represents an openflow Switch
* @see PortGroupConfig
* @return PortGroup data for a given Openflow switch.
* @see PortGroup
long matrixSwitchId);
/**
- * Registers a Listener for Port Group membership changes based on Custom application algorithm.
- * @param listener A Controller module that listens to events from the Custom Port Grouping Application.
+ * Registers a Listener for Port Group membership changes based on Custom
+ * application algorithm.
+ *
+ * @param listener
+ * A Controller module that listens to events from the Custom
+ * Port Grouping Application.
*/
public void registerPortGroupChange(PortGroupChangeListener listener);
/**
- * Application returns an Usage string for the Match Criteria User Configuration.
- * Controller provides an opportunity for application to implement Custom Algorithm for Port Grouping.
- * This method exposes the custom algorithm to the user so that the user can configure the matchString
- * regular expression in PortGroupConfig appropriately.
- *
+ * Application returns an Usage string for the Match Criteria User
+ * Configuration. Controller provides an opportunity for application to
+ * implement Custom Algorithm for Port Grouping. This method exposes the
+ * custom algorithm to the user so that the user can configure the
+ * matchString regular expression in PortGroupConfig appropriately.
+ *
* @return Usage string.
*/
public String getApplicationDrivenMatchCriteriaUsage();
/**
- * Returns the name of the Custom Application that implements PortGroupProvider interface.
- *
+ * Returns the name of the Custom Application that implements
+ * PortGroupProvider interface.
+ *
* @return Provider Name
*/
public String getProviderName();
/**
- * Controller uses this method to check with the Provider supports the matchCriteria String configured by the User.
- *
+ * Controller uses this method to check with the Provider supports the
+ * matchCriteria String configured by the User.
+ *
* @param matchCriteria
- * @return true if the Provider supports the matchCriteria String. false otherwise.
+ * @return true if the Provider supports the matchCriteria String. false
+ * otherwise.
*/
public boolean isMatchCriteriaSupported(String matchCriteria);
}
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
public class frmTest {
- @Test
- public void testFlowEntryInstall() throws UnknownHostException{
- Node node = NodeCreator.createOFNode(1L);
- FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node),
- node);
- FlowEntry pol2 = new FlowEntry("polTest2", null, getSampleFlowV6(node),
- node);
- FlowEntryInstall fei = new FlowEntryInstall(pol, null);
- FlowEntryInstall fei2 = new FlowEntryInstall(pol, null);
- FlowEntryInstall fei3 = new FlowEntryInstall(pol2, null);
- Assert.assertTrue(fei.getOriginal().equals(pol));
- Assert.assertTrue(fei.getInstall().equals(pol));
- Assert.assertTrue(fei.getFlowName().equals(pol.getFlowName()));
- Assert.assertTrue(fei.getGroupName().equals(pol.getGroupName()));
- Assert.assertTrue(fei.getNode().equals(pol.getNode()));
- Assert.assertFalse(fei.isDeletePending());
- fei.toBeDeleted();
- Assert.assertTrue(fei.isDeletePending());
- Assert.assertNull(fei.getContainerFlow());
- Assert.assertTrue(fei.equalsByNodeAndName(pol.getNode(), pol.getFlowName()));
-
- Assert.assertTrue(fei.equals(fei2));
- fei2.getOriginal().setFlowName("polTest2");
- Assert.assertFalse(fei.equals(null));
- Assert.assertFalse(fei.equals(fei3));
-
- }
+ @Test
+ public void testFlowEntryInstall() throws UnknownHostException {
+ Node node = NodeCreator.createOFNode(1L);
+ FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node),
+ node);
+ FlowEntry pol2 = new FlowEntry("polTest2", null, getSampleFlowV6(node),
+ node);
+ FlowEntryInstall fei = new FlowEntryInstall(pol, null);
+ FlowEntryInstall fei2 = new FlowEntryInstall(pol, null);
+ FlowEntryInstall fei3 = new FlowEntryInstall(pol2, null);
+ Assert.assertTrue(fei.getOriginal().equals(pol));
+ Assert.assertTrue(fei.getInstall().equals(pol));
+ Assert.assertTrue(fei.getFlowName().equals(pol.getFlowName()));
+ Assert.assertTrue(fei.getGroupName().equals(pol.getGroupName()));
+ Assert.assertTrue(fei.getNode().equals(pol.getNode()));
+ Assert.assertFalse(fei.isDeletePending());
+ fei.toBeDeleted();
+ Assert.assertTrue(fei.isDeletePending());
+ Assert.assertNull(fei.getContainerFlow());
+ Assert.assertTrue(fei.equalsByNodeAndName(pol.getNode(),
+ pol.getFlowName()));
+
+ Assert.assertTrue(fei.equals(fei2));
+ fei2.getOriginal().setFlowName("polTest2");
+ Assert.assertFalse(fei.equals(null));
+ Assert.assertFalse(fei.equals(fei3));
+
+ }
+
@Test
public void testFlowEntryCreation() throws UnknownHostException {
Node node = NodeCreator.createOFNode(1L);
Assert.assertTrue(pol.equals(pol2));
}
-
@Test
public void testFlowEntryCloning() throws UnknownHostException {
Node node = NodeCreator.createOFNode(1L);
match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
List<Action> actionList = new ArrayList<Action>();
- //actionList.add(new Drop());
+ // actionList.add(new Drop());
Flow flow = new Flow(match, actionList);
FlowEntry pol1 = new FlowEntry("m1", "same", flow, node1);
FlowEntry entry = new FlowEntry("polTest", null, getSampleFlowV6(node),
node);
- //testing equal function
+ // testing equal function
Assert.assertFalse(frmC.equals(null));
Assert.assertTrue(frmC.equals(frmC));
Assert.assertTrue(frmC.equals(frmC3));
Assert.assertFalse(frmC.equals(entry));
FlowConfig flowC = createSampleFlowConfig();
Assert.assertFalse(frmC.equals(flowC));
- //testing installInHW
+ // testing installInHW
Assert.assertTrue(frmC.installInHw());
frmC.setInstallInHw(false);
Assert.assertFalse(frmC.installInHw());
frmC.setInstallInHw(true);
Assert.assertTrue(frmC.installInHw());
- //testing general set and get methods
+ // testing general set and get methods
ArrayList<String> actions = createSampleActionList();
frmC.setActions(actions);
Assert.assertFalse(frmC.equals(frmC3));
Assert.assertFalse(frmC.equals(flowC));
frmC.setProtocol(IPProtocols.TCP.toString());
- Assert.assertTrue(frmC.getProtocol().equals(
- IPProtocols.TCP.toString()));
+ Assert.assertTrue(frmC.getProtocol().equals(IPProtocols.TCP.toString()));
Assert.assertFalse(frmC.equals(frmC3));
frmC3.setProtocol(IPProtocols.TCP.toString());
Assert.assertFalse(frmC.equals(flowC));
- frmC.setNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "1"));
- Assert.assertTrue(frmC.getNode()
- .equals(Node.fromString(Node.NodeIDType.OPENFLOW,
- "1")));
+ frmC.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
+ Assert.assertTrue(frmC.getNode().equals(
+ Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
Assert.assertFalse(frmC.equals(frmC3));
- frmC3.setNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "1"));
+ frmC3.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
Assert.assertFalse(frmC.equals(flowC));
frmC.setTosBits("0");
Assert.assertFalse(frmC.equals(frmC3));
frmC3.setHardTimeout("1000");
- // Assert.assertFalse(frmC.equals(flowC));
+ // Assert.assertFalse(frmC.equals(flowC));
Assert.assertTrue(actions.equals(frmC.getActions()));
FlowConfig frmC2 = new FlowConfig(frmC);
Assert.assertFalse(frmC2.equals(frmC));
frmC2.setDynamic(true);
Assert.assertTrue(frmC2.equals(frmC));
- //Assert.assertFalse(frmC2.equals(frmC3));
+ // Assert.assertFalse(frmC2.equals(frmC3));
flowC.setDynamic(true);
Assert.assertTrue(flowC.equals(frmC));
Assert.assertTrue(flowC.isStatusSuccessful());
Assert.assertTrue(id.toString().equals("1"));
}
-
+
@Test
- public void testFlowConfigNextHopValidity() throws UnknownHostException{
- FlowConfig fc = new FlowConfig();
- Assert.assertFalse(fc.isOutputNextHopValid(null));
- Assert.assertFalse(fc.isOutputNextHopValid("abc"));
- Assert.assertFalse(fc.isOutputNextHopValid("1.1.1"));
- Assert.assertFalse(fc.isOutputNextHopValid("1.1.1.1/49"));
-
- Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1"));
- Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1/32"));
- Assert.assertTrue(fc.isOutputNextHopValid("2001:420:281:1004:407a:57f4:4d15:c355"));
-
+ public void testFlowConfigNextHopValidity() throws UnknownHostException {
+ FlowConfig fc = new FlowConfig();
+ Assert.assertFalse(fc.isOutputNextHopValid(null));
+ Assert.assertFalse(fc.isOutputNextHopValid("abc"));
+ Assert.assertFalse(fc.isOutputNextHopValid("1.1.1"));
+ Assert.assertFalse(fc.isOutputNextHopValid("1.1.1.1/49"));
+
+ Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1"));
+ Assert.assertTrue(fc.isOutputNextHopValid("1.1.1.1/32"));
+ Assert.assertTrue(fc
+ .isOutputNextHopValid("2001:420:281:1004:407a:57f4:4d15:c355"));
+
}
-
+
@Test
- public void testFlowConfigEqualities() throws UnknownHostException{
- FlowConfig fc = new FlowConfig();
- FlowConfig fc2 = new FlowConfig();
- fc.setName("flow1");
- fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "1"));
- Assert.assertFalse(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "0")));
- Assert.assertTrue(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "1")));
-
- Assert.assertTrue(fc.isByNameAndNodeIdEqual(
- "flow1",
- Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
- Assert.assertFalse(fc.isByNameAndNodeIdEqual(
- "flow1",
- Node.fromString(Node.NodeIDType.OPENFLOW, "0")));
- Assert.assertFalse(fc.isByNameAndNodeIdEqual(
- "flow2",
- Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
-
- Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2));
- fc2.setName("flow1");
- Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2));
- fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "0"));
- Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2));
- fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "1"));
- Assert.assertTrue(fc.isByNameAndNodeIdEqual(fc2));
+ public void testFlowConfigEqualities() throws UnknownHostException {
+ FlowConfig fc = new FlowConfig();
+ FlowConfig fc2 = new FlowConfig();
+ fc.setName("flow1");
+ fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
+ Assert.assertFalse(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW,
+ "0")));
+ Assert.assertTrue(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW,
+ "1")));
+
+ Assert.assertTrue(fc.isByNameAndNodeIdEqual("flow1",
+ Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
+ Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow1",
+ Node.fromString(Node.NodeIDType.OPENFLOW, "0")));
+ Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow2",
+ Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
+
+ Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2));
+ fc2.setName("flow1");
+ Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2));
+ fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "0"));
+ Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2));
+ fc2.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
+ Assert.assertTrue(fc.isByNameAndNodeIdEqual(fc2));
}
-
+
@Test
- public void testStatusToggle() throws UnknownHostException{
- FlowConfig fc = new FlowConfig();
- fc.toggleStatus();
- Assert.assertTrue(fc.installInHw());
- fc.toggleStatus();
- Assert.assertFalse(fc.installInHw());
- fc.toggleStatus();
- Assert.assertTrue(fc.installInHw());
-
+ public void testStatusToggle() throws UnknownHostException {
+ FlowConfig fc = new FlowConfig();
+ fc.toggleStatus();
+ Assert.assertTrue(fc.installInHw());
+ fc.toggleStatus();
+ Assert.assertFalse(fc.installInHw());
+ fc.toggleStatus();
+ Assert.assertTrue(fc.installInHw());
+
}
+
@Test
public void testGetFlowEntry() throws UnknownHostException {
FlowConfig fc2 = createSampleFlowConfig();
Assert.assertFalse(fc.isValid(null, sb));
Assert.assertTrue(sb.toString().contains("Node is null"));
- fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW,
- "1"));
+ fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
Assert.assertTrue(fc.isValid(null, sb));
fc.setPriority("-1");
fc.setCookie("100");
fc.setIngressPort("-1");
Assert.assertFalse(fc.isValid(null, sb));
- Assert
- .assertTrue(sb.toString().contains(
- "is not valid for the Switch"));
+ Assert.assertTrue(sb.toString().contains("is not valid for the Switch"));
fc.setIngressPort("100");
Assert.assertTrue(fc.isValid(null, sb));
private FlowConfig createSampleFlowConfig() throws UnknownHostException {
ArrayList<String> actions;
actions = createSampleActionList();
- //actions.add(ActionType.CONTROLLER.toString());
- FlowConfig flowConfig =
- new FlowConfig("true", "Config1",
- Node.fromString(Node.NodeIDType.OPENFLOW,
- "1"), "100", "0", "60", "2", "100",
- "0", "0x0800", "00:A0:C9:14:C8:29",
- "00:A0:C9:22:AB:11", IPProtocols.TCP.toString(), "0",
- "1.2.3.4", "2.2.2.2", "8080", "100", "300", "1000",
- actions);
+ // actions.add(ActionType.CONTROLLER.toString());
+ FlowConfig flowConfig = new FlowConfig("true", "Config1",
+ Node.fromString(Node.NodeIDType.OPENFLOW, "1"), "100", "0",
+ "60", "2", "100", "0", "0x0800", "00:A0:C9:14:C8:29",
+ "00:A0:C9:22:AB:11", IPProtocols.TCP.toString(), "0",
+ "1.2.3.4", "2.2.2.2", "8080", "100", "300", "1000", actions);
return flowConfig;
}
actions.add(ActionType.FLOOD.toString());
actions.add(ActionType.SW_PATH.toString());
actions.add(ActionType.HW_PATH.toString());
- actions.add(ActionType.SET_VLAN_PCP.toString()+"=1");
- actions.add(ActionType.SET_VLAN_ID.toString()+"=1");
+ actions.add(ActionType.SET_VLAN_PCP.toString() + "=1");
+ actions.add(ActionType.SET_VLAN_ID.toString() + "=1");
actions.add(ActionType.POP_VLAN.toString());
- actions.add(ActionType.SET_DL_SRC.toString()+"=00:A0:C1:AB:22:11");
- actions.add(ActionType.SET_DL_DST.toString()+"=00:B1:C1:00:AA:BB");
- actions.add(ActionType.SET_NW_SRC.toString()+"=1.1.1.1");
- actions.add(ActionType.SET_NW_DST.toString()+"=2.2.2.2");
+ actions.add(ActionType.SET_DL_SRC.toString() + "=00:A0:C1:AB:22:11");
+ actions.add(ActionType.SET_DL_DST.toString() + "=00:B1:C1:00:AA:BB");
+ actions.add(ActionType.SET_NW_SRC.toString() + "=1.1.1.1");
+ actions.add(ActionType.SET_NW_DST.toString() + "=2.2.2.2");
actions.add(ActionType.CONTROLLER.toString());
- actions.add(ActionType.SET_NW_TOS.toString()+"1");
- actions.add(ActionType.SET_TP_SRC.toString()+"60");
- actions.add(ActionType.SET_TP_DST.toString()+"8080");
- actions.add(ActionType.SET_NEXT_HOP.toString()+"=1.1.1.1");
-
+ actions.add(ActionType.SET_NW_TOS.toString() + "1");
+ actions.add(ActionType.SET_TP_SRC.toString() + "60");
+ actions.add(ActionType.SET_TP_DST.toString() + "8080");
+ actions.add(ActionType.SET_NEXT_HOP.toString() + "=1.1.1.1");
+
return actions;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>forwardingrulesmanager.implementation</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.3.6</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Include-Resource>
+ </Include-Resource>
+ <Export-Package>
+ </Export-Package>
+ <Import-Package>
+ org.opendaylight.controller.clustering.services,
+ org.opendaylight.controller.configuration,
+ org.opendaylight.controller.hosttracker,
+ org.opendaylight.controller.hosttracker.hostAware,
+ org.opendaylight.controller.switchmanager,
+ org.opendaylight.controller.sal.action,
+ org.opendaylight.controller.sal.core,
+ org.opendaylight.controller.sal.flowprogrammer,
+ org.opendaylight.controller.sal.match,
+ org.opendaylight.controller.sal.utils,
+ org.opendaylight.controller.sal.packet,
+ org.opendaylight.controller.forwardingrulesmanager,
+ javax.xml.bind.annotation,
+ javax.xml.bind,
+ org.apache.felix.dm,
+ org.apache.commons.lang3.builder,
+ org.osgi.service.component,
+ org.slf4j,
+ org.eclipse.osgi.framework.console,
+ org.osgi.framework
+ </Import-Package>
+ <Bundle-Activator>
+ org.opendaylight.controller.forwardingrulesmanager.internal.Activator
+ </Bundle-Activator>
+ <Require-Bundle>
+ org.opendaylight.controller.hosttracker
+ </Require-Bundle>
+ <Service-Component>
+ </Service-Component>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>hosttracker</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>configuration</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>clustering.services</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>switchmanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>forwardingrulesmanager</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
-
/*
* Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
.getLogger(Activator.class);
/**
- * Function called when the activator starts just after some
- * initializations are done by the
- * ComponentActivatorAbstractBase.
- *
+ * Function called when the activator starts just after some initializations
+ * are done by the ComponentActivatorAbstractBase.
+ *
*/
public void init() {
}
/**
- * Function called when the activator stops just before the
- * cleanup done by ComponentActivatorAbstractBase
- *
+ * Function called when the activator stops just before the cleanup done by
+ * ComponentActivatorAbstractBase
+ *
*/
public void destroy() {
}
/**
- * Function that is used to communicate to dependency manager the
- * list of known implementations for services inside a container
- *
- *
+ * Function that is used to communicate to dependency manager the list of
+ * known implementations for services inside a container
+ *
+ *
* @return An array containing all the CLASS objects that will be
- * instantiated in order to get an fully working implementation
- * Object
+ * instantiated in order to get an fully working implementation
+ * Object
*/
public Object[] getImplementations() {
Object[] res = { ForwardingRulesManagerImpl.class };
}
/**
- * Function that is called when configuration of the dependencies
- * is required.
- *
- * @param c dependency manager Component object, used for
- * configuring the dependencies exported and imported
- * @param imp Implementation class that is being configured,
- * needed as long as the same routine can configure multiple
- * implementations
- * @param containerName The containerName being configured, this allow
- * also optional per-container different behavior if needed, usually
- * should not be the case though.
+ * Function that is called when configuration of the dependencies is
+ * required.
+ *
+ * @param c
+ * dependency manager Component object, used for configuring the
+ * dependencies exported and imported
+ * @param imp
+ * Implementation class that is being configured, needed as long
+ * as the same routine can configure multiple implementations
+ * @param containerName
+ * The containerName being configured, this allow also optional
+ * per-container different behavior if needed, usually should not
+ * be the case though.
*/
public void configureInstance(Component c, Object imp, String containerName) {
if (imp.equals(ForwardingRulesManagerImpl.class)) {
c.setInterface(interfaces, props);
- c.add(createContainerServiceDependency(containerName).setService(
- IFlowProgrammerService.class).setCallbacks(
- "setFlowProgrammerService", "unsetFlowProgrammerService")
+ c.add(createContainerServiceDependency(containerName)
+ .setService(IFlowProgrammerService.class)
+ .setCallbacks("setFlowProgrammerService",
+ "unsetFlowProgrammerService").setRequired(true));
+
+ c.add(createContainerServiceDependency(containerName)
+ .setService(IClusterContainerServices.class)
+ .setCallbacks("setClusterContainerService",
+ "unsetClusterContainerService").setRequired(true));
+ c.add(createContainerServiceDependency(containerName)
+ .setService(ISwitchManager.class)
+ .setCallbacks("setSwitchManager", "unsetSwitchManager")
+ .setRequired(true));
+ c.add(createContainerServiceDependency(containerName)
+ .setService(IForwardingRulesManagerAware.class)
+ .setCallbacks("setFrmAware", "unsetFrmAware")
+ .setRequired(false));
+ c.add(createContainerServiceDependency(containerName)
+ .setService(IfIptoHost.class)
+ .setCallbacks("setHostFinder", "unsetHostFinder")
+ .setRequired(true));
+ c.add(createContainerServiceDependency(containerName)
+ .setService(IContainer.class)
+ .setCallbacks("setIContainer", "unsetIContainer")
.setRequired(true));
-
- c.add(createContainerServiceDependency(containerName).setService(
- IClusterContainerServices.class).setCallbacks(
- "setClusterContainerService",
- "unsetClusterContainerService").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- ISwitchManager.class).setCallbacks("setSwitchManager",
- "unsetSwitchManager").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IForwardingRulesManagerAware.class).setCallbacks(
- "setFrmAware", "unsetFrmAware").setRequired(false));
- c.add(createContainerServiceDependency(containerName).setService(
- IfIptoHost.class).setCallbacks("setHostFinder",
- "unsetHostFinder").setRequired(true));
- c.add(createContainerServiceDependency(containerName).setService(
- IContainer.class).setCallbacks("setIContainer",
- "unsetIContainer").setRequired(true));
}
}
}
import org.opendaylight.controller.sal.core.Property;
import org.opendaylight.controller.sal.core.UpdateType;
import org.opendaylight.controller.sal.flowprogrammer.Flow;
-import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
import org.opendaylight.controller.sal.match.Match;
import org.opendaylight.controller.sal.match.MatchType;
+import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.sal.utils.EtherTypes;
import org.opendaylight.controller.sal.utils.GlobalConstants;
import org.opendaylight.controller.sal.utils.HexEncode;
import org.opendaylight.controller.sal.utils.ObjectReader;
import org.opendaylight.controller.sal.utils.ObjectWriter;
import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.controller.switchmanager.IInventoryListener;
import org.opendaylight.controller.switchmanager.ISwitchManager;
import org.opendaylight.controller.switchmanager.ISwitchManagerAware;
public class ForwardingRulesManagerImpl implements IForwardingRulesManager,
PortGroupChangeListener, IContainerListener, ISwitchManagerAware,
IConfigurationContainerAware, IInventoryListener, IObjectReader,
- ICacheUpdateAware<Long, String>, CommandProvider,
- IFlowProgrammerListener {
+ ICacheUpdateAware<Long, String>, CommandProvider {
private static final String SAVE = "Save";
private static final String NODEDOWN = "Node is Down";
private static final Logger log = LoggerFactory
// Sanity Check
if (flowEntry == null || flowEntry.getNode() == null) {
String msg = "Invalid FlowEntry";
- String logMsg = msg + ": {}";
- log.warn(logMsg, flowEntry);
+ log.warn(msg + ": " + flowEntry);
return new Status(StatusCode.NOTACCEPTABLE, msg);
}
// Container Flow conflict Check
if (toInstallList.isEmpty()) {
String msg = "Flow Entry conflicts with all Container Flows";
- String logMsg = msg + ": {}";
- log.warn(logMsg, flowEntry);
+ log.warn(msg);
return new Status(StatusCode.CONFLICT, msg);
}
if (findMatch(entry.getInstall(), false) != null) {
log.warn("Operation Rejected: A flow with same match "
+ "and priority exists on the target node");
- log.trace("Aborting to install {}", entry);
+ log.trace("Aborting to install " + entry);
continue;
}
toInstallSafe.add(entry);
if (toInstallSafe.size() == 0) {
String msg = "A flow with same match and priority exists "
+ "on the target node";
- String logMsg = msg + ": {}";
- log.warn(logMsg, flowEntry);
+ log.warn(msg);
return new Status(StatusCode.CONFLICT, msg);
}
oneSucceded = true;
} else {
error = ret;
- log.warn("Failed to install the entry: {}. The failure is: {}",
- installEntry, ret.getDescription());
+ log.warn("Failed to install the entry: " + ret.getDescription());
}
}
if (currentFlowEntry == null || currentFlowEntry.getNode() == null
|| newFlowEntry == null || newFlowEntry.getNode() == null) {
String msg = "Modify: Invalid FlowEntry";
- String logMsg = msg + ": {} or {}";
- log.warn(logMsg, currentFlowEntry, newFlowEntry);
+ log.warn(msg + ": {} or {} ", currentFlowEntry, newFlowEntry);
return new Status(StatusCode.NOTACCEPTABLE, msg);
}
if (!currentFlowEntry.getNode().equals(newFlowEntry.getNode())
|| !currentFlowEntry.getFlowName().equals(
newFlowEntry.getFlowName())) {
String msg = "Modify: Incompatible Flow Entries";
- String logMsg = msg + ": {} and {}";
- log.warn(logMsg, currentFlowEntry, newFlowEntry);
+ log.warn(msg + ": {} and {}", currentFlowEntry, newFlowEntry);
return new Status(StatusCode.NOTACCEPTABLE, msg);
}
// Equality Check
if (currentFlowEntry.equals(newFlowEntry)) {
String msg = "Modify skipped as flows are the same";
- String logMsg = msg + ": {} and {}";
- log.debug(logMsg, currentFlowEntry, newFlowEntry);
+ log.debug(msg + ": " + currentFlowEntry + " and " + newFlowEntry);
return new Status(StatusCode.SUCCESS, msg);
}
currentFlowEntry)) {
String msg = "Operation Rejected: Another flow with same match "
+ "and priority exists on the target node";
- String logMsg = msg + ": {}";
- log.warn(logMsg, currentFlowEntry);
+ log.warn(msg);
return new Status(StatusCode.CONFLICT, msg);
}
if (toInstallList.isEmpty()) {
String msg = "Modify Operation Rejected: The new entry "
+ "conflicts with all the container flows";
- String logMsg = msg + ": {}";
- log.warn(logMsg, newFlowEntry);
log.warn(msg);
return new Status(StatusCode.CONFLICT, msg);
}
.getFlow());
if (!status.isSuccess()) {
- log.warn(
- "SDN Plugin failed to program the flow: {}. The failure is: {}",
- newEntries.getInstall(), status.getDescription());
+ log.warn("SDN Plugin failed to program the flow: "
+ + status.getDescription());
return status;
}
// Sanity Check
if (flowEntry == null || flowEntry.getNode() == null) {
String msg = "Invalid FlowEntry";
- String logMsg = msg + ": {}";
- log.warn(logMsg, flowEntry);
+ log.warn(msg + ": " + flowEntry);
return new Status(StatusCode.NOTACCEPTABLE, msg);
}
boolean atLeastOneRemoved = false;
for (FlowEntryInstall entry : installedList) {
if (flowsOnNode == null) {
- String msg = "Removal skipped (Node down) for flow entry";
- String logMsg = msg + ": {}";
- log.debug(logMsg, flowEntry);
+ String msg = "Removal skipped (Node down)";
+ log.debug(msg + " for flow entry " + flowEntry);
return new Status(StatusCode.SUCCESS, msg);
}
if (!flowsOnNode.contains(entry)) {
- String logMsg = "Removal skipped (not present in software view) for flow entry: {}";
- log.debug(logMsg, flowEntry);
+ log.debug("Removal skipped (not present in software view) "
+ + "for flow entry " + flowEntry);
+
if (installedList.size() == 1) {
// If we had only one entry to remove, we are done
return new Status(StatusCode.SUCCESS, null);
if (!ret.isSuccess()) {
error = ret;
- log.warn("Failed to remove the entry: {}. The failure is: {}",
- entry.getInstall(), ret.getDescription());
+ log.warn("Failed to remove the entry: " + ret.getDescription());
if (installedList.size() == 1) {
// If we had only one entry to remove, this is fatal failure
return error;
.getInstall().getFlow());
if (!status.isSuccess()) {
- log.warn(
- "SDN Plugin failed to program the flow: {}. The failure is: {}",
- entry.getInstall(), status.getDescription());
+ log.warn("SDN Plugin failed to remove the flow: "
+ + status.getDescription());
return status;
}
- log.info("Removed {}", entry.getInstall());
+ log.trace("Removed {}", entry.getInstall());
// Update DB
updateLocalDatabase(entry, false);
.getFlow());
if (!status.isSuccess()) {
- log.warn(
- "SDN Plugin failed to program the flow: {}. The failure is: {}",
- entry.getInstall(), status.getDescription());
+ log.warn("SDN Plugin failed to program the flow: "
+ + status.getDescription());
return status;
}
- log.info("Added {}", entry.getInstall());
+ log.trace("Added {}", entry.getInstall());
// Update DB
updateLocalDatabase(entry, true);
// Update DB
if (status.isSuccess()) {
updateLocalDatabase(target, false);
- } else {
- // log the error
- log.warn(
- "SDN Plugin failed to remove the flow: {}. The failure is: {}",
- target.getInstall(), status.getDescription());
}
return status;
Status status;
if (inContainerMode) {
String msg = "Controller in container mode: Install Refused";
- String logMsg = msg + ": {}";
status = new Status(StatusCode.NOTACCEPTABLE, msg);
- log.warn(logMsg, flowEntry);
+ log.warn(msg);
} else {
status = addEntry(flowEntry);
}
Status status;
if (inContainerMode) {
String msg = "Controller in container mode: Uninstall Refused";
- String logMsg = msg + ": {}";
status = new Status(StatusCode.NOTACCEPTABLE, msg);
- log.warn(logMsg, entry);
+ log.warn(msg);
} else {
status = removeEntry(entry);
}
Status status = null;
if (inContainerMode) {
String msg = "Controller in container mode: Modify Refused";
- String logMsg = msg + ": {}";
status = new Status(StatusCode.NOTACCEPTABLE, msg);
- log.warn(logMsg, newFlowEntry);
+ log.warn(msg);
} else {
status = modifyEntry(currentFlowEntry, newFlowEntry);
}
try {
frma.policyUpdate(policyname, add);
} catch (Exception e) {
- log.warn("Exception on callback", e);
+ log.error("Exception on callback", e);
}
}
}
log.info("Ports {} added to FlowEntry {}", portList,
flowName);
} else {
- log.warn(
- "Failed to add ports {} to Flow entry {}. The failure is: {}",
- portList, currentFlowEntry.toString(),
- error.getDescription());
+ log.warn("Failed to add ports {} to Flow entry {}: "
+ + error.getDescription(), portList,
+ currentFlowEntry.toString());
}
return;
}
log.info("Ports {} removed from FlowEntry {}", portList,
flowName);
} else {
- log.warn(
- "Failed to remove ports {} from Flow entry {}. The failure is: {}",
- portList, currentFlowEntry.toString(),
- status.getDescription());
+ log.warn("Failed to remove ports {} from Flow entry {}: "
+ + status.getDescription(), portList,
+ currentFlowEntry.toString());
}
return;
}
Status status = modifyEntry(currentFlowEntry, newFlowEntry);
if (status.isSuccess()) {
- log.info("Output port replaced with {} for flow {} on node {}",
- outPort, flowName, node);
+ log.info("Output port replaced with " + outPort
+ + " for flow {} on node {}", flowName, node);
} else {
- log.warn(
- "Failed to replace output port for flow {} on node {}. The failure is: {}",
- flowName, node, status.getDescription());
+ log.warn("Failed to replace output port for flow {} on node {}: ",
+ status.getDescription(), flowName, node);
}
return;
}
EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));
} catch (CacheConfigException cce) {
- log.error("FRM CacheConfigException", cce);
+ log.error("FRM CacheConfigException");
} catch (CacheExistException cce) {
- log.error("FRM CacheExistException", cce);
+ log.error("FRM CacheExistException");
}
}
// Presence check
if (flowConfigExists(config)) {
error = "Entry with this name on specified switch already exists";
- log.warn(
- "Entry with this name on specified switch already exists: {}",
- config);
config.setStatus(error);
return new Status(StatusCode.CONFLICT, error);
}
// Skip validation check if we are trying to restore a saved config
if (!restore && !config.isValid(container, resultStr)) {
- log.warn("Invalid Configuration for flow {}. The failure is {}",
- config, resultStr.toString());
+ log.debug(resultStr.toString());
error = "Invalid Configuration (" + resultStr.toString() + ")";
config.setStatus(error);
return new Status(StatusCode.BADREQUEST, error);
}
}
if (!multipleFlowPush) {
- log.warn(
- "Invalid Configuration(Invalid PortGroup Name) for flow {}",
- config);
+ log.debug(resultStr.toString());
error = "Invalid Configuration (Invalid PortGroup Name)";
config.setStatus(error);
return new Status(StatusCode.BADREQUEST, error);
}
private void updateStaticFlowConfigsOnNodeDown(Node node) {
- log.trace("Updating Static Flow configs on node down: {}", node);
+ log.trace("Updating Static Flow configs on node down: " + node);
List<Integer> toRemove = new ArrayList<Integer>();
for (Entry<Integer, FlowConfig> entry : staticFlows.entrySet()) {
}
private void updateStaticFlowConfigsOnContainerModeChange(UpdateType update) {
- log.trace("Updating Static Flow configs on container mode change: {}",
- update);
+ log.trace("Updating Static Flow configs on container mode change: "
+ + update);
for (FlowConfig config : staticFlows.values()) {
if (config.isPortGroupEnabled()) {
if (entry.isInternalFlow()) {
String msg = "Invalid operation: Controller generated "
+ "flow cannot be deleted";
- String logMsg = msg + ": {}";
- log.warn(logMsg, name);
+ log.warn(msg);
return new Status(StatusCode.NOTACCEPTABLE, msg);
}
if (!entry.isPortGroupEnabled()) {
if (newFlowConfig.isInternalFlow()) {
String msg = "Invalid operation: Controller generated flow "
+ "cannot be modified";
- String logMsg = msg + ": {}";
- log.warn(logMsg, newFlowConfig);
+ log.warn(msg);
return new Status(StatusCode.NOTACCEPTABLE, msg);
}
if (!newFlowConfig.isValid(container, resultStr)) {
String msg = "Invalid Configuration (" + resultStr.toString() + ")";
newFlowConfig.setStatus(msg);
- log.warn("Invalid Configuration for flow {}. The failure is {}",
- newFlowConfig, resultStr.toString());
+ log.warn(msg);
return new Status(StatusCode.BADREQUEST, msg);
}
if (oldFlowConfig == null) {
String msg = "Attempt to modify a non existing static flow";
- String logMsg = msg + ": {}";
- log.warn(logMsg, newFlowConfig);
+ log.warn(msg);
return new Status(StatusCode.NOTFOUND, msg);
}
// Do not attempt to reinstall the flow, warn user
if (newFlowConfig.equals(oldFlowConfig)) {
String msg = "No modification detected";
- log.info(
- "Static flow modification skipped. New flow and old flow are the same: {}",
- newFlowConfig);
+ log.info("Static flow modification skipped: " + msg);
return new Status(StatusCode.SUCCESS, msg);
}
if (config.isInternalFlow()) {
String msg = "Invalid operation: Controller generated flow "
+ "cannot be modified";
- String logMsg = msg + ": {}";
- log.warn(logMsg, config);
+ log.warn(msg);
return new Status(StatusCode.NOTACCEPTABLE, msg);
}
for (FlowEntry flowEntry : inactiveFlows) {
Status status = this.removeEntry(flowEntry);
if (!status.isSuccess()) {
- log.warn("Failed to remove entry: {}. The failure is: {}"
- + flowEntry, status.getDescription());
+ log.warn(
+ "Failed to remove entry: {}: "
+ + status.getDescription(), flowEntry);
}
}
}
for (FlowEntry flowEntry : this.inactiveFlows) {
Status status = this.addEntry(flowEntry);
if (!status.isSuccess()) {
- log.warn("Failed to install entry: {}. The failure is: {}"
- + flowEntry, status.getDescription());
+ log.warn(
+ "Failed to install entry: {}: "
+ + status.getDescription(), flowEntry);
}
}
* @param node
*/
private synchronized void cleanDatabaseForNode(Node node) {
- log.info("Cleaning Flow database for Node {}", node.toString());
+ log.info("Cleaning Flow database for Node " + node.toString());
// Find out which groups the node's flows are part of
Set<String> affectedGroups = new HashSet<String>();
try {
node = NodeCreator.createOFNode(Long.valueOf(nodeId));
} catch (NumberFormatException e) {
- ci.print("Node id not a number");
- return;
+ e.printStackTrace();
}
ci.println(this.programmer.addFlow(node, getSampleFlow(node)));
}
try {
node = NodeCreator.createOFNode(Long.valueOf(nodeId));
} catch (NumberFormatException e) {
- ci.print("Node id not a number");
- return;
+ e.printStackTrace();
}
ci.println(this.programmer.removeFlow(node, getSampleFlow(node)));
}
}
}
- @Override
- public void flowRemoved(Node node, Flow flow) {
- log.trace("Received flow removed notification on {} for {}", node, flow);
- // For flow entry identification, only match and priority matter
- FlowEntry toFind = new FlowEntry("any", "any", flow, node);
- FlowEntryInstall installedEntry = this.findMatch(toFind, false);
- if (installedEntry == null) {
- log.trace("Entry is not know to us");
- return;
- }
-
- // Update Static flow status
- for (Map.Entry<Integer, FlowConfig> entry : staticFlows.entrySet()) {
- FlowConfig conf = entry.getValue();
- if (conf.isByNameAndNodeIdEqual(installedEntry.getFlowName(), node)) {
- // Update Configuration database
- conf.toggleStatus();
- break;
- }
- }
- // Update software views
- this.updateLocalDatabase(installedEntry, false);
- }
-
}