Search in sources :

Example 41 with OchSignal

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());
        }
    }
}
Also used : Bandwidth(org.onlab.util.Bandwidth) Resource(org.onosproject.net.resource.Resource) DiscreteResource(org.onosproject.net.resource.DiscreteResource) TributarySlot(org.onosproject.net.TributarySlot) MplsLabel(org.onlab.packet.MplsLabel) OchSignal(org.onosproject.net.OchSignal) VlanId(org.onlab.packet.VlanId)

Example 42 with OchSignal

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;
}
Also used : ModOchSignalInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction) OchSignal(org.onosproject.net.OchSignal) CircuitSignalID(org.projectfloodlight.openflow.types.CircuitSignalID) L0ModificationInstruction(org.onosproject.net.flow.instructions.L0ModificationInstruction) NoMappingFoundException(org.onosproject.provider.of.flow.util.NoMappingFoundException)

Example 43 with OchSignal

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;
}
Also used : OchSignal(org.onosproject.net.OchSignal) JsonNode(com.fasterxml.jackson.databind.JsonNode) HexString(org.onlab.util.HexString)

Example 44 with OchSignal

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));
}
Also used : OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) IPDscpCriterion(org.onosproject.net.flow.criteria.IPDscpCriterion) VlanPcpCriterion(org.onosproject.net.flow.criteria.VlanPcpCriterion) IPProtocolCriterion(org.onosproject.net.flow.criteria.IPProtocolCriterion) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) IcmpTypeCriterion(org.onosproject.net.flow.criteria.IcmpTypeCriterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) IPCriterion(org.onosproject.net.flow.criteria.IPCriterion) IcmpCodeCriterion(org.onosproject.net.flow.criteria.IcmpCodeCriterion) IPv6NDTargetAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDTargetAddressCriterion) Icmpv6TypeCriterion(org.onosproject.net.flow.criteria.Icmpv6TypeCriterion) SctpPortCriterion(org.onosproject.net.flow.criteria.SctpPortCriterion) TunnelIdCriterion(org.onosproject.net.flow.criteria.TunnelIdCriterion) MplsCriterion(org.onosproject.net.flow.criteria.MplsCriterion) IPv6NDLinkLayerAddressCriterion(org.onosproject.net.flow.criteria.IPv6NDLinkLayerAddressCriterion) EthCriterion(org.onosproject.net.flow.criteria.EthCriterion) IPEcnCriterion(org.onosproject.net.flow.criteria.IPEcnCriterion) OduSignalTypeCriterion(org.onosproject.net.flow.criteria.OduSignalTypeCriterion) TcpPortCriterion(org.onosproject.net.flow.criteria.TcpPortCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) EthTypeCriterion(org.onosproject.net.flow.criteria.EthTypeCriterion) OduSignalIdCriterion(org.onosproject.net.flow.criteria.OduSignalIdCriterion) UdpPortCriterion(org.onosproject.net.flow.criteria.UdpPortCriterion) Icmpv6CodeCriterion(org.onosproject.net.flow.criteria.Icmpv6CodeCriterion) OchSignalTypeCriterion(org.onosproject.net.flow.criteria.OchSignalTypeCriterion) IPv6FlowLabelCriterion(org.onosproject.net.flow.criteria.IPv6FlowLabelCriterion) IPv6ExthdrFlagsCriterion(org.onosproject.net.flow.criteria.IPv6ExthdrFlagsCriterion) VlanIdCriterion(org.onosproject.net.flow.criteria.VlanIdCriterion) OchSignal(org.onosproject.net.OchSignal) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) Lambda(org.onosproject.net.Lambda) Test(org.junit.Test)

Example 45 with OchSignal

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) OFPortDescProp(org.projectfloodlight.openflow.protocol.OFPortDescProp) OchSignal(org.onosproject.net.OchSignal) OFPortDescPropOptical(org.projectfloodlight.openflow.protocol.OFPortDescPropOptical)

Aggregations

OchSignal (org.onosproject.net.OchSignal)63 PortNumber (org.onosproject.net.PortNumber)17 ChannelSpacing (org.onosproject.net.ChannelSpacing)16 GridType (org.onosproject.net.GridType)14 DeviceId (org.onosproject.net.DeviceId)12 ConnectPoint (org.onosproject.net.ConnectPoint)11 DeviceService (org.onosproject.net.device.DeviceService)10 HashMap (java.util.HashMap)9 Set (java.util.Set)9 IntStream (java.util.stream.IntStream)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 Logger (org.slf4j.Logger)8 ArrayList (java.util.ArrayList)7 Port (org.onosproject.net.Port)7 Collectors (java.util.stream.Collectors)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)6 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)6 Collections (java.util.Collections)5 List (java.util.List)5 Frequency (org.onlab.util.Frequency)5