Search in sources :

Example 31 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class LumentumPowerConfig method acquireTargetPower.

// TODO implement actual get configuration from the device
// This is used by ROADM application to retrieve attenuation parameter, with T instanceof OchSignal
// The ROADM app expresses the attenuation in 0.01 dB units
private Double acquireTargetPower(PortNumber port, T component) {
    log.debug("Lumentum get port {} target power...", port);
    if (component instanceof OchSignal) {
        Set<FlowRule> rules = getConnectionCache().get(did());
        FlowRule rule;
        if (rules == null) {
            log.error("Lumentum NETCONF fail to retrieve attenuation signal {} port {}", component, port);
            return 0.0;
        } else {
            rule = rules.stream().filter(c -> ((LumentumFlowRule) c).getOutputPort() == port).filter(c -> ((LumentumFlowRule) c).ochSignal() == component).findFirst().orElse(null);
        }
        if (rule == null) {
            log.error("Lumentum NETCONF fail to retrieve attenuation signal {} port {}", component, port);
            return 0.0;
        } else {
            log.debug("Lumentum NETCONF on port {} attenuation {}", port, (((LumentumFlowRule) rule).attenuation * 100));
            return ((LumentumFlowRule) rule).attenuation * 100;
        }
    }
    return 0.0;
}
Also used : IntStream(java.util.stream.IntStream) NetconfException(org.onosproject.netconf.NetconfException) Logger(org.slf4j.Logger) Range(com.google.common.collect.Range) PortNumber(org.onosproject.net.PortNumber) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Set(java.util.Set) PowerConfig(org.onosproject.net.behaviour.PowerConfig) DeviceConnectionCache(org.onosproject.drivers.odtn.impl.DeviceConnectionCache) NetconfSession(org.onosproject.netconf.NetconfSession) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) OchSignal(org.onosproject.net.OchSignal) HashSet(java.util.HashSet) NetconfController(org.onosproject.netconf.NetconfController) FlowRule(org.onosproject.net.flow.FlowRule) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) OchSignal(org.onosproject.net.OchSignal) FlowRule(org.onosproject.net.flow.FlowRule)

Example 32 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class LumentumPowerConfig method acquireCurrentPower.

// TODO implement actual get configuration from the device
// This is used by ROADM application to retrieve power parameter, with T instanceof OchSignal
private Double acquireCurrentPower(PortNumber port, T component) {
    log.debug("Lumentum get port {} current power...", port);
    if (component instanceof OchSignal) {
        Set<FlowRule> rules = getConnectionCache().get(did());
        FlowRule rule;
        if (rules == null) {
            log.error("Lumentum NETCONF fail to retrieve power signal {} port {}", component, port);
            return 0.0;
        } else {
            rule = rules.stream().filter(c -> ((LumentumFlowRule) c).getInputPort() == port).filter(c -> ((LumentumFlowRule) c).ochSignal() == component).findFirst().orElse(null);
        }
        if (rule == null) {
            log.error("Lumentum NETCONF fail to retrieve power signal {} port {}", component, port);
            return 0.0;
        } else {
            log.debug("Lumentum NETCONF on port {} power {}", port, (((LumentumFlowRule) rule).inputPower));
            return ((double) (((LumentumFlowRule) rule).inputPower * 100));
        }
    }
    return 0.0;
}
Also used : IntStream(java.util.stream.IntStream) NetconfException(org.onosproject.netconf.NetconfException) Logger(org.slf4j.Logger) Range(com.google.common.collect.Range) PortNumber(org.onosproject.net.PortNumber) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Set(java.util.Set) PowerConfig(org.onosproject.net.behaviour.PowerConfig) DeviceConnectionCache(org.onosproject.drivers.odtn.impl.DeviceConnectionCache) NetconfSession(org.onosproject.netconf.NetconfSession) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) OchSignal(org.onosproject.net.OchSignal) HashSet(java.util.HashSet) NetconfController(org.onosproject.netconf.NetconfController) FlowRule(org.onosproject.net.flow.FlowRule) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) OchSignal(org.onosproject.net.OchSignal) FlowRule(org.onosproject.net.flow.FlowRule)

Example 33 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class LumentumRoadmLambdaQuery method queryLambdas.

@Override
public Set<OchSignal> queryLambdas(PortNumber portNumber) {
    DeviceService deviceService = this.handler().get(DeviceService.class);
    Port port = deviceService.getPort(data().deviceId(), portNumber);
    if ((port.type() == Port.Type.FIBER) || (port.type() == Port.Type.OMS)) {
        // Complete set of 50GHz OchSignal
        int startMultiplier50 = (int) (START_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
        Set<OchSignal> channels50 = IntStream.range(0, LAMBDA_COUNT_50).mapToObj(x -> new OchSignal(GRID_TYPE, CHANNEL_SPACING_50, startMultiplier50 + x, 4)).collect(Collectors.toSet());
        return channels50;
    } else {
        return Collections.emptySet();
    }
}
Also used : IntStream(java.util.stream.IntStream) GridType(org.onosproject.net.GridType) LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) Set(java.util.Set) Spectrum(org.onlab.util.Spectrum) Collectors(java.util.stream.Collectors) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) OchSignal(org.onosproject.net.OchSignal) Frequency(org.onlab.util.Frequency) Port(org.onosproject.net.Port) ChannelSpacing(org.onosproject.net.ChannelSpacing) Collections(java.util.Collections) Port(org.onosproject.net.Port) DeviceService(org.onosproject.net.device.DeviceService) OchSignal(org.onosproject.net.OchSignal)

Example 34 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class LumentumWaveReadyDiscovery method extractPorts.

// Extract ports from response on pluggable inventory retrieval.
// Client ports are identified by 850nm, everything else is a network port.
private List<PortDescription> extractPorts(String s) {
    List<PortDescription> ports = new ArrayList<>();
    if (s.length() == 0) {
        return ports;
    }
    Arrays.stream(s.split("\"\"")).forEach(p -> {
        if (p.contains(EIGHTFIFTY)) {
            PortDescription cltPort = oduCltPortDescription(PortNumber.portNumber(ports.size() + 1L), true, CltSignalType.CLT_10GBE, extractAnnotations(p));
            ports.add(cltPort);
        } else {
            PortDescription netPort = ochPortDescription(PortNumber.portNumber(ports.size() + 1L), true, OduSignalType.ODU2e, true, new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4), extractAnnotations(p));
            ports.add(netPort);
        }
    });
    return ports;
}
Also used : ArrayList(java.util.ArrayList) OchPortHelper.ochPortDescription(org.onosproject.net.optical.device.OchPortHelper.ochPortDescription) PortDescription(org.onosproject.net.device.PortDescription) OduCltPortHelper.oduCltPortDescription(org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription) OchSignal(org.onosproject.net.OchSignal)

Example 35 with OchSignal

use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.

the class DefaultTrafficSelectorTest method testCriteriaCreation.

/**
 * Tests the builder functions that add specific criteria.
 */
@Test
public void testCriteriaCreation() {
    TrafficSelector selector;
    final long longValue = 0x12345678;
    final int intValue = 22;
    final short shortValue = 33;
    final byte byteValue = 44;
    final byte dscpValue = 0xf;
    final byte ecnValue = 3;
    final MacAddress macValue = MacAddress.valueOf("11:22:33:44:55:66");
    final IpPrefix ipPrefixValue = IpPrefix.valueOf("192.168.1.0/24");
    final IpPrefix ipv6PrefixValue = IpPrefix.valueOf("fe80::1/64");
    final Ip6Address ipv6AddressValue = Ip6Address.valueOf("fe80::1");
    selector = DefaultTrafficSelector.builder().matchInPort(PortNumber.portNumber(11)).build();
    assertThat(selector, hasCriterionWithType(Type.IN_PORT));
    selector = DefaultTrafficSelector.builder().matchInPhyPort(PortNumber.portNumber(11)).build();
    assertThat(selector, hasCriterionWithType(Type.IN_PHY_PORT));
    selector = DefaultTrafficSelector.builder().matchMetadata(longValue).build();
    assertThat(selector, hasCriterionWithType(Type.METADATA));
    selector = DefaultTrafficSelector.builder().matchEthDst(macValue).build();
    assertThat(selector, hasCriterionWithType(Type.ETH_DST));
    selector = DefaultTrafficSelector.builder().matchEthSrc(macValue).build();
    assertThat(selector, hasCriterionWithType(Type.ETH_SRC));
    selector = DefaultTrafficSelector.builder().matchEthType(shortValue).build();
    assertThat(selector, hasCriterionWithType(Type.ETH_TYPE));
    selector = DefaultTrafficSelector.builder().matchVlanId(VlanId.vlanId(shortValue)).build();
    assertThat(selector, hasCriterionWithType(Type.VLAN_VID));
    selector = DefaultTrafficSelector.builder().matchVlanPcp(byteValue).build();
    assertThat(selector, hasCriterionWithType(Type.VLAN_PCP));
    selector = DefaultTrafficSelector.builder().matchIPDscp(dscpValue).build();
    assertThat(selector, hasCriterionWithType(Type.IP_DSCP));
    selector = DefaultTrafficSelector.builder().matchIPEcn(ecnValue).build();
    assertThat(selector, hasCriterionWithType(Type.IP_ECN));
    selector = DefaultTrafficSelector.builder().matchIPProtocol(byteValue).build();
    assertThat(selector, hasCriterionWithType(Type.IP_PROTO));
    selector = DefaultTrafficSelector.builder().matchIPSrc(ipPrefixValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV4_SRC));
    selector = DefaultTrafficSelector.builder().matchIPDst(ipPrefixValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV4_DST));
    selector = DefaultTrafficSelector.builder().matchTcpSrc(TpPort.tpPort(intValue)).build();
    assertThat(selector, hasCriterionWithType(Type.TCP_SRC));
    selector = DefaultTrafficSelector.builder().matchTcpDst(TpPort.tpPort(intValue)).build();
    assertThat(selector, hasCriterionWithType(Type.TCP_DST));
    selector = DefaultTrafficSelector.builder().matchUdpSrc(TpPort.tpPort(intValue)).build();
    assertThat(selector, hasCriterionWithType(Type.UDP_SRC));
    selector = DefaultTrafficSelector.builder().matchUdpDst(TpPort.tpPort(intValue)).build();
    assertThat(selector, hasCriterionWithType(Type.UDP_DST));
    selector = DefaultTrafficSelector.builder().matchSctpSrc(TpPort.tpPort(intValue)).build();
    assertThat(selector, hasCriterionWithType(Type.SCTP_SRC));
    selector = DefaultTrafficSelector.builder().matchSctpDst(TpPort.tpPort(intValue)).build();
    assertThat(selector, hasCriterionWithType(Type.SCTP_DST));
    selector = DefaultTrafficSelector.builder().matchIcmpType(byteValue).build();
    assertThat(selector, hasCriterionWithType(Type.ICMPV4_TYPE));
    selector = DefaultTrafficSelector.builder().matchIcmpCode(byteValue).build();
    assertThat(selector, hasCriterionWithType(Type.ICMPV4_CODE));
    selector = DefaultTrafficSelector.builder().matchIPv6Src(ipv6PrefixValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV6_SRC));
    selector = DefaultTrafficSelector.builder().matchIPv6Dst(ipv6PrefixValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV6_DST));
    selector = DefaultTrafficSelector.builder().matchIPv6FlowLabel(intValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV6_FLABEL));
    selector = DefaultTrafficSelector.builder().matchIcmpv6Type(byteValue).build();
    assertThat(selector, hasCriterionWithType(Type.ICMPV6_TYPE));
    selector = DefaultTrafficSelector.builder().matchIPv6NDTargetAddress(ipv6AddressValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV6_ND_TARGET));
    selector = DefaultTrafficSelector.builder().matchIPv6NDSourceLinkLayerAddress(macValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV6_ND_SLL));
    selector = DefaultTrafficSelector.builder().matchIPv6NDTargetLinkLayerAddress(macValue).build();
    assertThat(selector, hasCriterionWithType(Type.IPV6_ND_TLL));
    selector = DefaultTrafficSelector.builder().matchMplsLabel(MplsLabel.mplsLabel(3)).build();
    assertThat(selector, hasCriterionWithType(Type.MPLS_LABEL));
    selector = DefaultTrafficSelector.builder().matchIPv6ExthdrFlags(Criterion.IPv6ExthdrFlags.NONEXT.getValue()).build();
    assertThat(selector, hasCriterionWithType(Type.IPV6_EXTHDR));
    selector = DefaultTrafficSelector.builder().add(Criteria.matchLambda(new OchSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, 1, 1))).build();
    assertThat(selector, hasCriterionWithType(Type.OCH_SIGID));
    selector = DefaultTrafficSelector.builder().matchEthDst(macValue).extension(new MockExtensionSelector(1), DeviceId.NONE).extension(new MockExtensionSelector(2), DeviceId.NONE).build();
    assertThat(selector.criteria().size(), is(equalTo(3)));
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) Ip6Address(org.onlab.packet.Ip6Address) OchSignal(org.onosproject.net.OchSignal) MacAddress(org.onlab.packet.MacAddress) Test(org.junit.Test)

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