@Override public FlowAdded createNotification(final Flow o, final InstanceIdentifier<Flow> path) { Preconditions.checkArgument(o != null); Preconditions.checkArgument(path != null); final FlowAddedBuilder builder = new FlowAddedBuilder(o); builder.setFlowRef(new FlowRef(path)); builder.setNode(createNodeRef(path)); return builder.build(); }
/** * Return a MD-SAL flow ID configured in the given flow-ref instance. * * @param fref A flow-ref instance. * @return A MD-SAL flow ID configured in the given flow-ref instance. * @throws IllegalArgumentException * The given flow-ref instance is invalid. */ private String getFlowId(FlowRef fref) { if (fref == null) { throw new IllegalArgumentException("flow-ref cannot be null."); } // Verify the specified path. InstanceIdentifier<?> path = fref.getValue(); FlowKey fkey = path.firstKeyOf(Flow.class); if (fkey != null) { InstanceIdentifier<Flow> expected = tablePath.child(Flow.class, fkey); if (expected.equals(path)) { return fkey.getId().getValue(); } } throw new IllegalArgumentException("Invalid flow-ref: " + path); }
@Override public FlowUpdated updateNotification(final Flow o, final InstanceIdentifier<Flow> path) { Preconditions.checkArgument(o != null); Preconditions.checkArgument(path != null); final FlowUpdatedBuilder builder = new FlowUpdatedBuilder(o); builder.setFlowRef(new FlowRef(path)); builder.setNode(createNodeRef(path)); return builder.build(); }
@Override public FlowRemoved deleteNotification(final InstanceIdentifier<Flow> path) { Preconditions.checkArgument(path != null); final FlowRemovedBuilder builder = new FlowRemovedBuilder(); builder.setFlowRef(new FlowRef(path)); builder.setNode(createNodeRef(path)); return builder.build(); } }
builder.setFlowRef(new FlowRef(lacpFId)); builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue()));
builder.setFlowRef(new FlowRef(lacpFId)); builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue()));
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()); } }
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()); } }
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));
builder.setFlowRef(new FlowRef(flowPath)); builder.setFlowTable(new FlowTableRef(tableInstanceId)); builder.setTransactionUri(new Uri(flowToSend.getId().getValue()));
@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()); } }
@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; }
arpReplyToControllerFlow).setFlowRef(new FlowRef(flowIid)).setNode(nodeRef).build());
/** * Starts and commits data change transaction which modifies provided flow * path with supplied body. * * @param flowPath * @param flow * @return transaction commit */ private Future<RpcResult<AddFlowOutput>> writeFlowToConfigData(InstanceIdentifier<Flow> flowPath, Flow flow) { final InstanceIdentifier<Table> tableInstanceId = flowPath.<Table>firstIdentifierOf(Table.class); final InstanceIdentifier<Node> nodeInstanceId = flowPath.<Node>firstIdentifierOf(Node.class); 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 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()); } }
/** * Construct an RPC input to install the specified flow entry. * * @param flowId A VTN flow ID. * @param vfent A {@link VtnFlowEntry} instance. * @return A {@link AddFlowInput} instance. */ public static AddFlowInput createAddFlowInput(VtnFlowId flowId, VtnFlowEntry vfent) { SalNode snode = SalNode.create(vfent.getNode()); Short table = vfent.getTableId(); FlowTableRef tref = new FlowTableRef(snode.getFlowTableIdentifier(table)); // Associate a unique MD-SAL flow ID. FlowId fid = createMdFlowId(flowId.getValue(), vfent.getOrder()); FlowRef fref = new FlowRef(snode.getFlowIdentifier(table, fid)); return new AddFlowInputBuilder((Flow)vfent). setNode(snode.getNodeRef()). setFlowRef(fref). setFlowTable(tref). setTransactionUri(createTxUri(vfent, "add-flow:")). setStrict(true). build(); }
@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()); } }
FlowRef fref = new FlowRef(snode.getFlowIdentifier(table, fid));