Search in sources :

Example 6 with DefaultFlowEntry

use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.

the class FlowRuleManagerTest method getFlowEntry.

@Test
public void getFlowEntry() {
    assertTrue("store should be empty", Sets.newHashSet(service.getFlowEntries(DID)).isEmpty());
    FlowRule f1 = addFlowRule(1);
    FlowRule f2 = addFlowRule(2);
    FlowEntry fe1 = new DefaultFlowEntry(f1);
    FlowEntry fe2 = new DefaultFlowEntry(f2);
    assertEquals("2 rules should exist", 2, flowCount());
    FlowEntry actual1 = service.getFlowEntry(f1);
    FlowEntry actual2 = service.getFlowEntry(f2);
    assertEquals(fe1, actual1);
    assertEquals(fe2, actual2);
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Test(org.junit.Test)

Example 7 with DefaultFlowEntry

use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.

the class ECFlowRuleStoreTest method testPurgeFlowAppId.

/**
 * Tests purge flow for a device and an application.
 */
@Test
public void testPurgeFlowAppId() {
    FlowEntry flowEntry1 = new DefaultFlowEntry(flowRule1);
    flowStoreImpl.addOrUpdateFlowRule(flowEntry1);
    FlowEntry flowEntry2 = new DefaultFlowEntry(flowRule2);
    flowStoreImpl.addOrUpdateFlowRule(flowEntry2);
    FlowEntry flowEntry3 = new DefaultFlowEntry(flowRule3);
    flowStoreImpl.addOrUpdateFlowRule(flowEntry3);
    assertFlowsOnDevice(deviceId, 2);
    assertFlowsOnDevice(deviceId2, 1);
    flowStoreImpl.purgeFlowRules(deviceId, APP_ID_2);
    assertFlowsOnDevice(deviceId, 1);
    assertFlowsOnDevice(deviceId2, 1);
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Test(org.junit.Test)

Example 8 with DefaultFlowEntry

use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.

the class OplinkOpticalFlowRuleProgrammable method parseConnections.

private Collection<FlowEntry> parseConnections() {
    log.debug("Fetch connections...");
    String reply = netconfGet(handler(), getConnectionsFilter());
    List<HierarchicalConfiguration> subtrees = configsAt(reply, KEY_DATA_CONNS);
    Collection<FlowEntry> list = new ArrayList<>();
    for (HierarchicalConfiguration connection : subtrees) {
        list.add(new DefaultFlowEntry(parseConnection(connection), FlowEntry.FlowEntryState.ADDED));
    }
    return list;
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) ArrayList(java.util.ArrayList) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) FlowEntry(org.onosproject.net.flow.FlowEntry)

Example 9 with DefaultFlowEntry

use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.

the class TapiFlowRuleProgrammable method getFlowEntries.

@Override
public Collection<FlowEntry> getFlowEntries() {
    DeviceId deviceId = did();
    // TODO this is a blocking call on ADVA OLS, right now using cache.
    // return getFlowsFromConnectivityServices(deviceId);
    List<FlowEntry> entries = new ArrayList<>();
    Set<FlowRule> rules = getConnectionCache().get(deviceId);
    if (rules != null) {
        rules.forEach(rule -> {
            entries.add(new DefaultFlowEntry(rule, FlowEntry.FlowEntryState.ADDED, 0, 0, 0));
        });
    }
    return entries;
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry)

Example 10 with DefaultFlowEntry

use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.

the class TapiFlowRuleProgrammable method getFlowsFromConnectivityServices.

// Currently uused because get is a blocking call on ADVA
private Collection<FlowEntry> getFlowsFromConnectivityServices(DeviceId deviceId) {
    Set<String> uuids = getUuids(deviceId, handler());
    if (uuids.isEmpty()) {
        return ImmutableList.of();
    }
    DeviceConnectionCache cache = getConnectionCache();
    if (cache.get(deviceId) == null) {
        return ImmutableList.of();
    }
    List<FlowEntry> entries = new ArrayList<>();
    uuids.forEach(uuid -> {
        FlowRule rule = cache.get(deviceId, uuid);
        if (rule != null) {
            entries.add(new DefaultFlowEntry(rule, FlowEntry.FlowEntryState.ADDED, 0, 0, 0));
        } else {
            log.info("Non existing rule for uuid {}", uuid);
        }
    });
    return entries;
}
Also used : DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) ArrayList(java.util.ArrayList) DeviceConnectionCache(org.onosproject.drivers.odtn.impl.DeviceConnectionCache) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry)

Aggregations

DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)44 FlowEntry (org.onosproject.net.flow.FlowEntry)38 FlowRule (org.onosproject.net.flow.FlowRule)31 StoredFlowEntry (org.onosproject.net.flow.StoredFlowEntry)22 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)21 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)8 DeviceId (org.onosproject.net.DeviceId)7 Collectors (java.util.stream.Collectors)6 Map (java.util.Map)4 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)4 DeviceConnectionCache (org.onosproject.drivers.odtn.impl.DeviceConnectionCache)4 PortNumber (org.onosproject.net.PortNumber)4 DeviceService (org.onosproject.net.device.DeviceService)4 FlowId (org.onosproject.net.flow.FlowId)4 Logger (org.slf4j.Logger)4 ImmutableList (com.google.common.collect.ImmutableList)3 IOException (java.io.IOException)3 Objects (java.util.Objects)3 Set (java.util.Set)3