use of org.onosproject.driver.optical.flowrule.CrossConnectFlowRule in project onos by opennetworkinglab.
the class LumentumSdnRoadmFlowRuleProgrammable method applyFlowRules.
@Override
public Collection<FlowRule> applyFlowRules(Collection<FlowRule> rules) {
try {
snmp = new LumentumSnmpDevice(data().deviceId());
} catch (IOException e) {
log.error("Failed to connect to device: ", e);
}
// Line ports
DeviceService deviceService = this.handler().get(DeviceService.class);
List<Port> ports = deviceService.getPorts(data().deviceId());
List<PortNumber> linePorts = ports.subList(ports.size() - 2, ports.size()).stream().map(p -> p.number()).collect(Collectors.toList());
// Apply the valid rules on the device
Collection<FlowRule> added = rules.stream().map(r -> new CrossConnectFlowRule(r, linePorts)).filter(xc -> installCrossConnect(xc)).collect(Collectors.toList());
// Cache the cookie/priority
CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
added.forEach(xc -> cache.set(Objects.hash(data().deviceId(), xc.selector(), xc.treatment()), xc.id(), xc.priority()));
return added;
}
use of org.onosproject.driver.optical.flowrule.CrossConnectFlowRule in project onos by opennetworkinglab.
the class LumentumSdnRoadmFlowRuleProgrammable method removeFlowRules.
@Override
public Collection<FlowRule> removeFlowRules(Collection<FlowRule> rules) {
try {
snmp = new LumentumSnmpDevice(data().deviceId());
} catch (IOException e) {
log.error("Failed to connect to device: ", e);
}
// Line ports
DeviceService deviceService = this.handler().get(DeviceService.class);
List<Port> ports = deviceService.getPorts(data().deviceId());
List<PortNumber> linePorts = ports.subList(ports.size() - 2, ports.size()).stream().map(p -> p.number()).collect(Collectors.toList());
// Apply the valid rules on the device
Collection<FlowRule> removed = rules.stream().map(r -> new CrossConnectFlowRule(r, linePorts)).filter(xc -> removeCrossConnect(xc)).collect(Collectors.toList());
// Remove flow rule from cache
CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
removed.forEach(xc -> cache.remove(Objects.hash(data().deviceId(), xc.selector(), xc.treatment())));
return removed;
}
Aggregations