/** * To delete Arp flows in the given node. * @param nodeId : nodeId */ private void deleteArpFlow(NodeId nodeId) { List<Flow> flowList = getFlowList(nodeId); for (Flow flow : flowList) { String flowId = flow.getId().toString(); if (flowId.contains(ARP_REPLY_TO_CONTROLLER_FLOW_NAME)) { deleteFlow(nodeId, flow); } } }
public TableFlowUpdateState(final KeyedInstanceIdentifier<Table, TableKey> tablePath, final Table table) { tableRef = tablePath; tableKey = tablePath.getKey(); flowIdByHash = HashBiMap.create(); if(table != null) { final FlowHashIdMapping flowHashMapping = table.getAugmentation(FlowHashIdMapping.class); if (flowHashMapping != null) { final List<FlowHashIdMap> flowHashMap = flowHashMapping.getFlowHashIdMap() != null ? flowHashMapping.getFlowHashIdMap() : Collections.<FlowHashIdMap> emptyList(); for (final FlowHashIdMap flowHashId : flowHashMap) { try { flowIdByHash.put(flowHashId.getKey(), flowHashId.getFlowId()); } catch (final Exception e) { //flowHashId.getKey() too verbose for standard log. if(LOG.isDebugEnabled()) { final FlowId currData = flowIdByHash.get(flowHashId.getKey()); LOG.debug("flow hashing hit a duplicate for {} -> {}. Curr value: {} Equals:{}. Exception was raised:", flowHashId.getKey(), flowHashId.getFlowId(), currData, flowHashId.getFlowId().equals(currData), e); } else { LOG.warn("flow hashing hit a duplicate {}. Exception was raised: {}. Enable DEBUG for more detail.", flowHashId.getFlowId().toString().substring(0, Math.min(TRUNCATED_LOG_MESSAGE_LENGTH,flowHashId.getFlowId().toString().length())), e.getMessage().substring(0,Math.min(TRUNCATED_LOG_MESSAGE_LENGTH,e.getMessage().length()))); } } } } } }
/** * To remove redirect flows in the given nodes. * @param nodeId : nodeId * @param intent : intent */ private void removeRedirectFlow(NodeId nodeId, Intent intent) { List<Flow> flowList = getFlowList(nodeId); List<String> endPointGroups = IntentUtils.extractEndPointGroup(intent); String endPointGroupsFroward = createRedirectFlowName(endPointGroups); Collections.reverse(endPointGroups); String endPointGroupsReverse = createRedirectFlowName(endPointGroups); for (Flow flow : flowList) { String flowId = flow.getId().toString(); if (flowId.contains(endPointGroupsFroward) || flowId.contains(endPointGroupsReverse)) { deleteFlow(nodeId, flow); } } }
public void writeFlow(MacAddress srcMac, MacAddress dstMac, NodeConnectorRef dstNodeConnectorRef, Long meterId) { LOG.info("in flowManager.addFlow"); if(srcMac != null && dstMac.equals(srcMac)) { LOG.info("In addMacToMacFlow: No flows added. Source and Destination MAC are same."); return; } TableKey flowTableKey = new TableKey(flowTableId); InstanceIdentifier<Flow> flowPath = buildFlowPath(createMacMatch(srcMac, dstMac), dstNodeConnectorRef, flowTableKey); FlowId flowId = flowPath.firstKeyOf(Flow.class).getId(); LOG.info("flowPath: " + flowPath.toString()); LOG.info("flowId: " + flowId.toString()); Flow flowBody = createMacToMacFlow(flowId, flowTableKey.getId(), DEFAULT_PRIORITY, srcMac, dstMac, meterId, dstNodeConnectorRef); LOG.info("flowBody: " + flowBody.toString()); WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody, true); try { writeTransaction.submit().checkedGet(); } catch (TransactionCommitFailedException e) { LOG.error("Transaction failed: {}", e.toString()); } LOG.info("Transaction succeeded"); }
public void writeFlow(Ipv4Address srcIp, Ipv4Address dstIp, NodeConnectorRef dstNodeConnectorRef, Long meterId) { LOG.info("in flowManager.addFlow"); if(srcIp != null && dstIp.equals(srcIp)) { LOG.info("In addIpv4ToIpv4Flow: No flows added. Source and Destination mac are same."); return; } TableKey flowTableKey = new TableKey(flowTableId); InstanceIdentifier<Flow> flowPath = buildFlowPath(createIpv4Match(srcIp, dstIp), dstNodeConnectorRef, flowTableKey); FlowId flowId = flowPath.firstKeyOf(Flow.class).getId(); LOG.info("flowPath: " + flowPath.toString()); LOG.info("flowId: " + flowId.toString()); Flow flowBody = createIpv4ToIpv4Flow(flowId, flowTableKey.getId(), DEFAULT_PRIORITY, srcIp, dstIp, meterId, dstNodeConnectorRef); LOG.info("flowBody: " + flowBody.toString()); WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.CONFIGURATION, flowPath, flowBody, true); try { writeTransaction.submit().checkedGet(); } catch (TransactionCommitFailedException e) { LOG.error("Transaction failed: {}", e.toString()); } LOG.info("Transaction succeed"); }