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 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()); }
/** * {@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(); } } }
@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(); } }
RemoveFlowInputBuilder ingress = new RemoveFlowInputBuilder(). setNode(nref). setTableId(table). RemoveFlowInputBuilder egress = new RemoveFlowInputBuilder(). setNode(nref). setTableId(table).
/** * 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()); } }
NodeConnectorId ncId = extNcIidAndMac.getLeft().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId(); 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);
new FlowTableRef(snode.getFlowTableIdentifier(table)); return new RemoveFlowInputBuilder(). setNode(snode.getNodeRef()). setTableId(table).
Flow lacpFlow = createLacpFlow(); final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(lacpFlow); builder.setNode(new NodeRef(nodeId)); builder.setFlowRef(new FlowRef(lacpFId));
new FlowTableRef(snode.getFlowTableIdentifier(table)); RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(flow). setNode(snode.getNodeRef()). setFlowTable(tref).
@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()); } }