private static Optional<? extends Flow> injectMatchToFlow(Flow sourceFlow, Match match) { if (sourceFlow instanceof AddFlowInput) { return Optional.of(new AddFlowInputBuilder(sourceFlow).setMatch(match).build()); } else if (sourceFlow instanceof RemoveFlowInput) { return Optional.of(new RemoveFlowInputBuilder(sourceFlow).setMatch(match).build()); } else if (sourceFlow instanceof UpdatedFlow) { return Optional.of(new UpdatedFlowBuilder(sourceFlow).setMatch(match).build()); } else { return Optional.empty(); } }
/** * {@inheritDoc} */ @Override public void transactionCanceled() { LOG.warn("Failed to read VTN flows: {}", targetNode); if (!rpcFuture.isDone()) { LOG.warn("All flow entries in {} will be removed.", targetNode); Short tid = Short.valueOf(FlowUtils.TABLE_ID); FlowTableRef tref = new FlowTableRef(targetNode.getFlowTableIdentifier(tid)); StringBuilder sb = new StringBuilder("clean-up:"). append(targetNode); RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(). setNode(targetNode.getNodeRef()). setFlowTable(tref). setTransactionUri(new Uri(sb.toString())). setTableId(tid). setMatch(EMPTY_MATCH). setStrict(false); rpcList.invoke(builder); completeRpc(); } } }
private static Optional<? extends Flow> injectMatchAndAction(Flow sourceFlow, Match match) { Instructions instructions = (new InstructionsBuilder()) .setInstruction(injectPushActionToInstruction(sourceFlow)) .build(); if (sourceFlow instanceof AddFlowInput) { return Optional.of(new AddFlowInputBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else if (sourceFlow instanceof RemoveFlowInput) { return Optional.of(new RemoveFlowInputBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else if (sourceFlow instanceof UpdatedFlow) { return Optional.of(new UpdatedFlowBuilder(sourceFlow) .setMatch(match).setInstructions(instructions).build()); } else { return Optional.empty(); } }
/** * This utility method deletes the flows as per the match. * @param flowService reference of SalFlowService. * @param flows Collection of flows to be deleted. * @param node Flows to be deleted from the node. */ public static void deleteFlows(SalFlowService flowService, Collection<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow> flows, InstanceIdentifier<Node> node) { for(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow flow : flows) { RemoveFlowInputBuilder inputBuilder = new RemoveFlowInputBuilder() .setMatch(flow.getMatch()) .setTableId(flow.getTableId()) .setNode(new NodeRef(node)); flowService.removeFlow(inputBuilder.build()); } }
setFlowTable(tref). setTransactionUri(new Uri("remove-flow:all")). setMatch(EMPTY_MATCH). setCookie(COOKIE_VTN). setCookieMask(COOKIE_MASK_VTN).
builder.setMatch(EMPTY_MATCH);