use of org.opendaylight.genius.mdsalutil.FlowEntity in project netvirt by opendaylight.
the class QosNeutronUtils method removeStaleFlowEntry.
public void removeStaleFlowEntry(Interface intrf) {
List<MatchInfo> matches = new ArrayList<>();
BigInteger dpnId = getDpIdFromInterface(intrf);
Integer ifIndex = intrf.getIfIndex();
matches.add(new MatchMetadata(MetaDataUtil.getLportTagMetaData(ifIndex), MetaDataUtil.METADATA_MASK_LPORT_TAG));
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.QOS_DSCP_TABLE, getQosFlowId(NwConstants.QOS_DSCP_TABLE, dpnId, ifIndex), QosConstants.QOS_DEFAULT_FLOW_PRIORITY, "QoSRemoveFlow", 0, 0, NwConstants.COOKIE_QOS_TABLE, matches, null);
mdsalUtils.removeFlow(flowEntity);
}
use of org.opendaylight.genius.mdsalutil.FlowEntity in project netvirt by opendaylight.
the class QosNodeListener method createTableMissEntry.
public void createTableMissEntry(BigInteger dpnId) {
List<MatchInfo> matches = new ArrayList<>();
List<InstructionInfo> instructions = new ArrayList<>();
List<ActionInfo> actionsInfos = new ArrayList<>();
actionsInfos.add(new ActionNxResubmit(NwConstants.LPORT_DISPATCHER_TABLE));
instructions.add(new InstructionApplyActions(actionsInfos));
FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpnId, NwConstants.QOS_DSCP_TABLE, "QoSTableMissFlow", 0, "QoS Table Miss Flow", 0, 0, NwConstants.COOKIE_QOS_TABLE, matches, instructions);
mdsalUtils.installFlow(flowEntity);
}
use of org.opendaylight.genius.mdsalutil.FlowEntity in project genius by opendaylight.
the class MdSalUtilTest method testInstallFlow.
@Test
public void testInstallFlow() throws Exception {
String dpnId = "openflow:1";
String tableId1 = "12";
// Install Flow 1
FlowEntity testFlow1 = createFlowEntity(dpnId, tableId1);
mdSalMgr.installFlowInternal(testFlow1).get();
flowFwder.awaitDataChangeCount(1);
// Install FLow 2
String tableId2 = "13";
FlowEntity testFlow2 = createFlowEntity(dpnId, tableId2);
mdSalMgr.installFlowInternal(testFlow2).get();
flowFwder.awaitDataChangeCount(2);
}
use of org.opendaylight.genius.mdsalutil.FlowEntity in project genius by opendaylight.
the class TestIMdsalApiManager method assertFlowsInAnyOrder.
// ComparisonException doesn’t allow us to keep the cause (which we don’t care about anyway)
@SuppressWarnings("checkstyle:AvoidHidingCauseException")
public synchronized void assertFlowsInAnyOrder(Iterable<FlowEntity> expectedFlows) {
checkNonEmptyFlows(expectedFlows);
// TODO Support Iterable <-> List directly within XtendBeanGenerator
List<FlowEntity> expectedFlowsAsNewArrayList = Lists.newArrayList(expectedFlows);
List<FlowEntity> sortedFlows = sortFlows(flows);
List<FlowEntity> sortedExpectedFlows = sortFlows(expectedFlowsAsNewArrayList);
// System#identityHashCode even less so.
try {
assertThat(sortedFlows).containsExactlyElementsIn(sortedExpectedFlows);
} catch (AssertionError e) {
// We LOG the AssertionError just for clarity why containsExactlyElementsIn() failed
LOG.warn("assert containsExactlyElementsIn() failed", e);
// We LOG the expected and actual flow in case of a failed assertion
// because, even though that is typically just a HUGE String that's
// hard to read (the diff printed subsequently by assertEqualBeans
// is, much, more readable), there are cases when looking more closely
// at the full toString() output of the flows is still useful, so:
// TIP: Use e.g. 'wdiff -n expected.txt actual.txt | colordiff' to compare these!
LOG.warn("assert failed [order ignored!]; expected flows: {}", sortedExpectedFlows);
LOG.warn("assert failed [order ignored!]; actual flows : {}", sortedFlows);
// The point of now also doing assertEqualBeans() is just that its output,
// in case of a comparison failure, is *A LOT* more clearly readable
// than what G Truth (or Hamcrest) can do based on toString.
assertEqualBeans(sortedExpectedFlows, sortedFlows);
if (sortedExpectedFlows.toString().equals(sortedFlows.toString()) && !sortedExpectedFlows.equals(sortedFlows)) {
fail("Suspected toString, missing getter, equals (hashCode) bug in FlowEntity related class!!! :-(");
}
throw new ComparisonFailure("assertEqualBeans() MUST fail - given that the assertThat.containsExactlyElementsIn() just failed!" + // AssertDataObjects, but for FlowEntity it's the same... it only makes a difference for DataObjects
" What is missing in: " + new XtendBeanGenerator().getExpression(sortedFlows), sortedExpectedFlows.toString(), sortedFlows.toString());
// If this ^^^ occurs, then there is probably a bug in ch.vorburger.xtendbeans
}
}
use of org.opendaylight.genius.mdsalutil.FlowEntity in project genius by opendaylight.
the class ActionInfoImmutableTest method actionInfoActionKeyDoesNotMagicallyChangeOnFlowEntityGetFlowBuilder.
@Test
public void actionInfoActionKeyDoesNotMagicallyChangeOnFlowEntityGetFlowBuilder() {
FlowEntityBuilder flowEntityBuilder = new FlowEntityBuilder().setDpnId(BigInteger.valueOf(123L)).setTableId((short) 1).setPriority(2).setFlowName("TEST-NAME").setFlowId("TEST-ID").setCookie(BigInteger.valueOf(110100480L));
ActionInfo actionInfo = new ActionNxConntrack(27, 1, 0, 0, (short) 255);
List<ActionInfo> actionInfos = new ArrayList<>();
actionInfos.add(actionInfo);
flowEntityBuilder.addInstructionInfoList(new InstructionApplyActions(actionInfos));
FlowEntity flowEntity = flowEntityBuilder.build();
assertEquals(27, ((InstructionApplyActions) flowEntity.getInstructionInfoList().get(0)).getActionInfos().get(0).getActionKey());
flowEntity.getFlowBuilder();
assertEquals(27, ((InstructionApplyActions) flowEntity.getInstructionInfoList().get(0)).getActionInfos().get(0).getActionKey());
flowEntity.getFlowBuilder();
assertEquals(27, ((InstructionApplyActions) flowEntity.getInstructionInfoList().get(0)).getActionInfos().get(0).getActionKey());
}
Aggregations