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(); }
/** * {@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(); } } }
new FlowTableRef(snode.getFlowTableIdentifier(table)); RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(flow). setNode(snode.getNodeRef()). setFlowTable(tref). setTransactionUri(uri). setCookieMask(COOKIE_MASK_ALL). setStrict(true); if (builder.getMatch() == null) { builder.setMatch(EMPTY_MATCH);
private RemoveFlowInputImpl(RemoveFlowInputBuilder base) { this._bufferId = base.getBufferId(); this._containerName = base.getContainerName(); this._cookie = base.getCookie(); this._cookieMask = base.getCookieMask(); this._flags = base.getFlags(); this._flowName = base.getFlowName(); this._flowRef = base.getFlowRef(); this._flowTable = base.getFlowTable(); this._hardTimeout = base.getHardTimeout(); this._idleTimeout = base.getIdleTimeout(); this._instructions = base.getInstructions(); this._match = base.getMatch(); this._node = base.getNode(); this._outGroup = base.getOutGroup(); this._outPort = base.getOutPort(); this._priority = base.getPriority(); this._tableId = base.getTableId(); this._transactionUri = base.getTransactionUri(); this._barrier = base.isBarrier(); this._installHw = base.isInstallHw(); this._strict = base.isStrict(); switch (base.augmentation.size()) { case 0:
/** * 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()); } }
@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()); } }
new FlowTableRef(snode.getFlowTableIdentifier(table)); return new RemoveFlowInputBuilder(). setNode(snode.getNodeRef()). setTableId(table). setFlowTable(tref). setTransactionUri(new Uri("remove-flow:all")). setMatch(EMPTY_MATCH). setCookie(COOKIE_VTN). setCookieMask(COOKIE_MASK_VTN). setStrict(false);
@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()); }
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(); } }
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(); } }
/** * 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()); }
@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; }
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(); }
Flow lacpFlow = createLacpFlow(); final RemoveFlowInputBuilder builder = new RemoveFlowInputBuilder(lacpFlow); 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()); try
@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)); } }
RemoveFlowInputBuilder ingress = new RemoveFlowInputBuilder(). setNode(nref). setTableId(table). setFlowTable(tref). setTransactionUri(new Uri(ub.toString())). setMatch(match). setStrict(false); list.add(ingress); RemoveFlowInputBuilder egress = new RemoveFlowInputBuilder(). setNode(nref). setTableId(table). setFlowTable(tref). setTransactionUri(new Uri(ub.toString())). setMatch(EMPTY_MATCH). setOutPort(NumberUtils.getUnsigned(sport.getPortNumber())). setStrict(false); list.add(egress);
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); Future<RpcResult<AddFlowOutput>> futureAddFlowResult = flowService.addFlow(new AddFlowInputBuilder(