use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class VirtualNetworkFlowRuleManagerTest method purgeFlowRules.
@Test
public void purgeFlowRules() {
FlowRule f1 = addFlowRule(1);
FlowRule f2 = addFlowRule(2);
FlowRule f3 = addFlowRule(3);
assertEquals("3 rules should exist", 3, flowCount(vnetFlowRuleService1));
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
FlowEntry fe3 = new DefaultFlowEntry(f3);
providerService1.pushFlowMetrics(VDID1, ImmutableList.of(fe1, fe2, fe3));
validateEvents(listener1, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED, RULE_ADDED);
vnetFlowRuleService1.purgeFlowRules(VDID1);
assertEquals("0 rule should exist", 0, flowCount(vnetFlowRuleService1));
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class SimpleVirtualFlowRuleStore method storeFlowRuleInternal.
private void storeFlowRuleInternal(NetworkId networkId, FlowRule rule) {
StoredFlowEntry f = new DefaultFlowEntry(rule);
final DeviceId did = f.deviceId();
final FlowId fid = f.id();
List<StoredFlowEntry> existing = getFlowEntries(networkId, did, fid);
synchronized (existing) {
for (StoredFlowEntry fe : existing) {
if (fe.equals(rule)) {
// was already there? ignore
return;
}
}
// new flow rule added
existing.add(f);
}
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class CzechLightFlowRuleProgrammable method getFlowEntries.
@Override
public Collection<FlowEntry> getFlowEntries() {
if (deviceType() == CzechLightDiscovery.DeviceType.INLINE_AMP || deviceType() == CzechLightDiscovery.DeviceType.COHERENT_ADD_DROP) {
final var data = getConnectionCache().get(data().deviceId());
if (data == null) {
return new ArrayList<>();
}
return data.stream().map(rule -> new DefaultFlowEntry(rule)).collect(Collectors.toList());
}
HierarchicalConfiguration xml;
try {
xml = doGetSubtree(CzechLightDiscovery.CHANNEL_DEFS_FILTER + CzechLightDiscovery.MC_ROUTING_FILTER);
} catch (NetconfException e) {
log.error("Cannot read data from NETCONF: {}", e);
return new ArrayList<>();
}
final var allChannels = MediaChannelDefinition.parseChannelDefinitions(xml);
Collection<FlowEntry> list = new ArrayList<>();
final var allMCs = xml.configurationsAt("data.media-channels");
allMCs.stream().map(cfg -> confToMCRouting(ELEMENT_ADD, allChannels, cfg)).filter(Objects::nonNull).forEach(flow -> {
log.debug("{}: found ADD: {}", data().deviceId(), flow.toString());
list.add(new DefaultFlowEntry(asFlowRule(Direction.ADD, flow), FlowEntry.FlowEntryState.ADDED));
});
allMCs.stream().map(cfg -> confToMCRouting(ELEMENT_DROP, allChannels, cfg)).filter(Objects::nonNull).forEach(flow -> {
log.debug("{}: found DROP: {}", data().deviceId(), flow.toString());
list.add(new DefaultFlowEntry(asFlowRule(Direction.DROP, flow), FlowEntry.FlowEntryState.ADDED));
});
return list;
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class FlowRuleManagerTest method flowMetrics.
@Test
public void flowMetrics() {
FlowRule f1 = flowRule(1, 1);
FlowRule f2 = flowRule(2, 2);
FlowRule f3 = flowRule(3, 3);
mgr.applyFlowRules(f1, f2, f3);
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
// FlowRule updatedF1 = flowRule(f1, FlowRuleState.ADDED);
// FlowRule updatedF2 = flowRule(f2, FlowRuleState.ADDED);
providerService.pushFlowMetrics(DID, Lists.newArrayList(fe1, fe2));
assertTrue("Entries should be added.", validateState(ImmutableMap.of(f1, FlowEntryState.ADDED, f2, FlowEntryState.ADDED, f3, FlowEntryState.PENDING_ADD)));
validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED, RULE_ADD_REQUESTED);
}
use of org.onosproject.net.flow.DefaultFlowEntry in project onos by opennetworkinglab.
the class FlowRuleManagerTest method purgeFlowRules.
@Test
public void purgeFlowRules() {
FlowRule f1 = addFlowRule(1);
FlowRule f2 = addFlowRule(2);
FlowRule f3 = addFlowRule(3);
assertEquals("3 rules should exist", 3, flowCount());
FlowEntry fe1 = new DefaultFlowEntry(f1);
FlowEntry fe2 = new DefaultFlowEntry(f2);
FlowEntry fe3 = new DefaultFlowEntry(f3);
providerService.pushFlowMetrics(DID, ImmutableList.of(fe1, fe2, fe3));
validateEvents(RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADD_REQUESTED, RULE_ADDED, RULE_ADDED, RULE_ADDED);
mgr.purgeFlowRules(DID);
assertEquals("0 rule should exist", 0, flowCount());
}
Aggregations