Search in sources :

Example 21 with FlowEntry

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

the class ECFlowRuleStoreTest method testRemoveFlow.

/**
 * Tests flow removal.
 */
@Test
public void testRemoveFlow() {
    Iterable<FlowEntry> flows1 = flowStoreImpl.getFlowEntries(deviceId);
    for (FlowEntry flow : flows1) {
        flowStoreImpl.removeFlowRule(flow);
    }
    assertFlowsOnDevice(deviceId, 0);
}
Also used : FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Test(org.junit.Test)

Example 22 with FlowEntry

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

the class ECFlowRuleStoreTest method assertFlowsOnDevice.

private void assertFlowsOnDevice(DeviceId deviceId, int nFlows) {
    Iterable<FlowEntry> flows1 = flowStoreImpl.getFlowEntries(deviceId);
    int sum1 = 0;
    for (FlowEntry flowEntry : flows1) {
        sum1++;
    }
    assertThat(sum1, is(nFlows));
}
Also used : FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry)

Example 23 with FlowEntry

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

the class PolatisInternalConnectivity method filterUsedPorts.

private Set<PortNumber> filterUsedPorts(Set<PortNumber> ports, Collection<FlowEntry> flowEntries) {
    if (ports.isEmpty() || flowEntries.isEmpty()) {
        return ports;
    }
    for (FlowEntry flowEntry : flowEntries) {
        PortNumber inputPort = ((PortCriterion) flowEntry.selector().getCriterion(Criterion.Type.IN_PORT)).port();
        ports.remove(inputPort);
        PortNumber outputPort = ((OutputInstruction) flowEntry.treatment().allInstructions().get(0)).port();
        ports.remove(outputPort);
        log.debug("Cross-connection {}-{} removed from output port list", inputPort, outputPort);
    }
    log.debug("Ports after filtering out used ones: " + ports);
    return ports;
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) PortNumber(org.onosproject.net.PortNumber) FlowEntry(org.onosproject.net.flow.FlowEntry)

Example 24 with FlowEntry

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

the class FlowRuleManager method getFlowRulesByGroupId.

@Override
public Iterable<FlowRule> getFlowRulesByGroupId(ApplicationId appId, short groupId) {
    checkPermission(FLOWRULE_READ);
    Set<FlowRule> matches = Sets.newHashSet();
    long toLookUp = ((long) appId.id() << 16) | groupId;
    for (Device d : deviceService.getDevices()) {
        for (FlowEntry flowEntry : store.getFlowEntries(d.id())) {
            if ((flowEntry.id().value() >>> 32) == toLookUp) {
                matches.add(flowEntry);
            }
        }
    }
    return matches;
}
Also used : Device(org.onosproject.net.Device) FlowRule(org.onosproject.net.flow.FlowRule) FlowEntry(org.onosproject.net.flow.FlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry)

Example 25 with FlowEntry

use of org.onosproject.net.flow.FlowEntry 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)

Aggregations

FlowEntry (org.onosproject.net.flow.FlowEntry)122 DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)61 FlowRule (org.onosproject.net.flow.FlowRule)51 Test (org.junit.Test)31 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)31 FlowRuleService (org.onosproject.net.flow.FlowRuleService)26 ArrayList (java.util.ArrayList)24 StoredFlowEntry (org.onosproject.net.flow.StoredFlowEntry)23 DeviceId (org.onosproject.net.DeviceId)20 Device (org.onosproject.net.Device)19 PortNumber (org.onosproject.net.PortNumber)17 Instruction (org.onosproject.net.flow.instructions.Instruction)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)15 List (java.util.List)14 DeviceService (org.onosproject.net.device.DeviceService)14 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)13 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)13 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 HashSet (java.util.HashSet)12 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)11