Search in sources :

Example 66 with FlowEntity

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);
}
Also used : BigInteger(java.math.BigInteger) MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 67 with 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);
}
Also used : MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 68 with 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);
}
Also used : FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 69 with FlowEntity

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
    }
}
Also used : XtendBeanGenerator(ch.vorburger.xtendbeans.XtendBeanGenerator) ComparisonFailure(org.junit.ComparisonFailure) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 70 with FlowEntity

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());
}
Also used : FlowEntityBuilder(org.opendaylight.genius.mdsalutil.FlowEntityBuilder) ArrayList(java.util.ArrayList) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) ActionNxConntrack(org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack) InstructionApplyActions(org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity) Test(org.junit.Test)

Aggregations

FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)119 ArrayList (java.util.ArrayList)56 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)52 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)50 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)37 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)37 BigInteger (java.math.BigInteger)23 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)22 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)17 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)14 ActionPuntToController (org.opendaylight.genius.mdsalutil.actions.ActionPuntToController)12 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 MatchTunnelId (org.opendaylight.genius.mdsalutil.matches.MatchTunnelId)7 Test (org.junit.Test)6 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)6 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)6 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)6 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)6 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)5