mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-21 12:22:18 +02:00
Do not create wavelength-based match/actions for wavelength-transparent devices.
Change-Id: I665daad954210101cf0ab04671673bf7cb1e4e46
This commit is contained in:
parent
b27ad7d992
commit
b6f95e2433
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.onosproject.net.optical.intent.impl.compiler;
|
package org.onosproject.net.optical.intent.impl.compiler;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import org.apache.felix.scr.annotations.Activate;
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
import org.apache.felix.scr.annotations.Component;
|
import org.apache.felix.scr.annotations.Component;
|
||||||
@ -51,6 +52,7 @@ import java.util.Collections;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Component(immediate = true)
|
@Component(immediate = true)
|
||||||
public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathIntent> {
|
public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathIntent> {
|
||||||
@ -67,6 +69,12 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
protected DeviceService deviceService = new DeviceServiceAdapter();
|
protected DeviceService deviceService = new DeviceServiceAdapter();
|
||||||
|
|
||||||
private ApplicationId appId;
|
private ApplicationId appId;
|
||||||
|
// Devices which are wavelength transparent and thus do not require wavelength-based match/actions
|
||||||
|
private static final Set<Type> TRANSPARENT_DEVICES =
|
||||||
|
ImmutableSet.of(Type.OPTICAL_AMPLIFIER, Type.FIBER_SWITCH);
|
||||||
|
// Devices which don't accept flow rules
|
||||||
|
private static final Set<Type> NO_FLOWRULE_DEVICES =
|
||||||
|
ImmutableSet.of(Type.OPTICAL_AMPLIFIER);
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
public void activate() {
|
public void activate() {
|
||||||
@ -100,14 +108,6 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean blockFlowRule(DeviceId deviceId) {
|
|
||||||
Type devType = Optional.ofNullable(deviceService.getDevice(deviceId))
|
|
||||||
.map(Device::type)
|
|
||||||
.orElse(Device.Type.OTHER);
|
|
||||||
// TODO add condition for protection switch
|
|
||||||
return devType == Device.Type.OPTICAL_AMPLIFIER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create rules for the forward path of the intent.
|
* Create rules for the forward path of the intent.
|
||||||
*
|
*
|
||||||
@ -123,7 +123,9 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
|
|
||||||
for (Link link : intent.path().links()) {
|
for (Link link : intent.path().links()) {
|
||||||
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
|
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
|
||||||
|
if (!isTransparent(link.src().deviceId())) {
|
||||||
treatmentBuilder.add(Instructions.modL0Lambda(intent.lambda()));
|
treatmentBuilder.add(Instructions.modL0Lambda(intent.lambda()));
|
||||||
|
}
|
||||||
treatmentBuilder.setOutput(link.src().port());
|
treatmentBuilder.setOutput(link.src().port());
|
||||||
|
|
||||||
FlowRule rule = DefaultFlowRule.builder()
|
FlowRule rule = DefaultFlowRule.builder()
|
||||||
@ -135,15 +137,17 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
.makePermanent()
|
.makePermanent()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (!blockFlowRule(current.deviceId())) {
|
if (!isNoFlowRule(current.deviceId())) {
|
||||||
rules.add(rule);
|
rules.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
current = link.dst();
|
current = link.dst();
|
||||||
selectorBuilder.matchInPort(link.dst().port());
|
selectorBuilder.matchInPort(link.dst().port());
|
||||||
|
if (!isTransparent(link.dst().deviceId())) {
|
||||||
selectorBuilder.add(Criteria.matchLambda(intent.lambda()));
|
selectorBuilder.add(Criteria.matchLambda(intent.lambda()));
|
||||||
selectorBuilder.add(Criteria.matchOchSignalType(intent.signalType()));
|
selectorBuilder.add(Criteria.matchOchSignalType(intent.signalType()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build the egress ROADM rule
|
// Build the egress ROADM rule
|
||||||
TrafficTreatment.Builder treatmentLast = DefaultTrafficTreatment.builder();
|
TrafficTreatment.Builder treatmentLast = DefaultTrafficTreatment.builder();
|
||||||
@ -158,7 +162,7 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
.makePermanent()
|
.makePermanent()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (!blockFlowRule(intent.dst().deviceId())) {
|
if (!isNoFlowRule(intent.dst().deviceId())) {
|
||||||
rules.add(rule);
|
rules.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +184,9 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
|
|
||||||
for (Link link : Lists.reverse(intent.path().links())) {
|
for (Link link : Lists.reverse(intent.path().links())) {
|
||||||
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
|
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
|
||||||
|
if (isTransparent(link.dst().deviceId())) {
|
||||||
treatmentBuilder.add(Instructions.modL0Lambda(intent.lambda()));
|
treatmentBuilder.add(Instructions.modL0Lambda(intent.lambda()));
|
||||||
|
}
|
||||||
treatmentBuilder.setOutput(link.dst().port());
|
treatmentBuilder.setOutput(link.dst().port());
|
||||||
|
|
||||||
FlowRule rule = DefaultFlowRule.builder()
|
FlowRule rule = DefaultFlowRule.builder()
|
||||||
@ -192,15 +198,17 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
.makePermanent()
|
.makePermanent()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (!blockFlowRule(current.deviceId())) {
|
if (!isNoFlowRule(current.deviceId())) {
|
||||||
rules.add(rule);
|
rules.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
current = link.src();
|
current = link.src();
|
||||||
selectorBuilder.matchInPort(link.src().port());
|
selectorBuilder.matchInPort(link.src().port());
|
||||||
|
if (isTransparent(link.src().deviceId())) {
|
||||||
selectorBuilder.add(Criteria.matchLambda(intent.lambda()));
|
selectorBuilder.add(Criteria.matchLambda(intent.lambda()));
|
||||||
selectorBuilder.add(Criteria.matchOchSignalType(intent.signalType()));
|
selectorBuilder.add(Criteria.matchOchSignalType(intent.signalType()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build the egress ROADM rule
|
// Build the egress ROADM rule
|
||||||
TrafficTreatment.Builder treatmentLast = DefaultTrafficTreatment.builder();
|
TrafficTreatment.Builder treatmentLast = DefaultTrafficTreatment.builder();
|
||||||
@ -215,10 +223,36 @@ public class OpticalPathIntentCompiler implements IntentCompiler<OpticalPathInte
|
|||||||
.makePermanent()
|
.makePermanent()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
if (!blockFlowRule(intent.src().deviceId())) {
|
if (!isNoFlowRule(intent.src().deviceId())) {
|
||||||
rules.add(rule);
|
rules.add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if device does not accept flow rules, false otherwise.
|
||||||
|
*
|
||||||
|
* @param deviceId the device
|
||||||
|
* @return true if device does not accept flow rule, false otherwise
|
||||||
|
*/
|
||||||
|
private boolean isNoFlowRule(DeviceId deviceId) {
|
||||||
|
return NO_FLOWRULE_DEVICES.contains(
|
||||||
|
Optional.ofNullable(deviceService.getDevice(deviceId))
|
||||||
|
.map(Device::type)
|
||||||
|
.orElse(Type.OTHER));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if device is wavelength transparent, false otherwise.
|
||||||
|
*
|
||||||
|
* @param deviceId the device
|
||||||
|
* @return true if wavelength transparent, false otherwise
|
||||||
|
*/
|
||||||
|
private boolean isTransparent(DeviceId deviceId) {
|
||||||
|
return TRANSPARENT_DEVICES.contains(
|
||||||
|
Optional.ofNullable(deviceService.getDevice(deviceId))
|
||||||
|
.map(Device::type)
|
||||||
|
.orElse(Type.OTHER));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user