Ramon Casellas | 99c1625 | 2019-05-31 14:29:00 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | * This work was partially supported by EC H2020 project METRO-HAUL (761727). |
| 17 | */ |
| 18 | |
| 19 | package org.onosproject.drivers.odtn.openroadm; |
| 20 | |
| 21 | import org.onlab.util.Frequency; |
| 22 | import org.onosproject.net.DeviceId; |
| 23 | import org.onosproject.net.OchSignal; |
| 24 | import org.onosproject.net.Port; |
| 25 | import org.onosproject.net.PortNumber; |
| 26 | import org.onosproject.net.device.DeviceService; |
| 27 | import org.onosproject.net.flow.FlowId; |
| 28 | import org.slf4j.Logger; |
| 29 | import org.slf4j.LoggerFactory; |
| 30 | |
| 31 | |
| 32 | class OpenRoadmConnectionBase { |
| 33 | |
| 34 | protected static final Logger log = LoggerFactory.getLogger(OpenRoadmConnection.class); |
| 35 | |
| 36 | // Parameters of the FlowRule traslated into the OpenRoadm connection |
| 37 | protected DeviceId deviceId; |
| 38 | protected FlowId id; |
| 39 | protected int priority; |
| 40 | |
| 41 | protected OpenRoadmFlowRule.Type type; // enum (EXPRESS_LINK, ADD_LINK, DROP_LINK) |
| 42 | protected OchSignal ochSignal; |
| 43 | protected PortNumber inPortNumber; |
| 44 | protected PortNumber outPortNumber; |
| 45 | |
| 46 | protected Port srcPort; // used to retrieve info in the annotations |
| 47 | protected Port dstPort; // used to retrieve info in the annotations |
| 48 | |
| 49 | // Parameters of <roadm-connections> |
| 50 | protected String connectionName; |
| 51 | protected String opticalControlMode; |
| 52 | protected double targetOutputPower = 0.0; |
| 53 | protected String srcConnInterface; // this is an NMC interface |
| 54 | protected String dstConnInterface; // this is an NMC interface |
| 55 | |
| 56 | // Parameters of associated NMC interfaces: |
| 57 | // <type>openROADM-if:networkMediaChannelConnectionTerminationPoint</type> |
| 58 | protected String srcNmcName; |
| 59 | protected String srcNmcDescription; |
| 60 | protected String srcNmcType; |
| 61 | protected String srcNmcAdministrativeState; |
| 62 | protected String srcNmcSupportingCircuitPack; |
| 63 | protected String srcNmcSupportingInterface; // this is an MC interface (express-link) or a |
| 64 | // physical-port (add-drop) |
| 65 | protected String srcNmcSupportingPort; |
| 66 | protected Frequency srcNmcFrequency; // expressed in Thz |
| 67 | protected Frequency srcNmcWidth; // expressed in Ghz |
| 68 | |
| 69 | protected String dstNmcName; |
| 70 | protected String dstNmcDescription; |
| 71 | protected String dstNmcType; |
| 72 | protected String dstNmcAdministrativeState; |
| 73 | protected String dstNmcSupportingCircuitPack; |
| 74 | protected String dstNmcSupportingInterface; // this is an MC interface (express-link) or a |
| 75 | // physical-port (add-drop) |
| 76 | protected String dstNmcSupportingPort; |
| 77 | protected Frequency dstNmcFrequency; // expressed in Thz |
| 78 | protected Frequency dstNmcWidth; // expressed in Ghz |
| 79 | |
| 80 | // Parameters of associated MC interfaces: |
| 81 | // <type>openROADM-if:mediaChannelTrailTerminationPoint</type> |
| 82 | protected String srcMcName; |
| 83 | protected String srcMcDescription; |
| 84 | protected String srcMcType; |
| 85 | protected String srcMcAdministrativeState; |
| 86 | protected String srcMcSupportingCircuitPack; |
| 87 | protected String srcMcSupportingInterface; // this is a physical-port |
| 88 | protected String srcMcSupportingPort; |
| 89 | protected Frequency srcMcMinFrequency; // expressed in Thz |
| 90 | protected Frequency srcMcMaxFrequency; // expressed in Thz |
| 91 | |
| 92 | protected String dstMcName; |
| 93 | protected String dstMcDescription; |
| 94 | protected String dstMcType; |
| 95 | protected String dstMcAdministrativeState; |
| 96 | protected String dstMcSupportingCircuitPack; |
| 97 | protected String dstMcSupportingInterface; // this is a physical-port |
| 98 | protected String dstMcSupportingPort; |
| 99 | protected Frequency dstMcMinFrequency; // expressed in Thz |
| 100 | protected Frequency dstMcMaxFrequency; // expressed in Thz |
| 101 | |
| 102 | |
| 103 | |
| 104 | public OpenRoadmFlowRule.Type getType() { |
| 105 | return type; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | |
| 110 | |
| 111 | /** |
| 112 | * Class that models an OpenROADM connection object (Yang leaf). |
| 113 | * |
| 114 | */ |
| 115 | public class OpenRoadmConnection extends OpenRoadmConnectionBase { |
| 116 | |
| 117 | public static final String OPENROADM_CIRCUIT_PACK_NAME = "openroadm-circuit-pack-name"; |
| 118 | |
| 119 | public static final String OPENROADM_PORT_NAME = "openroadm-port-name"; |
| 120 | |
| 121 | public static final String OPENROADM_LOGICAL_CONNECTION_POINT = |
| 122 | "openroadm-logical-connection-point"; |
| 123 | |
| 124 | /** |
| 125 | * Constructor. |
| 126 | * |
| 127 | * @param openRoadmName name of the Connection. |
| 128 | * @param xc the associated OpenRoadmFlowRule. |
| 129 | * @param deviceService ONOS device service. |
| 130 | */ |
| 131 | public OpenRoadmConnection(String openRoadmName, OpenRoadmFlowRule xc, |
| 132 | DeviceService deviceService) { |
| 133 | connectionName = openRoadmName; |
| 134 | deviceId = xc.deviceId(); |
| 135 | id = xc.id(); |
| 136 | priority = xc.priority(); |
| 137 | |
| 138 | inPortNumber = xc.inPort(); |
| 139 | outPortNumber = xc.outPort(); |
| 140 | ochSignal = xc.ochSignal(); |
| 141 | type = xc.type(); |
| 142 | |
| 143 | srcPort = deviceService.getPort(deviceId, xc.inPort()); |
| 144 | dstPort = deviceService.getPort(deviceId, xc.outPort()); |
| 145 | |
| 146 | // Conversion from ochSignal (center frequency + diameter) to OpenRoadm |
| 147 | // Media Channel (start - end) |
| 148 | Frequency freqRadius = Frequency.ofHz( |
| 149 | xc.ochSignal().channelSpacing().frequency().asHz() / 2); |
| 150 | Frequency centerFreq = xc.ochSignal().centralFrequency(); |
| 151 | |
| 152 | // e.g. DEG1-TTP-RX |
| 153 | String srcTag = |
| 154 | srcPort.annotations().value(OPENROADM_LOGICAL_CONNECTION_POINT) + |
| 155 | "-" + centerFreq.asTHz(); |
| 156 | |
| 157 | // e.g. DEG2-TTP-TX or SRG2-PP1-TX |
| 158 | String dstTag = |
| 159 | dstPort.annotations().value(OPENROADM_LOGICAL_CONNECTION_POINT) + |
| 160 | "-" + centerFreq.asTHz(); |
| 161 | |
| 162 | srcMcMinFrequency = centerFreq.subtract(freqRadius); |
| 163 | srcMcMaxFrequency = centerFreq.add(freqRadius); |
| 164 | dstMcMinFrequency = srcMcMinFrequency; |
| 165 | dstMcMaxFrequency = srcMcMaxFrequency; |
| 166 | srcNmcFrequency = centerFreq; |
| 167 | dstNmcFrequency = centerFreq; |
| 168 | srcNmcWidth = xc.ochSignal().channelSpacing().frequency(); |
| 169 | dstNmcWidth = xc.ochSignal().channelSpacing().frequency(); |
| 170 | |
| 171 | srcMcSupportingInterface = |
| 172 | "OMS-" + |
| 173 | srcPort.annotations().value(OPENROADM_LOGICAL_CONNECTION_POINT); |
| 174 | dstMcSupportingInterface = |
| 175 | "OMS-" + |
| 176 | dstPort.annotations().value(OPENROADM_LOGICAL_CONNECTION_POINT); |
| 177 | |
| 178 | // Media Channel Interfaces |
| 179 | srcMcName = "MC-TTP-" + srcTag; |
| 180 | srcMcSupportingCircuitPack = |
| 181 | srcPort.annotations().value(OPENROADM_CIRCUIT_PACK_NAME); |
| 182 | srcMcSupportingPort = srcPort.annotations().value(OPENROADM_PORT_NAME); |
| 183 | |
| 184 | dstMcName = "MC-TTP-" + dstTag; |
| 185 | dstMcSupportingCircuitPack = |
| 186 | dstPort.annotations().value(OPENROADM_CIRCUIT_PACK_NAME); |
| 187 | dstMcSupportingPort = dstPort.annotations().value(OPENROADM_PORT_NAME); |
| 188 | |
| 189 | // Network Media Channel Interfaces |
| 190 | srcNmcName = "NMC-CTP-" + srcTag; |
| 191 | srcConnInterface = srcNmcName; |
| 192 | srcNmcSupportingInterface = srcMcName; |
| 193 | srcNmcSupportingCircuitPack = |
| 194 | srcPort.annotations().value(OPENROADM_CIRCUIT_PACK_NAME); |
| 195 | srcNmcSupportingPort = srcPort.annotations().value(OPENROADM_PORT_NAME); |
| 196 | |
| 197 | dstNmcName = "NMC-CTP-" + dstTag; |
| 198 | dstConnInterface = dstNmcName; |
| 199 | dstNmcSupportingInterface = dstMcName; |
| 200 | dstNmcSupportingCircuitPack = |
| 201 | dstPort.annotations().value(OPENROADM_CIRCUIT_PACK_NAME); |
| 202 | dstNmcSupportingPort = dstPort.annotations().value(OPENROADM_PORT_NAME); |
| 203 | } |
| 204 | |
| 205 | protected String getConnectionName() { |
| 206 | return connectionName; |
| 207 | } |
| 208 | } |