Search in sources :

Example 1 with FlowId

use of org.onosproject.net.flow.FlowId 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);
    }
}
Also used : FlowId(org.onosproject.net.flow.FlowId) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DeviceId(org.onosproject.net.DeviceId)

Example 2 with FlowId

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

the class SimpleFlowRuleStore method storeFlowRuleInternal.

private void storeFlowRuleInternal(FlowRule rule) {
    StoredFlowEntry f = new DefaultFlowEntry(rule);
    final DeviceId did = f.deviceId();
    final FlowId fid = f.id();
    List<StoredFlowEntry> existing = getFlowEntries(did, fid);
    synchronized (existing) {
        for (StoredFlowEntry fe : existing) {
            if (fe.equals(rule)) {
                // was already there? ignore
                return;
            }
        }
        // new flow rule added
        existing.add(f);
    }
}
Also used : FlowId(org.onosproject.net.flow.FlowId) StoredFlowEntry(org.onosproject.net.flow.StoredFlowEntry) DefaultFlowEntry(org.onosproject.net.flow.DefaultFlowEntry) DeviceId(org.onosproject.net.DeviceId)

Example 3 with FlowId

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

the class LumentumSdnRoadmFlowRuleProgrammable method fetchRules.

// Returns the currently installed flow entries on the device.
private List<FlowRule> fetchRules(OID oid, boolean isAdd, PortNumber linePort) {
    List<FlowRule> rules = new LinkedList<>();
    for (TreeEvent event : snmp.get(oid)) {
        if (event == null) {
            continue;
        }
        VariableBinding[] varBindings = event.getVariableBindings();
        for (VariableBinding varBinding : varBindings) {
            CrossConnectCache cache = this.handler().get(CrossConnectCache.class);
            if (varBinding.getVariable().toInt() == IN_SERVICE) {
                int channel = varBinding.getOid().removeLast();
                PortNumber addDropPort = getAddDropPort(channel, isAdd);
                if (addDropPort == null) {
                    continue;
                }
                TrafficSelector selector = DefaultTrafficSelector.builder().matchInPort(isAdd ? addDropPort : linePort).add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID)).add(Criteria.matchLambda(toOchSignal(channel))).build();
                TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(isAdd ? linePort : addDropPort).build();
                // Lookup flow ID and priority
                int hash = Objects.hash(data().deviceId(), selector, treatment);
                Pair<FlowId, Integer> lookup = cache.get(hash);
                if (lookup == null) {
                    continue;
                }
                FlowRule fr = DefaultFlowRule.builder().forDevice(data().deviceId()).makePermanent().withSelector(selector).withTreatment(treatment).withPriority(lookup.getRight()).withCookie(lookup.getLeft().value()).build();
                rules.add(fr);
            }
        }
    }
    return rules;
}
Also used : CrossConnectCache(org.onosproject.driver.optical.flowrule.CrossConnectCache) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) LinkedList(java.util.LinkedList) TreeEvent(org.snmp4j.util.TreeEvent) FlowId(org.onosproject.net.flow.FlowId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CrossConnectFlowRule(org.onosproject.driver.optical.flowrule.CrossConnectFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber) VariableBinding(org.snmp4j.smi.VariableBinding)

Example 4 with FlowId

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

the class RoadmManager method createConnection.

@Override
public FlowId createConnection(DeviceId deviceId, int priority, boolean isPermanent, int timeout, PortNumber inPort, PortNumber outPort, OchSignal ochSignal, Double attenuation) {
    checkNotNull(deviceId);
    checkNotNull(inPort);
    checkNotNull(outPort);
    FlowId flowId = createConnection(deviceId, priority, isPermanent, timeout, inPort, outPort, ochSignal);
    delayedSetAttenuation(deviceId, outPort, ochSignal, attenuation);
    return flowId;
}
Also used : FlowId(org.onosproject.net.flow.FlowId)

Example 5 with FlowId

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

the class RoadmCrossConnectCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    DeviceService deviceService = AbstractShellCommand.get(DeviceService.class);
    if (deviceService.isAvailable(DeviceId.deviceId(deviceId))) {
        if (deviceService.getPort(DeviceId.deviceId(deviceId), PortNumber.portNumber(srcPort)).isEnabled()) {
            if (deviceService.getPort(DeviceId.deviceId(deviceId), PortNumber.portNumber(dstPort)).isEnabled()) {
                if (operation.equals(CREATE)) {
                    FlowId check = addRule();
                    if (check != null) {
                        print("Rule %s was successfully added", check.toString());
                        log.info("Rule {} was successfully added", check.toString());
                    } else {
                        print("Your rule wasn't added. Something went wrong during the process " + "(issue on the driver side).");
                        log.error("Your rule wasn't added. " + "Something went wrong during the process (issue on the driver side).");
                    }
                } else if (operation.equals(REMOVE)) {
                    FlowId check = dropRule();
                    if (check != null) {
                        print("Rule %s was successfully dropped", check.toString());
                        log.info("Rule {} was successfully dropped", check.toString());
                    } else {
                        print("Your rule wasn't dropped. No match found.");
                        log.error("Your rule wasn't dropped. No match found.");
                    }
                } else {
                    print("\n Unspecified operation -- %s -- :( \n Try again! \n", operation);
                    log.debug("\n Unspecified operation -- {} -- :( \n Try again! \n", operation);
                }
            } else {
                log.error("Destination port {} is not enabled", dstPort);
            }
        } else {
            log.error("Source port {} is not enabled", srcPort);
        }
    } else {
        log.error("Device {} is not available", deviceId);
    }
}
Also used : FlowId(org.onosproject.net.flow.FlowId) DeviceService(org.onosproject.net.device.DeviceService)

Aggregations

FlowId (org.onosproject.net.flow.FlowId)8 DeviceId (org.onosproject.net.DeviceId)4 PortNumber (org.onosproject.net.PortNumber)3 OchSignal (org.onosproject.net.OchSignal)2 DefaultFlowEntry (org.onosproject.net.flow.DefaultFlowEntry)2 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)2 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)2 StoredFlowEntry (org.onosproject.net.flow.StoredFlowEntry)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)2 RoadmService (org.onosproject.roadm.RoadmService)2 LinkedList (java.util.LinkedList)1 Frequency (org.onlab.util.Frequency)1 CrossConnectCache (org.onosproject.driver.optical.flowrule.CrossConnectCache)1 CrossConnectFlowRule (org.onosproject.driver.optical.flowrule.CrossConnectFlowRule)1 DeviceService (org.onosproject.net.device.DeviceService)1 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)1 FlowEntry (org.onosproject.net.flow.FlowEntry)1 FlowRule (org.onosproject.net.flow.FlowRule)1 FlowRuleService (org.onosproject.net.flow.FlowRuleService)1