import java.util.List;
public class InstructionUtils {
- private static final Logger logger = LoggerFactory.getLogger(InstructionUtils.class);
+ private static final Logger LOG = LoggerFactory.getLogger(InstructionUtils.class);
private static final int IPV4 = 0x8100;
private static final int MAX_LENGTH = 0xffff;
public static InstructionBuilder createOutputPortInstructions(InstructionBuilder ib, Long dpidLong, Long port) {
NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
- logger.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} inPort={} ",
+ LOG.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} inPort={} ",
dpidLong, port);
List<Action> actionList = Lists.newArrayList();
Long dpidLong, Long port,
List<Instruction> instructions) {
NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
- logger.debug(
+ LOG.debug(
"addOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
dpidLong, port, instructions);
final NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
final Uri ncidUri = new Uri(ncid);
- logger.debug(
+ LOG.debug(
"removeOutputPortFromInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
dpidLong, port, instructions);
ab = new ActionBuilder();
ab.setAction(action.getAction());
ab.setOrder(action.getOrder() - 1);
- ab.setKey(new ActionKey(i));
+ ab.setKey(new ActionKey(action.getOrder() - 1));
Action actionNewOrder = ab.build();
actionList.remove(action);
actionList.add(i, actionNewOrder);
} else if (action.getOrder() == removedActionOrder) {
// Sanity: implementation assumes no two actions have the same order
//
- logger.error("Found action with same order as the action removed for {}, order {} index {}: {}",
+ LOG.error("Found action with same order as the action removed for {}, order {} index {}: {}",
ncid, removedActionOrder, i, action);
}
// If port we are asked to delete is not found, this implementation will leave actions
// alone and not remove the flow, as long as a remaining OutputActionCase is found.
//
- for (int i = 0; i < actionList.size(); i++) {
- if (actionList.get(i).getAction() instanceof OutputActionCase) {
+ for (Action action : actionList) {
+ if (action.getAction() instanceof OutputActionCase) {
removeFlow = false;
break;
}
ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
- logger.debug("removeOutputPortFromInstructions() : applyAction {}", aab.build());
+ LOG.debug("removeOutputPortFromInstructions() : applyAction {}", aab.build());
return false;
} else {
/* if all output ports are removed. Return true to indicate flow remove */
*
* @param ib Map InstructionBuilder without any instructions
* @param prefixdst String containing an IPv4 prefix
+ * @param extraAction (optional) Additional action to be performed in actionList
* @return ib Map InstructionBuilder with instructions
*/
- public static InstructionBuilder createNwDstInstructions(InstructionBuilder ib, Ipv4Prefix prefixdst) {
+ public static InstructionBuilder createNwDstInstructions(InstructionBuilder ib, Ipv4Prefix prefixdst,
+ ActionBuilder extraAction) {
List<Action> actionList = Lists.newArrayList();
ActionBuilder ab = new ActionBuilder();
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
+ if (extraAction != null) {
+ extraAction.setOrder(1);
+ extraAction.setKey(new ActionKey(1));
+ actionList.add(extraAction.build());
+ }
+
// Create an Apply Action
ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);