Search in sources :

Example 6 with UpdatedFlow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow in project openflowplugin by opendaylight.

the class FlowCreatorUtil method canModifyFlow.

/**
 * Determine whether a flow entry can be modified or not.
 *
 * @param original An original flow entry.
 * @param updated  An updated flow entry.
 * @param version  Protocol version.
 * @return {@code true} only if a flow entry can be modified.
 */
public static boolean canModifyFlow(OriginalFlow original, UpdatedFlow updated, Short version) {
    // flags, and cookie.
    if (!Objects.equals(original.getMatch(), updated.getMatch()) || !equalsWithDefault(original.getPriority(), updated.getPriority(), FlowConvertor.DEFAULT_PRIORITY) || !equalsWithDefault(original.getIdleTimeout(), updated.getIdleTimeout(), FlowConvertor.DEFAULT_IDLE_TIMEOUT) || !equalsWithDefault(original.getHardTimeout(), updated.getHardTimeout(), FlowConvertor.DEFAULT_HARD_TIMEOUT) || !equalsFlowModFlags(original.getFlags(), updated.getFlags())) {
        return false;
    }
    if (!Boolean.TRUE.equals(updated.isStrict()) && version != null && version.shortValue() != OFConstants.OFP_VERSION_1_0) {
        FlowCookie cookieMask = updated.getCookieMask();
        if (cookieMask != null) {
            BigInteger mask = cookieMask.getValue();
            if (mask != null && !mask.equals(BigInteger.ZERO)) {
                // Allow FLOW_MOD with filtering by cookie.
                return true;
            }
        }
    }
    FlowCookie oc = original.getCookie();
    FlowCookie uc = updated.getCookie();
    BigInteger orgCookie;
    BigInteger updCookie;
    if (oc == null) {
        if (uc == null) {
            return true;
        }
        orgCookie = OFConstants.DEFAULT_COOKIE;
        updCookie = uc.getValue();
    } else {
        orgCookie = oc.getValue();
        updCookie = (uc == null) ? OFConstants.DEFAULT_COOKIE : uc.getValue();
    }
    return equalsWithDefault(orgCookie, updCookie, OFConstants.DEFAULT_COOKIE);
}
Also used : FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) BigInteger(java.math.BigInteger)

Example 7 with UpdatedFlow

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow in project openflowplugin by opendaylight.

the class FlowConvertorTest method testOnlyModifyStrictCommand.

/**
 * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testOnlyModifyStrictCommand() {
    UpdatedFlowBuilder flowBuilder = new UpdatedFlowBuilder();
    flowBuilder.setStrict(true);
    UpdatedFlow flow = flowBuilder.build();
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    data.setDatapathId(new BigInteger("42"));
    List<FlowModInputBuilder> flowMod = convert(flow, data);
    Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
    Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
}
Also used : UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) BigInteger(java.math.BigInteger) FlowModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder) UpdatedFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder) Test(org.junit.Test)

Aggregations

UpdatedFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow)5 OriginalFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow)4 BigInteger (java.math.BigInteger)3 Test (org.junit.Test)3 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)3 UpdateFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput)3 UpdatedFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 ArrayList (java.util.ArrayList)2 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)2 UpdateFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)2 OriginalFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder)2 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)2 FlowModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 List (java.util.List)1 Map (java.util.Map)1 CrudCounts (org.opendaylight.openflowplugin.applications.frsync.util.CrudCounts)1 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)1 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)1