2 * Copyright © 2021 AT&T and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.renderer.openroadminterface;
11 import java.math.BigDecimal;
12 import java.util.ArrayList;
13 import java.util.Arrays;
14 import java.util.List;
15 import java.util.Optional;
16 import java.util.stream.IntStream;
17 import org.opendaylight.transportpce.common.StringConstants;
18 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
19 import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
20 import org.opendaylight.transportpce.common.mapping.PortMapping;
21 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
22 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.AEndApiInfo;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.ZEndApiInfo;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.TrailTraceOther.TimDetectMode;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.parent.odu.allocation.ParentOduAllocationBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.parent.odu.allocation.parent.odu.allocation.trib.slots.choice.OpucnBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.PowerDBm;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic24;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic28;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic36;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic48;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyTHz;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.ModulationFormat;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.ProvisionModeType;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R100G;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R200GOtsi;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R300GOtsi;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R400GOtsi;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Ofec;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Rsfec;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Scfec;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.Interface1Builder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.ethernet.container.EthernetBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.EthernetCsmacd;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.InterfaceType;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OpticalChannel;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnOdu;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnOtu;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.Otsi;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtsiGroup;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529.och.container.OchBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.attributes.FlexoBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.container.OtsiBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUCn;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTP;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTPCTP;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr400G;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTU4;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTUCn;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.PayloadTypeDef;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.OduAttributes.MonitoringMode;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.odu.container.OduBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.opu.OpuBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.otsi.group.container.OtsiGroupBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If100GE;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCHOTU4ODU4;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOtsiOtsigroup;
77 import org.opendaylight.yangtools.yang.common.Uint16;
78 import org.opendaylight.yangtools.yang.common.Uint32;
79 import org.opendaylight.yangtools.yang.common.Uint8;
80 import org.slf4j.Logger;
81 import org.slf4j.LoggerFactory;
83 public class OpenRoadmInterface710 {
84 private static final String MAPPING_ERROR_EXCEPTION_MESSAGE =
85 "Unable to get mapping from PortMapping for node % and logical connection port %s";
86 private static final String MODULATION_FMT_EXCEPTION_MESSAGE =
87 "Unable to get the modulation format";
88 private static final String RATE_EXCEPTION_MESSAGE =
89 "Unable to get the rate";
90 private static final String ODUC = "-ODUC";
91 private static final List<String> SUPPORTED_ODUCN_RATES = new ArrayList<>() {
98 private final PortMapping portMapping;
99 private final OpenRoadmInterfaces openRoadmInterfaces;
100 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface710.class);
102 public OpenRoadmInterface710(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
103 this.portMapping = portMapping;
104 this.openRoadmInterfaces = openRoadmInterfaces;
107 public String createOpenRoadmEthInterface(String nodeId, String logicalConnPoint)
108 throws OpenRoadmInterfaceException {
109 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
110 if (portMap == null) {
111 throw new OpenRoadmInterfaceException(
112 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
114 // Ethernet interface specific data
115 EthernetBuilder ethIfBuilder = new EthernetBuilder()
117 // Default set to 400G
118 .setSpeed(Uint32.valueOf(400000));
119 // We have to differentiate if-100GE vs if-400GE
120 if (portMap.getSupportedInterfaceCapability().contains(If100GE.class)) {
121 ethIfBuilder.setSpeed(Uint32.valueOf(100000));
124 InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class,
125 logicalConnPoint + "-ETHERNET");
127 // Create Interface1 type object required for adding as augmentation
128 Interface1Builder ethIf1Builder = new Interface1Builder();
129 ethInterfaceBldr.addAugmentation(ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
131 // Post interface on the device
132 openRoadmInterfaces.postInterface(nodeId, ethInterfaceBldr);
134 // Post the equipment-state change on the device circuit-pack
135 openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
137 return ethInterfaceBldr.getName();
140 public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint,
141 SpectrumInformation spectrumInformation)
142 throws OpenRoadmInterfaceException {
144 ModulationFormat modulationFormat = ModulationFormat.DpQpsk;
145 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
146 .forName(spectrumInformation.getModulationFormat());
147 if (optionalModulationFormat.isPresent()) {
148 modulationFormat = optionalModulationFormat.get();
150 // OCH interface specific data
151 OchBuilder ocIfBuilder = new OchBuilder()
152 .setFrequency(new FrequencyTHz(spectrumInformation.getCenterFrequency()))
153 .setRate(R100G.class)
154 .setTransmitPower(new PowerDBm(new BigDecimal("-5")))
155 .setModulationFormat(modulationFormat);
156 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
157 if (portMap == null) {
158 throw new OpenRoadmInterfaceException(
159 String.format("Unable to get mapping from PortMapping for node %s and logical connection port %s",
160 nodeId, logicalConnPoint));
162 // Create generic interface
164 ochInterfaceBldr = createGenericInterfaceBuilder(portMap, OpticalChannel.class,
165 spectrumInformation.getIdentifierFromParams(logicalConnPoint));
166 // Create Interface1 type object required for adding as augmentation
167 // TODO look at imports of different versions of class
168 org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529.Interface1Builder
169 ochIf1Builder = new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529
170 .Interface1Builder();
171 ochInterfaceBldr.addAugmentation(ochIf1Builder.setOch(ocIfBuilder.build()).build());
173 // Post interface on the device
174 openRoadmInterfaces.postInterface(nodeId, ochInterfaceBldr);
176 // Post the equipment-state change on the device circuit-pack if xpdr node
177 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
178 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
181 return ochInterfaceBldr.getName();
184 public String createOpenRoadmOtsiInterface(String nodeId, String logicalConnPoint,
185 SpectrumInformation spectrumInformation)
186 throws OpenRoadmInterfaceException {
188 ModulationFormat modulationFormat;
189 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
190 .forName(spectrumInformation.getModulationFormat());
191 if (optionalModulationFormat.isPresent()) {
192 modulationFormat = optionalModulationFormat.get();
194 throw new OpenRoadmInterfaceException(
195 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
198 // OTSI interface specific data
199 OtsiBuilder otsiBuilder = new OtsiBuilder()
200 .setFrequency(new FrequencyTHz(spectrumInformation.getCenterFrequency()))
201 .setTransmitPower(new PowerDBm(new BigDecimal("-5")))
202 .setProvisionMode(ProvisionModeType.Explicit)
204 .setModulationFormat(modulationFormat);
206 // Set the Flexo values
207 FlexoBuilder flexoBuilder = new FlexoBuilder();
208 boolean rateNotFound = false;
209 // Use the rate to switch rather than modulation format
210 int serviceRate = getServiceRate(modulationFormat, spectrumInformation);
211 switch (serviceRate) {
213 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
214 if (modulationFormat == ModulationFormat.DpQam16) {
215 LOG.info("FOIC is 2.8 for 31.6 Gbaud and rate is 200");
216 // FOIC rate is different
217 flexoBuilder.setFoicType(Foic28.class)
218 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
219 Uint8.valueOf(3), Uint8.valueOf(4))));
221 // default is dp-qpsk for 200G under 63.1 GBaud
222 flexoBuilder.setFoicType(Foic24.class)
223 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2))));
225 otsiBuilder.setOtsiRate(R200GOtsi.class)
226 .setFlexo(flexoBuilder.build());
229 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
230 flexoBuilder.setFoicType(Foic36.class)
231 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
233 otsiBuilder.setOtsiRate(R300GOtsi.class)
234 .setFlexo(flexoBuilder.build());
237 // Default baud-rate is 63.1 Gbaud
238 LOG.info("Given modulation format is {} and thus rate is 400G", modulationFormat);
239 flexoBuilder.setFoicType(Foic48.class)
240 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
241 Uint8.valueOf(3), Uint8.valueOf(4))));
242 otsiBuilder.setModulationFormat(modulationFormat)
243 .setOtsiRate(R400GOtsi.class)
244 .setFlexo(flexoBuilder.build());
247 LOG.error("Rate {} is unsupported", serviceRate);
253 throw new OpenRoadmInterfaceException(
254 String.format(RATE_EXCEPTION_MESSAGE));
257 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
258 if (portMap == null) {
259 throw new OpenRoadmInterfaceException(
260 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
262 // Create generic interface
263 InterfaceBuilder otsiInterfaceBldr = createGenericInterfaceBuilder(portMap, Otsi.class,
264 spectrumInformation.getIdentifierFromParams(logicalConnPoint));
265 // Create Interface1 type object required for adding as augmentation
266 org.opendaylight.yang.gen.v1.http
267 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder otsiIf1Builder =
268 new org.opendaylight.yang.gen.v1.http
269 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder();
271 otsiInterfaceBldr.addAugmentation(otsiIf1Builder.setOtsi(otsiBuilder.build()).build());
273 // Post interface on the device
274 openRoadmInterfaces.postInterface(nodeId, otsiInterfaceBldr);
276 // Post the equipment-state change on the device circuit-pack if xpdr node
277 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
278 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
281 return otsiInterfaceBldr.getName();
284 // This is a transponder use-case where the supporting port is just one, but YANG model
285 // requires supporting port to be list
286 public String createOpenRoadmOtsiGroupInterface(String nodeId, String logicalConnPoint,
287 String supportingOtsiInterface, SpectrumInformation spectrumInformation)
288 throws OpenRoadmInterfaceException {
289 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
290 if (portMap == null) {
291 throw new OpenRoadmInterfaceException(
292 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
293 nodeId, logicalConnPoint));
295 // Check the modulation format
296 ModulationFormat modulationFormat;
297 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
298 .forName(spectrumInformation.getModulationFormat());
299 if (optionalModulationFormat.isPresent()) {
300 modulationFormat = optionalModulationFormat.get();
302 throw new OpenRoadmInterfaceException(
303 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
305 int serviceRate = getServiceRate(modulationFormat, spectrumInformation);
306 // Create an OTSI group object
307 OtsiGroupBuilder otsiGroupBuilder = new OtsiGroupBuilder()
308 .setGroupId(Uint32.valueOf(1));
309 boolean rateNotFound = false;
310 switch (serviceRate) {
312 otsiGroupBuilder.setGroupRate(R200GOtsi.class);
315 otsiGroupBuilder.setGroupRate(R300GOtsi.class);
318 otsiGroupBuilder.setGroupRate(R400GOtsi.class);
321 LOG.error("Rate {} is not supported", serviceRate);
326 throw new OpenRoadmInterfaceException(
327 String.format(RATE_EXCEPTION_MESSAGE));
330 // Create generic interface
331 InterfaceBuilder otsiGroupInterfaceBldr = createGenericInterfaceBuilder(portMap, OtsiGroup.class,
332 logicalConnPoint + String.join("-", "", "OTSIGROUP", serviceRate + "G"));
335 List<String> listSupportingOtsiInterface = new ArrayList<>();
336 listSupportingOtsiInterface.add(supportingOtsiInterface);
337 otsiGroupInterfaceBldr.setSupportingInterfaceList(listSupportingOtsiInterface);
339 org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder
340 otsiGroupIf1Builder =
341 new org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder();
342 otsiGroupInterfaceBldr.addAugmentation(otsiGroupIf1Builder.setOtsiGroup(otsiGroupBuilder.build()).build());
344 // Post interface on the device
345 openRoadmInterfaces.postInterface(nodeId, otsiGroupInterfaceBldr);
347 // Post the equipment-state change on the device circuit-pack if xpdr node
348 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
349 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
352 return otsiGroupInterfaceBldr.getName();
355 public String createOpenRoadmOchOtsiOtsigroupInterface(String nodeId, String logicalConnPoint,
356 SpectrumInformation spectrumInformation)
357 throws OpenRoadmInterfaceException {
358 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
359 if (portMap == null) {
360 throw new OpenRoadmInterfaceException(
361 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
363 String interfaceOchOtsiOtsigroup = null;
364 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
365 // create OCH interface
366 interfaceOchOtsiOtsigroup = createOpenRoadmOchInterface(nodeId, logicalConnPoint, spectrumInformation);
367 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
368 // Create OTSi and OTSi-group and concat the names of the interface
369 String interfaceOtsiName = createOpenRoadmOtsiInterface(nodeId, logicalConnPoint, spectrumInformation);
370 // Concat the two names for this interface
371 interfaceOchOtsiOtsigroup = interfaceOtsiName
372 + "#" + createOpenRoadmOtsiGroupInterface(nodeId, logicalConnPoint, interfaceOtsiName,
373 spectrumInformation);
376 return interfaceOchOtsiOtsigroup;
379 public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface,
380 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
382 Mapping mapping = this.portMapping.getMapping(nodeId, logicalConnPoint);
383 if (mapping == null) {
384 throw new OpenRoadmInterfaceException(
385 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
388 otuInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOtu.class,
389 logicalConnPoint + "-OTU4");
390 // Supporting interface list
391 List<String> listSupportingOChInterface = new ArrayList<>();
392 listSupportingOChInterface.add(supportOchInterface);
393 otuInterfaceBldr.setSupportingInterfaceList(listSupportingOChInterface);
395 // OTU interface specific data
396 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder
397 otuIfBuilder = new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu
398 .interfaces.rev200529.otu.container.OtuBuilder()
400 .setRate(OTU4.class);
401 if (apiInfoA != null) {
402 otuIfBuilder.setTxSapi(apiInfoA.getSapi())
403 .setTxDapi(apiInfoA.getDapi())
404 .setExpectedSapi(apiInfoA.getExpectedSapi())
405 .setExpectedDapi(apiInfoA.getExpectedDapi());
407 if (apiInfoZ != null) {
408 otuIfBuilder.setTxSapi(apiInfoZ.getSapi())
409 .setTxDapi(apiInfoZ.getDapi())
410 .setExpectedSapi(apiInfoZ.getExpectedSapi())
411 .setExpectedDapi(apiInfoZ.getExpectedDapi());
414 // Create Interface1 type object required for adding as augmentation
415 // TODO look at imports of different versions of class
416 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
417 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
418 otuInterfaceBldr.addAugmentation(otuIf1Builder.setOtu(otuIfBuilder.build()).build());
420 // Post interface on the device
421 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBldr);
422 this.portMapping.updateMapping(nodeId, mapping);
423 return otuInterfaceBldr.getName();
427 public String createOpenRoadmOtucnInterface(String nodeId, String logicalConnPoint,
428 String supportingOtsiGroupInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
429 throws OpenRoadmInterfaceException {
430 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
431 if (mapping == null) {
432 throw new OpenRoadmInterfaceException(
433 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
434 nodeId, logicalConnPoint));
436 // Create an OTUCn object
437 OtuBuilder otuBuilder = new OtuBuilder()
438 .setRate(OTUCn.class)
439 .setTimActEnabled(false)
440 .setTimDetectMode(TimDetectMode.Disabled)
441 .setDegmIntervals(Uint8.valueOf(2))
442 .setDegthrPercentage(Uint16.valueOf(100));
444 if (apiInfoA != null) {
445 otuBuilder.setTxSapi(apiInfoA.getSapi())
446 .setTxDapi(apiInfoA.getDapi())
447 .setExpectedSapi(apiInfoA.getExpectedSapi())
448 .setExpectedDapi(apiInfoA.getExpectedDapi());
450 if (apiInfoZ != null) {
451 otuBuilder.setTxSapi(apiInfoZ.getSapi())
452 .setTxDapi(apiInfoZ.getDapi())
453 .setExpectedSapi(apiInfoZ.getExpectedSapi())
454 .setExpectedDapi(apiInfoZ.getExpectedDapi());
456 // Set the OTUCn rate for various rates
457 String rate = supportingOtsiGroupInterface.substring(supportingOtsiGroupInterface.lastIndexOf('-') + 1);
459 String otucnrate = null;
460 boolean rateNotFound = false;
463 otuBuilder.setOtucnNRate(Uint16.valueOf(2));
467 otuBuilder.setOtucnNRate(Uint16.valueOf(3));
471 otuBuilder.setOtucnNRate(Uint16.valueOf(4));
475 LOG.error("Rate {} is not supported", rate);
480 throw new OpenRoadmInterfaceException(
481 String.format(RATE_EXCEPTION_MESSAGE));
484 InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOtu.class,
485 logicalConnPoint + "-OTUC" + otucnrate);
488 List<String> listSupportingOtsiGroupInterface = new ArrayList<>();
489 listSupportingOtsiGroupInterface.add(supportingOtsiGroupInterface);
491 otuInterfaceBuilder.setSupportingInterfaceList(listSupportingOtsiGroupInterface);
492 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
493 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
495 otuInterfaceBuilder.addAugmentation(otuIf1Builder.setOtu(otuBuilder.build()).build());
497 // Post interface on the device
498 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBuilder);
499 // Post the equipment-state change on the device circuit-pack if xpdr node
500 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
501 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
503 this.portMapping.updateMapping(nodeId, mapping);
504 return otuInterfaceBuilder.getName();
507 public String createOpenRoadmOtu4OtucnInterface(String nodeId, String logicalConnPoint,
508 String supportingInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
509 throws OpenRoadmInterfaceException {
510 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
511 if (portMap == null) {
512 throw new OpenRoadmInterfaceException(
513 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
515 // Depending on OCH-OTU4-ODU4 interface or OTSi-OTSi-group, supporting interface should
517 String interfaceOtu4Otucn = null;
518 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
519 // create OTU4 interface
520 interfaceOtu4Otucn = createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportingInterface,
522 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
524 interfaceOtu4Otucn = createOpenRoadmOtucnInterface(nodeId, logicalConnPoint, supportingInterface,
528 return interfaceOtu4Otucn;
531 public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint,
532 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
534 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
535 if (mapping == null) {
536 throw new OpenRoadmInterfaceException(
537 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
539 InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOdu.class,
540 logicalConnPoint + "-ODU4");
541 List<String> listSupportingOtu4Interface = new ArrayList<>();
542 if (mapping.getSupportingOtu4() != null) {
543 listSupportingOtu4Interface.add(mapping.getSupportingOtu4());
544 oduInterfaceBldr.setSupportingInterfaceList(listSupportingOtu4Interface);
548 OpuBuilder opuBuilder = new OpuBuilder()
549 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
550 .setPayloadType(PayloadTypeDef.getDefaultInstance("07"));
552 // Create an ODU4 object
553 OduBuilder oduBuilder = new OduBuilder()
555 .setOduFunction(ODUTTP.class)
556 .setMonitoringMode(MonitoringMode.Terminated)
557 .setOpu(opuBuilder.build());
559 if (apiInfoA != null) {
560 oduBuilder.setTxSapi(apiInfoA.getSapi())
561 .setTxDapi(apiInfoA.getDapi())
562 .setExpectedSapi(apiInfoA.getExpectedSapi())
563 .setExpectedDapi(apiInfoA.getExpectedDapi());
565 if (apiInfoZ != null) {
566 oduBuilder.setTxSapi(apiInfoZ.getSapi())
567 .setTxDapi(apiInfoZ.getDapi())
568 .setExpectedSapi(apiInfoZ.getExpectedSapi())
569 .setExpectedDapi(apiInfoZ.getExpectedDapi());
571 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
572 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
574 oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
576 // Post interface on the device
577 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr);
578 // Since this is not a CTP, we can update the port-mapping
579 LOG.info("{}-{} updating mapping with interface {}", nodeId, logicalConnPoint, oduInterfaceBldr.getName());
580 this.portMapping.updateMapping(nodeId, mapping);
582 return oduInterfaceBldr.getName();
586 public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint)
587 throws OpenRoadmInterfaceException {
588 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
589 if (mapping == null) {
590 throw new OpenRoadmInterfaceException(
591 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
592 nodeId, logicalConnPoint));
594 // Create ODUcn object
595 // Start with OPU object
597 OpuBuilder opuBuilder = new OpuBuilder()
598 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
599 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
601 // Create an ODUCn object
602 OduBuilder oduBuilder = new OduBuilder()
603 .setRate(ODUCn.class)
604 .setOduFunction(ODUTTP.class)
605 .setMonitoringMode(MonitoringMode.Terminated)
606 .setTimActEnabled(false)
607 .setTimDetectMode(TimDetectMode.Disabled)
608 .setDegmIntervals(Uint8.valueOf(2))
609 .setDegthrPercentage(Uint16.valueOf(100))
610 .setOducnNRate(Uint16.valueOf(4))
611 .setOpu(opuBuilder.build());
614 String supportingOtucn;
615 List<String> listSupportingOtucnInterface = new ArrayList<>();
616 if (mapping.getSupportingOtucn() != null) {
617 listSupportingOtucnInterface.add(mapping.getSupportingOtucn());
618 supportingOtucn = mapping.getSupportingOtucn();
620 throw new OpenRoadmInterfaceException(
621 String.format("Missing supporting OTUCn interface on port-mapping"));
624 // Set the ODUCn rate from OTUCn interface naming convention
625 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
626 // check if the oducnrate is a valid value and if it is invalid, then throw error
627 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
628 throw new OpenRoadmInterfaceException(
629 String.format(RATE_EXCEPTION_MESSAGE));
632 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
634 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOdu.class,
635 logicalConnPoint + "-ODUC" + oducnrate);
637 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
638 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
639 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
641 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
643 // Post interface on the device
644 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
646 // Post the equipment-state change on the device circuit-pack if xpdr node
647 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
648 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
651 return oduInterfaceBuilder.getName();
654 // Overloaded methods should be together
655 // With SAPI and DAPI information
656 public String createOpenRoadmOducnInterface(String anodeId, String alogicalConnPoint,
657 String supportingOtucn, String znodeId, String zlogicalConnPoint)
658 throws OpenRoadmInterfaceException {
659 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
660 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
661 if (portMapA == null) {
662 throw new OpenRoadmInterfaceException(
663 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
664 anodeId, alogicalConnPoint));
667 if (portMapZ == null) {
668 throw new OpenRoadmInterfaceException(
669 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
670 znodeId, zlogicalConnPoint));
673 // Create ODUcn object
674 // Start with OPU object
676 OpuBuilder opuBuilder = new OpuBuilder()
677 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
678 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
680 // Create an ODUC4 object
681 OduBuilder oduBuilder = new OduBuilder()
682 .setRate(ODUCn.class)
683 .setOduFunction(ODUTTP.class)
684 .setMonitoringMode(MonitoringMode.Terminated)
685 .setTimActEnabled(false)
686 .setTimDetectMode(TimDetectMode.Disabled)
687 .setDegmIntervals(Uint8.valueOf(2))
688 .setDegthrPercentage(Uint16.valueOf(100))
689 .setOpu(opuBuilder.build())
690 .setTxSapi(portMapA.getLcpHashVal())
691 .setTxDapi(portMapZ.getLcpHashVal())
692 .setExpectedSapi(portMapZ.getLcpHashVal())
693 .setExpectedDapi(portMapZ.getLcpHashVal());
695 // Set the ODUCn rate from OTUCn interface naming convention
696 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
698 // check if the oducnrate is a valid value and if it is invalid, then throw error
699 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
700 throw new OpenRoadmInterfaceException(
701 String.format(RATE_EXCEPTION_MESSAGE));
704 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
706 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
707 alogicalConnPoint + ODUC + oducnrate);
710 List<String> listSupportingOtucnInterface = new ArrayList<>();
711 listSupportingOtucnInterface.add(supportingOtucn);
713 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
714 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
715 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
717 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
719 // Post interface on the device
720 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
722 // Post the equipment-state change on the device circuit-pack if xpdr node
723 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
724 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
727 return oduInterfaceBuilder.getName();
731 // This is only for transponder
732 public String createOpenRoadmOduflexInterface(String nodeId, String logicalConnPoint,
733 String supportingOducn)
734 throws OpenRoadmInterfaceException {
735 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
736 if (portMap == null) {
737 throw new OpenRoadmInterfaceException(
738 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
739 nodeId, logicalConnPoint));
742 OpuBuilder opuBuilder = new OpuBuilder()
743 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
744 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
746 // Parent Odu-allocation
747 // Set the trib-slot array
748 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
749 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
750 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
752 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
753 .setTribPortNumber(Uint16.valueOf(1))
754 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
756 // Create an ODUFlex object
757 OduBuilder oduBuilder = new OduBuilder()
758 .setRate(ODUflexCbr.class)
759 .setOduflexCbrService(ODUflexCbr400G.class)
760 .setOduFunction(ODUTTPCTP.class)
761 .setMonitoringMode(MonitoringMode.Terminated)
762 .setTimActEnabled(false)
763 .setTimDetectMode(TimDetectMode.Disabled)
764 .setDegmIntervals(Uint8.valueOf(2))
765 .setDegthrPercentage(Uint16.valueOf(100))
766 .setOpu(opuBuilder.build())
767 .setParentOduAllocation(parentOduAllocationBuilder.build());
769 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
770 logicalConnPoint + "-ODUFLEX");
772 List<String> listSupportingOtucnInterface = new ArrayList<>();
773 listSupportingOtucnInterface.add(supportingOducn);
775 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
778 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
780 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
782 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
784 // Post interface on the device
785 openRoadmInterfaces.postInterface(nodeId, oduflexInterfaceBuilder);
787 // Post the equipment-state change on the device circuit-pack if xpdr node
788 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
789 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
792 return oduflexInterfaceBuilder.getName();
795 // Overloaded methods should be together
796 // This is only for transponder; with SAPI/DAPI information
797 public String createOpenRoadmOduflexInterface(String anodeId, String alogicalConnPoint,
798 String supportingOducn, String znodeId, String zlogicalConnPoint)
799 throws OpenRoadmInterfaceException {
800 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
801 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
802 if (portMapA == null) {
803 throw new OpenRoadmInterfaceException(
804 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
805 anodeId, alogicalConnPoint));
808 if (portMapZ == null) {
809 throw new OpenRoadmInterfaceException(
810 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
811 znodeId, zlogicalConnPoint));
815 OpuBuilder opuBuilder = new OpuBuilder()
816 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
817 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
819 // Parent Odu-allocation
820 // Set the trib-slot array
821 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
822 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
823 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
825 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
826 .setTribPortNumber(Uint16.valueOf(1))
827 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
829 // Create an ODUFlex object
830 OduBuilder oduBuilder = new OduBuilder()
831 .setRate(ODUflexCbr.class)
832 .setOduflexCbrService(ODUflexCbr400G.class)
833 .setOduFunction(ODUTTPCTP.class)
834 .setMonitoringMode(MonitoringMode.Terminated)
835 .setTimActEnabled(false)
836 .setTimDetectMode(TimDetectMode.Disabled)
837 .setDegmIntervals(Uint8.valueOf(2))
838 .setDegthrPercentage(Uint16.valueOf(100))
839 .setTxSapi(portMapA.getLcpHashVal())
840 .setTxDapi(portMapZ.getLcpHashVal())
841 .setExpectedSapi(portMapZ.getLcpHashVal())
842 .setExpectedDapi(portMapA.getLcpHashVal())
843 .setOpu(opuBuilder.build())
844 .setParentOduAllocation(parentOduAllocationBuilder.build());
846 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
847 alogicalConnPoint + "-ODUFLEX");
849 List<String> listSupportingOtucnInterface = new ArrayList<>();
850 listSupportingOtucnInterface.add(supportingOducn);
852 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
855 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
857 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
859 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
861 // Post interface on the device
862 openRoadmInterfaces.postInterface(anodeId, oduflexInterfaceBuilder);
864 // Post the equipment-state change on the device circuit-pack if xpdr node
865 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
866 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
869 return oduflexInterfaceBuilder.getName();
872 public String createOpenRoadmOdu4OducnOduflex(String nodeId, String logicalConnPoint,
873 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
875 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
876 if (portMap == null) {
877 throw new OpenRoadmInterfaceException(
878 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
880 // Depending on OTU4 or OTUCn, supporting interface should
882 String interfaceOdu4OducnOduflex = null;
883 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
884 // create OTU4 interface
885 interfaceOdu4OducnOduflex = createOpenRoadmOdu4Interface(nodeId, logicalConnPoint, apiInfoA, apiInfoZ);
886 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
887 // Create ODUCn and ODUFlex interface.
888 String interfaceOducn = createOpenRoadmOducnInterface(nodeId, logicalConnPoint);
889 // Here we concat the two interfaces
890 interfaceOdu4OducnOduflex = interfaceOducn + "#"
891 + createOpenRoadmOduflexInterface(nodeId, logicalConnPoint, interfaceOducn);
894 return interfaceOdu4OducnOduflex;
897 public String createOpenRoadmOtnOducnInterface(String nodeId, String logicalConnPoint,
898 String supportingOtucn)
899 throws OpenRoadmInterfaceException {
900 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
901 if (portMap == null) {
902 throw new OpenRoadmInterfaceException(
903 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
904 nodeId, logicalConnPoint));
906 // Create ODUcn object
907 // Start with OPU object
909 OpuBuilder opuBuilder = new OpuBuilder()
910 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
911 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
913 // Create an ODUC4 object
914 OduBuilder oduBuilder = new OduBuilder()
915 .setRate(ODUCn.class)
916 .setOduFunction(ODUTTP.class)
917 .setMonitoringMode(MonitoringMode.Terminated)
918 .setTimActEnabled(false)
919 .setTimDetectMode(TimDetectMode.Disabled)
920 .setDegmIntervals(Uint8.valueOf(2))
921 .setDegthrPercentage(Uint16.valueOf(100))
922 .setOpu(opuBuilder.build());
924 // Set the ODUCn rate from OTUCn interface naming convention
925 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
927 // check if the oducnrate is a valid value and if it is invalid, then throw error
928 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
929 throw new OpenRoadmInterfaceException(
930 String.format(RATE_EXCEPTION_MESSAGE));
933 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
935 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
936 logicalConnPoint + ODUC + oducnrate);
939 List<String> listSupportingOtucnInterface = new ArrayList<>();
940 listSupportingOtucnInterface.add(supportingOtucn);
942 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
943 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
944 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
946 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
948 // Post interface on the device
949 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
950 // Post the equipment-state change on the device circuit-pack if xpdr node
951 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
952 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
954 // Update the port-mapping with the interface information
955 this.portMapping.updateMapping(nodeId, portMap);
956 return oduInterfaceBuilder.getName();
960 // With SAPI and DAPI information
961 public String createOpenRoadmOtnOducnInterface(String anodeId, String alogicalConnPoint,
962 String supportingOtucn, String znodeId, String zlogicalConnPoint)
963 throws OpenRoadmInterfaceException {
964 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
965 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
966 if (portMapA == null) {
967 throw new OpenRoadmInterfaceException(
968 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
969 anodeId, alogicalConnPoint));
972 if (portMapZ == null) {
973 throw new OpenRoadmInterfaceException(
974 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
975 znodeId, zlogicalConnPoint));
978 // Create ODUcn object
979 // Start with OPU object
981 OpuBuilder opuBuilder = new OpuBuilder()
982 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
983 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
985 // Create an ODUCn object
986 OduBuilder oduBuilder = new OduBuilder()
987 .setRate(ODUCn.class)
988 .setOduFunction(ODUTTP.class)
989 .setMonitoringMode(MonitoringMode.Terminated)
990 .setTimActEnabled(false)
991 .setTimDetectMode(TimDetectMode.Disabled)
992 .setDegmIntervals(Uint8.valueOf(2))
993 .setDegthrPercentage(Uint16.valueOf(100))
994 .setOpu(opuBuilder.build())
995 .setTxSapi(portMapA.getLcpHashVal())
996 .setTxDapi(portMapZ.getLcpHashVal())
997 .setExpectedSapi(portMapZ.getLcpHashVal())
998 .setExpectedDapi(portMapZ.getLcpHashVal());
1000 // Set the ODUCn rate from OTUCn interface naming convention
1001 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
1003 // check if the oducnrate is a valid value and if it is invalid, then throw error
1004 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
1005 throw new OpenRoadmInterfaceException(
1006 String.format(RATE_EXCEPTION_MESSAGE));
1009 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
1011 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
1012 alogicalConnPoint + ODUC + oducnrate);
1015 List<String> listSupportingOtucnInterface = new ArrayList<>();
1016 listSupportingOtucnInterface.add(supportingOtucn);
1018 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
1019 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
1020 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
1022 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
1024 // Post interface on the device
1025 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
1026 // Post the equipment-state change on the device circuit-pack if xpdr node
1027 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
1028 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
1030 // Update the port-mapping with the interface information
1031 this.portMapping.updateMapping(anodeId, portMapA);
1032 return oduInterfaceBuilder.getName();
1035 // This creates the name of the interface with slot numbers at the end
1036 public String createOpenRoadmOtsiInterfaceName(String logicalConnectionPoint, String spectralSlotName) {
1037 return String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, logicalConnectionPoint, spectralSlotName);
1040 private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, Class<? extends InterfaceType> type,
1042 return new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder()
1043 .setDescription(" TBD ")
1044 .setCircuitId(" TBD ")
1045 .setSupportingCircuitPackName(portMap.getSupportingCircuitPackName())
1046 .setSupportingPort(portMap.getSupportingPort())
1047 .setAdministrativeState(AdminStates.InService)
1050 .withKey(new InterfaceKey(key));
1053 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
1054 value = "UPM_UNCALLED_PRIVATE_METHOD",
1055 justification = "call in call() method")
1056 private int getServiceRate(ModulationFormat modulationFormat, SpectrumInformation spectrumInformation) {
1058 switch (modulationFormat) {
1060 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
1063 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
1066 // DpQam16 is possible for both 31.6 or 63.1 GBaud, for which spectral width is different
1067 // Here take the difference of highest and lowest spectral numbers and determine the width
1068 LOG.info("The width with guard band {}", (spectrumInformation.getHigherSpectralSlotNumber()
1069 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY);
1070 if ((spectrumInformation.getHigherSpectralSlotNumber()
1071 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY == 50.0) {
1072 // Based on roll-of-factor of 0.5, 50 - 12.5 = 37.5GHz translates to 31.6 GBaud
1073 LOG.info("The baud-rate is 31.6 GBaud");
1074 LOG.info("Given modulation format {} with 31.6 Gbaud rate is 200G", modulationFormat);
1077 // Based on roll-of-factor of 0.5, 87.5 - 12.5 = 75GHz translates to 63.1 GBaud
1078 LOG.info("The baud-rate is 63.1 GBaud");
1082 LOG.error("Modulation format is required to select the rate");