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);
}
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations