/** * {@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(); } } }
builder.setNode(new NodeRef(nodeId)); builder.setFlowRef(new FlowRef(lacpFId)); builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue())); try
Short table = Short.valueOf(TABLE_ID); FlowTableRef tref = new FlowTableRef(snode.getFlowTableIdentifier(table)); NodeRef nref = snode.getNodeRef();
Short table = Short.valueOf(TABLE_ID); FlowTableRef tref = new FlowTableRef(snode.getFlowTableIdentifier(table));
builder.setNode(new NodeRef(nodeId)); builder.setFlowRef(new FlowRef(lacpFId)); builder.setFlowTable(new FlowTableRef(tableId)); builder.setTransactionUri(new Uri(lacpFlow.getId().getValue())); Future<RpcResult<RemoveFlowOutput>> result = salFlow.removeFlow(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()); } }
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()); } }
Short table = flow.getTableId(); FlowTableRef tref = new FlowTableRef(snode.getFlowTableIdentifier(table));
builder.setNode(new NodeRef(nodeInstanceId)); 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; }
/** * 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(); }
new FlowTableRef(snode.getFlowTableIdentifier(table)); return new AddFlowInputBuilder(). setNode(snode.getNodeRef()).