Search in sources :

Example 61 with OchSignal

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

the class CzechLightLambdaQuery 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)) {
        final int startMultiplier50 = (int) (START_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
        final int endMultiplier50 = (int) (END_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
        return IntStream.range(startMultiplier50, endMultiplier50 + 1).mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x)).collect(Collectors.toSet());
    } else {
        return Collections.emptySet();
    }
}
Also used : IntStream(java.util.stream.IntStream) 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)

Example 62 with OchSignal

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

the class CassiniTerminalDeviceDiscovery method toPortDescriptionInternal.

/**
 * Converts Component subtree to PortDescription.
 *
 * @param component subtree to parse
 * @return PortDescription or null if component is not an ONOS Port
 */
private PortDescription toPortDescriptionInternal(HierarchicalConfiguration component) {
    Map<String, String> annotations = new HashMap<>();
    /*
        <components xmlns="http://openconfig.net/yang/platform">
             <component>
                <name>oc1/0</name>
                 <config>
                    <name>oc1/0</name>
                 </config>
                 <state>
                    <name>oc1/0</name>
                 <type>OPTICAL_CHANNEL</type>
                <id/>
                <description/>
                <mfg-name/>
                <hardware-version/>
                <firmware-version/>
                <software-version/>
                <serial-no/>
                <part-no/>
                <removable>true</removable>
                <empty>false</empty>
                <parent/>
                <temperature>
                <instant>0.0</instant>
                <avg>0.0</avg>
                <min>0.0</min>
                <max>0.0</max>
                <interval>0</interval>
                <min-time>0</min-time>
                <max-time>0</max-time>
                <alarm-status>true</alarm-status>
                <alarm-threshold>0</alarm-threshold>
                </temperature>
                <memory>
                    <available>0</available>
                    <utilized>0</utilized>
                </memory>
                <allocated-power>0</allocated-power>
                <used-power>0</used-power>
            </state>
            <optical-channel xmlns="http://openconfig.net/yang/terminal-device">
                <config>
                    <line-port>port-10101</line-port>
                </config>
            <state>
                <output-power/>
                <input-power/>
            </state>
            </optical-channel>
        </component>
        */
    String name = component.getString("name");
    String type = component.getString("state/type");
    checkNotNull(name, "name not found");
    checkNotNull(type, "state/type not found");
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_NAME, name);
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_TYPE, type);
    // TODO this currently support only line-side ports through parsing of optical channels.
    if (type.equals(OC_TRANSPORT_TYPES_OPTICAL_CHANNEL)) {
        String portName = component.getString("optical-channel/config/line-port");
        String portIndex = portName.split("-")[1];
        annotations.putIfAbsent(AnnotationKeys.PORT_NAME, portName);
        annotations.putIfAbsent(PORT_TYPE, OdtnPortType.LINE.value());
        annotations.putIfAbsent(ONOS_PORT_INDEX, portIndex);
        annotations.putIfAbsent(CONNECTION_ID, "connection-" + portIndex);
        OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1);
        return OchPortHelper.ochPortDescription(PortNumber.portNumber(Long.parseLong(portIndex)), true, // TODO Client signal to be discovered
        OduSignalType.ODU4, true, signalId, DefaultAnnotations.builder().putAll(annotations).build());
    } else {
        log.debug("Unknown port component type {}", type);
        return null;
    }
}
Also used : HashMap(java.util.HashMap) OchSignal(org.onosproject.net.OchSignal)

Example 63 with OchSignal

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

the class PolatisPowerConfig method acquireTargetPower.

private Long acquireTargetPower(PortNumber port, T component) {
    if (component instanceof OchSignal) {
        log.warn("Channel power is not applicable.");
        return null;
    }
    log.debug("Get port{} target power...", port);
    DeviceId deviceId = handler().data().deviceId();
    Long targetPower = 0L;
    try {
        targetPower = Long.valueOf(get(handler(), VOA_LEVEL_OID + "." + port.toLong()).toInt());
    } catch (IOException e) {
        log.error("Error reading target power for device {} exception {}", deviceId, e);
    }
    return targetPower;
}
Also used : DeviceId(org.onosproject.net.DeviceId) OchSignal(org.onosproject.net.OchSignal) IOException(java.io.IOException)

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