Search in sources :

Example 1 with CrossConnectFlowRule

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;
}
Also used : GridType(org.onosproject.net.GridType) Arrays(java.util.Arrays) FlowRuleProgrammable(org.onosproject.net.flow.FlowRuleProgrammable) TreeEvent(org.snmp4j.util.TreeEvent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) FlowEntry(org.onosproject.net.flow.FlowEntry) PDU(org.snmp4j.PDU) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) VariableBinding(org.snmp4j.smi.VariableBinding) Criteria(org.onosproject.net.flow.criteria.Criteria) LinkedList(java.util.LinkedList) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OchSignalType(org.onosproject.net.OchSignalType) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Logger(org.slf4j.Logger) Collection(java.util.Collection) IOException(java.io.IOException) Integer32(org.snmp4j.smi.Integer32) Collectors(java.util.stream.Collectors) FlowId(org.onosproject.net.flow.FlowId) OchSignal(org.onosproject.net.OchSignal) Objects(java.util.Objects) UnsignedInteger32(org.snmp4j.smi.UnsignedInteger32) List(java.util.List) ResponseEvent(org.snmp4j.event.ResponseEvent) FlowRule(org.onosproject.net.flow.FlowRule) ChannelSpacing(org.onosproject.net.ChannelSpacing) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Collections(java.util.Collections) OID(org.snmp4j.smi.OID) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) IOException(java.io.IOException) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber)

Example 2 with CrossConnectFlowRule

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;
}
Also used : GridType(org.onosproject.net.GridType) Arrays(java.util.Arrays) FlowRuleProgrammable(org.onosproject.net.flow.FlowRuleProgrammable) TreeEvent(org.snmp4j.util.TreeEvent) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) FlowEntry(org.onosproject.net.flow.FlowEntry) PDU(org.snmp4j.PDU) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) VariableBinding(org.snmp4j.smi.VariableBinding) Criteria(org.onosproject.net.flow.criteria.Criteria) LinkedList(java.util.LinkedList) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) OchSignalType(org.onosproject.net.OchSignalType) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) Logger(org.slf4j.Logger) Collection(java.util.Collection) IOException(java.io.IOException) Integer32(org.snmp4j.smi.Integer32) Collectors(java.util.stream.Collectors) FlowId(org.onosproject.net.flow.FlowId) OchSignal(org.onosproject.net.OchSignal) Objects(java.util.Objects) UnsignedInteger32(org.snmp4j.smi.UnsignedInteger32) List(java.util.List) ResponseEvent(org.snmp4j.event.ResponseEvent) FlowRule(org.onosproject.net.flow.FlowRule) ChannelSpacing(org.onosproject.net.ChannelSpacing) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Collections(java.util.Collections) OID(org.snmp4j.smi.OID) CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) IOException(java.io.IOException) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)2 Lists (com.google.common.collect.Lists)2 IOException (java.io.IOException)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Objects (java.util.Objects)2 Collectors (java.util.stream.Collectors)2 Pair (org.apache.commons.lang3.tuple.Pair)2 CrossConnectCache (org.onosproject.driver.optical.flowrule.CrossConnectCache)2 CrossConnectFlowRule (org.onosproject.driver.optical.flowrule.CrossConnectFlowRule)2 ChannelSpacing (org.onosproject.net.ChannelSpacing)2 GridType (org.onosproject.net.GridType)2 OchSignal (org.onosproject.net.OchSignal)2 OchSignalType (org.onosproject.net.OchSignalType)2 Port (org.onosproject.net.Port)2 PortNumber (org.onosproject.net.PortNumber)2 DeviceService (org.onosproject.net.device.DeviceService)2