/** * @param addFlowInput */ private void pushFlowViaRpc(AddFlowInput addFlowInput) { flowService.addFlow(addFlowInput); }
/** * Issue an remove-flow RPC request. * * @param w The node RPC watcher. * @param sfs MD-SAL flow service. * @param in The RPC input. */ public RemoveFlowRpc(NodeRpcWatcher w, SalFlowService sfs, RemoveFlowInput in) { super(w, in, in.getNode(), sfs.removeFlow(in), false); }
@Override public void update(final InstanceIdentifier<Flow> identifier, final Flow original, final Flow update, final InstanceIdentifier<FlowCapableNode> nodeIdent) { final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class); if (tableIdValidationPrecondition(tableKey, update)) { final UpdateFlowInputBuilder builder = new UpdateFlowInputBuilder(); builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))); builder.setFlowRef(new FlowRef(identifier)); builder.setTransactionUri(new Uri(provider.getNewTransactionId())); // This method is called only when a given flow object in datastore // has been updated. So FRM always needs to set strict flag into // update-flow input so that only a flow entry associated with // a given flow object is updated. builder.setUpdatedFlow((new UpdatedFlowBuilder(update)).setStrict(Boolean.TRUE).build()); builder.setOriginalFlow((new OriginalFlowBuilder(original)).setStrict(Boolean.TRUE).build()); provider.getSalFlowService().updateFlow(builder.build()); } }
/** * Issue an add-flow RPC request. * * @param w The node RPC watcher. * @param sfs MD-SAL flow service. * @param in The RPC input. * @param discon Determine whether an error caused by disconnection of * OpenFlow secure channel should be logged or not. */ public AddFlowRpc(NodeRpcWatcher w, SalFlowService sfs, AddFlowInput in, boolean discon) { super(w, in, in.getNode(), sfs.addFlow(in), discon); }
private ArpResolverMetadata resetFlowToRemove( final Ipv4Address gatewayIp, ArpResolverMetadata gatewayArpMetadata) { checkNotNull(gatewayIp); // If gatewayArpMetadata was not provided, look it up if (gatewayArpMetadata == null) { gatewayArpMetadata = gatewayToArpMetadataMap.get(gatewayIp); } if (gatewayArpMetadata != null && gatewayArpMetadata.getFlowToRemove() != null) { LOG.debug("Flow to route ARP Reply to Controller from {} being removed from node {}", gatewayIp, gatewayArpMetadata.getFlowToRemove().getNode()); flowService.removeFlow(gatewayArpMetadata.getFlowToRemove()); gatewayArpMetadata.setFlowToRemove(null); } return gatewayArpMetadata; }
@Override protected void processPacket(final InstanceIdentifier<Node> node, final Match match, final Instructions instructions) { final AddFlowInputBuilder fb = BUILDER.get(); // Finally build our flow fb.setMatch(match); fb.setInstructions(instructions); // Construct the flow instance id fb.setNode(new NodeRef(node)); // Add flow final AddFlowInput flow = fb.build(); if (LOG.isDebugEnabled()) { LOG.debug("onPacketReceived - About to write flow (via SalFlowService) {}", flow); } ListenableFuture<RpcResult<AddFlowOutput>> result = JdkFutureAdapters.listenInPoolThread(flowService.addFlow(flow)); Futures.addCallback(result, new FutureCallback<RpcResult<AddFlowOutput>>() { @Override public void onSuccess(final RpcResult<AddFlowOutput> o) { countFutureSuccess(); } @Override public void onFailure(final Throwable throwable) { countFutureError(); } }); }
@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 onDataTreeChanged(@Nonnull final Collection<DataTreeModification<FlowCapableNode>> modifications) { for (DataTreeModification modification : modifications) { if (modification.getRootNode().getModificationType() == ModificationType.WRITE) { AddFlowInputBuilder addFlowInput = new AddFlowInputBuilder(createFlow()); addFlowInput.setNode(new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class))); this.flowService.addFlow(addFlowInput.build()); } } }
/** * 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()); } }
try Future<RpcResult<AddFlowOutput>> result = salFlow.addFlow(builder.build()); if (result != null)
builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue())); Future<RpcResult<RemoveFlowOutput>> result = salFlow.removeFlow(builder.build()); try
private Future<RpcResult<AddFlowOutput>> writeFlowToController(InstanceIdentifier<Node> nodeInstanceId, InstanceIdentifier<Table> tableInstanceId, InstanceIdentifier<Flow> flowPath, Flow flow) { LOG.trace("Adding flow to node {}",nodeInstanceId.firstKeyOf(Node.class, NodeKey.class).getId().getValue()); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow); builder.setNode(new NodeRef(nodeInstanceId)); builder.setFlowRef(new FlowRef(flowPath)); builder.setFlowTable(new FlowTableRef(tableInstanceId)); builder.setTransactionUri(new Uri(flow.getId().getValue())); return salFlowService.addFlow(builder.build()); } }
List<Pair<RemoveFlowInput, EndpointL3Key>> removeFlowInputsAndL3EpKeys = requestInfoByKey.get(createKey(nodeKey.getId(), spa)); for (Pair<RemoveFlowInput, EndpointL3Key> removeFlowInputAndL3EpKey : removeFlowInputsAndL3EpKeys) { flowService.removeFlow(removeFlowInputAndL3EpKey.getLeft());
private Future<RpcResult<AddFlowOutput>> writeFlowToController(InstanceIdentifier<Node> nodeInstanceId, InstanceIdentifier<Table> tableInstanceId, InstanceIdentifier<Flow> flowPath, Flow flow) { LOG.trace("Adding flow to node {}",nodeInstanceId.firstKeyOf(Node.class, NodeKey.class).getId().getValue()); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow); builder.setNode(new NodeRef(nodeInstanceId)); builder.setFlowRef(new FlowRef(flowPath)); builder.setFlowTable(new FlowTableRef(tableInstanceId)); builder.setTransactionUri(new Uri(flow.getId().getValue())); return salFlowService.addFlow(builder.build()); } }
@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; }
nodeRef).build(), l3Ep.getKey())); final InstanceIdentifier<Flow> flowIid = createFlowIid(arpReplyToControllerFlow, nodeIid); Future<RpcResult<AddFlowOutput>> futureAddFlowResult = flowService.addFlow(new AddFlowInputBuilder( arpReplyToControllerFlow).setFlowRef(new FlowRef(flowIid)).setNode(nodeRef).build()); arpFlowResultFutures.add(JdkFutureAdapters.listenInPoolThread(futureAddFlowResult));
@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()); } }
builder.setTransactionUri(new Uri(flowToSend.getId().getValue())); final Future<RpcResult<AddFlowOutput>> rpcResultFuture = flowService.addFlow(builder.build()); try{ if(rpcResultFuture != null){
@Override public Future<RpcResult<AddFlowOutput>> add( final InstanceIdentifier<Flow> identifier, final Flow addDataObj, final InstanceIdentifier<FlowCapableNode> nodeIdent) { Future<RpcResult<AddFlowOutput>> future; final TableKey tableKey = identifier.firstKeyOf(Table.class, TableKey.class); if (tableIdValidationPrecondition(tableKey, addDataObj)) { final AddFlowInputBuilder builder = new AddFlowInputBuilder(addDataObj); builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))); builder.setFlowRef(new FlowRef(identifier)); builder.setFlowTable(new FlowTableRef(nodeIdent.child(Table.class, tableKey))); builder.setTransactionUri(new Uri(provider.getNewTransactionId())); future = provider.getSalFlowService().addFlow(builder.build()); } else { future = Futures.<RpcResult<AddFlowOutput>>immediateFuture(null); } return future; }
/** * Starts and commits data change transaction which modifies provided * flow path with supplied body. */ private Future<RpcResult<AddFlowOutput>> writeFlowToSwitch(NodeId nodeId, Flow flow) { InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.<Nodes>builder(Nodes.class) .<Node, NodeKey>child(Node.class, new NodeKey(nodeId)).build(); InstanceIdentifier<Table> tableInstanceId = nodeInstanceId .<FlowCapableNode>augmentation(FlowCapableNode.class) .<Table, TableKey>child(Table.class, new TableKey(flowTableId)); InstanceIdentifier<Flow> flowPath = tableInstanceId.<Flow, FlowKey>child(Flow.class, new FlowKey(new FlowId(String.valueOf(flowIdInc.getAndIncrement())))); final AddFlowInputBuilder builder = new AddFlowInputBuilder(flow).setNode(new NodeRef(nodeInstanceId)) .setFlowTable(new FlowTableRef(tableInstanceId)).setFlowRef(new FlowRef(flowPath)) .setTransactionUri(new Uri(flow.getId().getValue())); return salFlowService.addFlow(builder.build()); } }