use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class ResourceDeviceListener method registerPortResource.
private void registerPortResource(Device device, Port port) {
Resource portPath = Resources.discrete(device.id(), port.number()).resource();
if (!adminService.register(portPath)) {
log.error("Failed to register Port: {}", portPath.id());
}
queryBandwidth(device.id(), port.number()).map(bw -> portPath.child(Bandwidth.class, bw.bps())).map(adminService::register).ifPresent(success -> {
if (!success) {
log.error("Failed to register Bandwidth for {}", portPath.id());
}
});
// for VLAN IDs
Set<VlanId> vlans = queryVlanIds(device.id(), port.number());
if (!vlans.isEmpty()) {
boolean success = adminService.register(vlans.stream().map(portPath::child).collect(Collectors.toList()));
if (!success) {
log.error("Failed to register VLAN IDs for {}", portPath.id());
}
}
// for MPLS labels
Set<MplsLabel> mplsLabels = queryMplsLabels(device.id(), port.number());
if (!mplsLabels.isEmpty()) {
boolean success = adminService.register(mplsLabels.stream().map(portPath::child).collect(Collectors.toList()));
if (!success) {
log.error("Failed to register MPLS Labels for {}", portPath.id());
}
}
// for Lambdas
Set<OchSignal> lambdas = queryLambdas(device.id(), port.number());
if (!lambdas.isEmpty()) {
boolean success = adminService.register(lambdas.stream().map(portPath::child).collect(Collectors.toList()));
if (!success) {
log.error("Failed to register lambdas for {}", portPath.id());
}
}
// for Tributary slots
Set<TributarySlot> tSlots = queryTributarySlots(device.id(), port.number());
if (!tSlots.isEmpty()) {
boolean success = adminService.register(tSlots.stream().map(portPath::child).collect(Collectors.toList()));
if (!success) {
log.error("Failed to register tributary slots for {}", portPath.id());
}
}
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class FlowModBuilderVer13 method buildL0Modification.
protected OFAction buildL0Modification(Instruction i) {
L0ModificationInstruction l0m = (L0ModificationInstruction) i;
OFOxm<?> oxm = null;
switch(l0m.subtype()) {
case OCH:
try {
ModOchSignalInstruction modOchSignalInstruction = (ModOchSignalInstruction) l0m;
OchSignal signal = modOchSignalInstruction.lambda();
byte gridType = OpenFlowValueMapper.lookupGridType(signal.gridType());
byte channelSpacing = OpenFlowValueMapper.lookupChannelSpacing(signal.channelSpacing());
oxm = factory().oxms().expOchSigId(new CircuitSignalID(gridType, channelSpacing, (short) signal.spacingMultiplier(), (short) signal.slotGranularity()));
} catch (NoMappingFoundException e) {
log.warn(e.getMessage());
break;
}
break;
default:
log.warn("Unimplemented action type {}.", l0m.subtype());
break;
}
if (oxm != null) {
return factory().actions().buildSetField().setField(oxm).build();
}
return null;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class CriterionJsonMatcher method matchCriterion.
/**
* Matches an Och signal criterion object.
*
* @param criterion criterion to match
* @return true if the JSON matches the criterion, false otherwise.
*/
private boolean matchCriterion(OchSignalCriterion criterion) {
final OchSignal ochSignal = criterion.lambda();
final JsonNode jsonOchSignal = jsonCriterion.get("ochSignalId");
String jsonGridType = jsonOchSignal.get("gridType").textValue();
String jsonChannelSpacing = jsonOchSignal.get("channelSpacing").textValue();
int jsonSpacingMultiplier = jsonOchSignal.get("spacingMultiplier").intValue();
int jsonSlotGranularity = jsonOchSignal.get("slotGranularity").intValue();
boolean equality = Objects.equals(ochSignal.gridType().name(), jsonGridType) && Objects.equals(ochSignal.channelSpacing().name(), jsonChannelSpacing) && Objects.equals(ochSignal.spacingMultiplier(), jsonSpacingMultiplier) && Objects.equals(ochSignal.slotGranularity(), jsonSlotGranularity);
if (!equality) {
String joined = Joiner.on(", ").join(jsonGridType, jsonChannelSpacing, jsonSpacingMultiplier, jsonSlotGranularity);
description.appendText("och signal id was " + joined);
return false;
}
return true;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class FlowRuleCodecTest method codecSigIdCriteriaFlowTest.
/**
* Checks that a rule with a SigId criterion decodes properly.
*
* @throws IOException if the resource cannot be processed
*/
@Test
public void codecSigIdCriteriaFlowTest() throws Exception {
FlowRule rule = getRule("sigid-flow.json");
checkCommonData(rule);
assertThat(rule.selector().criteria().size(), is(1));
Criterion criterion = rule.selector().criteria().iterator().next();
assertThat(criterion.type(), is(Criterion.Type.OCH_SIGID));
Lambda lambda = ((OchSignalCriterion) criterion).lambda();
assertThat(lambda, instanceOf(OchSignal.class));
OchSignal ochSignal = (OchSignal) lambda;
assertThat(ochSignal.spacingMultiplier(), is(3));
assertThat(ochSignal.slotGranularity(), is(4));
assertThat(ochSignal.gridType(), is(GridType.CWDM));
assertThat(ochSignal.channelSpacing(), is(ChannelSpacing.CHL_25GHZ));
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class OpenFlowLambdaQuery method queryLambdas.
@Override
public Set<OchSignal> queryLambdas(PortNumber port) {
Set<OchSignal> signals = new LinkedHashSet<>();
for (OFPortDesc pd : getPortDescs()) {
if (pd.getPortNo().getPortNumber() == port.toLong()) {
for (OFPortDescProp prop : pd.getProperties()) {
if (prop instanceof OFPortDescPropOptical) {
OFPortDescPropOptical oprop = (OFPortDescPropOptical) prop;
long txMin = oprop.getTxMinFreqLmda();
long txMax = oprop.getTxMaxFreqLmda();
long txGrid = oprop.getTxGridFreqLmda();
signals.addAll(signals(txMin, txMax, txGrid));
long rxMin = oprop.getRxMinFreqLmda();
long rxMax = oprop.getRxMaxFreqLmda();
long rxGrid = oprop.getRxGridFreqLmda();
signals.addAll(signals(rxMin, rxMax, rxGrid));
}
}
}
}
return signals;
}
Aggregations