/** * Invoke a remove-flow RPC. * * @param builder A {@link RemoveFlowInputBuilder} instance. */ public void invoke(@Nonnull RemoveFlowInputBuilder builder) { RemoveFlowInput input = builder.build(); rpcList.add(new RemoveFlowRpc(rpcWatcher, flowService, input)); targetNodes.add(input.getNode()); }
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(); } }
public static Instructions toApplyInstruction(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) { return new InstructionsBuilder() .setInstruction( Collections.singletonList( new InstructionBuilder() .setOrder(0) .setInstruction( new ApplyActionsCaseBuilder() .setApplyActions(new ApplyActionsBuilder().setAction(actions).build()) .build() ).build()) ).build(); }
public static RemoveFlowInput removeFlowInput(final Node sourceNode, final Flow sourceFlow) { final FlowAdded source = MDFlowMapping.flowAdded(sourceFlow); return new RemoveFlowInputBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) source) .setNode(NodeMapping.toNodeRef(sourceNode)) .build(); }
@Override public void onNodeUpdated(NodeUpdated nodeUpdated) { LOG.debug("Node updated {}", nodeUpdated); NodeId nodeId = nodeUpdated.getId(); FlowCapableNodeUpdated switchDesc = nodeUpdated.getAugmentation(FlowCapableNodeUpdated.class); if (switchDesc != null) { LOG.info("Node {}, OpenFlow description {}", nodeId, switchDesc); } //Remove all flows using RPC call to MD-SAL Flow Service RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder() .setBarrier(true) .setNode(InventoryUtils.getNodeRef(nodeId)); salFlowService.removeFlow(flowBuilder.build()); }
@Override public void onSuccess(RpcResult<AddFlowOutput> result) { if (!result.isSuccessful()) { LOG.warn("Flow to route ARP Reply to Controller is not installed successfully : {} \nErrors: {}", flowIid,result.getErrors()); return; } LOG.debug("Flow to route ARP Reply to Controller installed successfully : {}", flowIid); ArpResolverMetadata gatewayArpMetadata = gatewayToArpMetadataMap.get(gatewayIp); if (gatewayArpMetadata == null) { LOG.warn("No metadata found for gatewayIp: {}", gatewayIp); return; } //cache metadata gatewayArpMetadata.setFlowToRemove(new RemoveFlowInputBuilder(arpReplyToControllerFlow).setNode(nodeRef).build()); //get MAC DA for ARP packets MacAddress arpRequestDestMacAddress = gatewayArpMetadata.getArpRequestDestMacAddress(); //Send ARP request packets for (NodeConnector egressNc : externalNetworkBridge.getNodeConnector()) { KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> egressNcIid = nodeIid.child( NodeConnector.class, new NodeConnectorKey(egressNc.getId())); ListenableFuture<RpcResult<Void>> futureSendArpResult = arpSender.sendArp( senderAddress, gatewayIp, arpRequestDestMacAddress, egressNcIid); Futures.addCallback(futureSendArpResult, logResult(gatewayIp, egressNcIid)); } }
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()); } }
builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue())); Future<RpcResult<RemoveFlowOutput>> result = salFlow.removeFlow(builder.build()); try
final Flow arpReplyToControllerFlow = createArpReplyToControllerFlow(senderAddress, tpa, ncId); flowsForRemove.add(new ImmutablePair<>(new RemoveFlowInputBuilder(arpReplyToControllerFlow).setNode( nodeRef).build(), l3Ep.getKey())); final InstanceIdentifier<Flow> flowIid = createFlowIid(arpReplyToControllerFlow, nodeIid); Future<RpcResult<AddFlowOutput>> futureAddFlowResult = flowService.addFlow(new AddFlowInputBuilder(
@Override public Future<RpcResult<RemoveFlowOutput>> removeWithResult(final InstanceIdentifier<Flow> identifier, final Flow removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) { Future<RpcResult<RemoveFlowOutput>> resultFuture = SettableFuture.create(); final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class); if (tableIdValidationPrecondition(tableKey, removeDataObj)) { final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj); builder.setFlowRef(new FlowRef(identifier)); builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))); builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey))); // This method is called only when a given flow object has been // removed from datastore. So FRM always needs to set strict flag // into remove-flow input so that only a flow entry associated with // a given flow object is removed. builder.setTransactionUri(new Uri(provider.getNewTransactionId())). setStrict(Boolean.TRUE); resultFuture = provider.getSalFlowService().removeFlow(builder.build()); } return resultFuture; }
@Override public void remove(final InstanceIdentifier<Flow> identifier, final Flow removeDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) { final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class); if (tableIdValidationPrecondition(tableKey, removeDataObj)) { final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(removeDataObj); builder.setFlowRef(new FlowRef(identifier)); builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))); builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey))); // This method is called only when a given flow object has been // removed from datastore. So FRM always needs to set strict flag // into remove-flow input so that only a flow entry associated with // a given flow object is removed. builder.setTransactionUri(new Uri(provider.getNewTransactionId())). setStrict(Boolean.TRUE); provider.getSalFlowService().removeFlow(builder.build()); } }