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.rev220114.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.rev200327.If100GE;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.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
369 String interfaceOtsiName = createOpenRoadmOtsiInterface(nodeId, logicalConnPoint, spectrumInformation);
370 interfaceOchOtsiOtsigroup = createOpenRoadmOtsiGroupInterface(nodeId, logicalConnPoint, interfaceOtsiName,
371 spectrumInformation);
374 return interfaceOchOtsiOtsigroup;
377 public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface,
378 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
380 Mapping mapping = this.portMapping.getMapping(nodeId, logicalConnPoint);
381 if (mapping == null) {
382 throw new OpenRoadmInterfaceException(
383 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
386 otuInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOtu.class,
387 logicalConnPoint + "-OTU4");
388 // Supporting interface list
389 List<String> listSupportingOChInterface = new ArrayList<>();
390 listSupportingOChInterface.add(supportOchInterface);
391 otuInterfaceBldr.setSupportingInterfaceList(listSupportingOChInterface);
393 // OTU interface specific data
394 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder
395 otuIfBuilder = new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu
396 .interfaces.rev200529.otu.container.OtuBuilder()
398 .setRate(OTU4.class);
399 if (apiInfoA != null) {
400 otuIfBuilder.setTxSapi(apiInfoA.getSapi())
401 .setTxDapi(apiInfoA.getDapi())
402 .setExpectedSapi(apiInfoA.getExpectedSapi())
403 .setExpectedDapi(apiInfoA.getExpectedDapi());
405 if (apiInfoZ != null) {
406 otuIfBuilder.setTxSapi(apiInfoZ.getSapi())
407 .setTxDapi(apiInfoZ.getDapi())
408 .setExpectedSapi(apiInfoZ.getExpectedSapi())
409 .setExpectedDapi(apiInfoZ.getExpectedDapi());
412 // Create Interface1 type object required for adding as augmentation
413 // TODO look at imports of different versions of class
414 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
415 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
416 otuInterfaceBldr.addAugmentation(otuIf1Builder.setOtu(otuIfBuilder.build()).build());
418 // Post interface on the device
419 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBldr);
420 this.portMapping.updateMapping(nodeId, mapping);
421 return otuInterfaceBldr.getName();
425 public String createOpenRoadmOtucnInterface(String nodeId, String logicalConnPoint,
426 String supportingOtsiGroupInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
427 throws OpenRoadmInterfaceException {
428 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
429 if (mapping == null) {
430 throw new OpenRoadmInterfaceException(
431 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
432 nodeId, logicalConnPoint));
434 // Create an OTUCn object
435 OtuBuilder otuBuilder = new OtuBuilder()
436 .setRate(OTUCn.class)
437 .setTimActEnabled(false)
438 .setTimDetectMode(TimDetectMode.Disabled)
439 .setDegmIntervals(Uint8.valueOf(2))
440 .setDegthrPercentage(Uint16.valueOf(100));
442 if (apiInfoA != null) {
443 otuBuilder.setTxSapi(apiInfoA.getSapi())
444 .setTxDapi(apiInfoA.getDapi())
445 .setExpectedSapi(apiInfoA.getExpectedSapi())
446 .setExpectedDapi(apiInfoA.getExpectedDapi());
448 if (apiInfoZ != null) {
449 otuBuilder.setTxSapi(apiInfoZ.getSapi())
450 .setTxDapi(apiInfoZ.getDapi())
451 .setExpectedSapi(apiInfoZ.getExpectedSapi())
452 .setExpectedDapi(apiInfoZ.getExpectedDapi());
454 // Set the OTUCn rate for various rates
455 String rate = supportingOtsiGroupInterface.substring(supportingOtsiGroupInterface.lastIndexOf('-') + 1);
457 String otucnrate = null;
458 boolean rateNotFound = false;
461 otuBuilder.setOtucnNRate(Uint16.valueOf(2));
465 otuBuilder.setOtucnNRate(Uint16.valueOf(3));
469 otuBuilder.setOtucnNRate(Uint16.valueOf(4));
473 LOG.error("Rate {} is not supported", rate);
478 throw new OpenRoadmInterfaceException(
479 String.format(RATE_EXCEPTION_MESSAGE));
482 InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOtu.class,
483 logicalConnPoint + "-OTUC" + otucnrate);
486 List<String> listSupportingOtsiGroupInterface = new ArrayList<>();
487 listSupportingOtsiGroupInterface.add(supportingOtsiGroupInterface);
489 otuInterfaceBuilder.setSupportingInterfaceList(listSupportingOtsiGroupInterface);
490 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
491 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
493 otuInterfaceBuilder.addAugmentation(otuIf1Builder.setOtu(otuBuilder.build()).build());
495 // Post interface on the device
496 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBuilder);
497 // Post the equipment-state change on the device circuit-pack if xpdr node
498 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
499 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
501 this.portMapping.updateMapping(nodeId, mapping);
502 return otuInterfaceBuilder.getName();
505 public String createOpenRoadmOtu4OtucnInterface(String nodeId, String logicalConnPoint,
506 String supportingInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
507 throws OpenRoadmInterfaceException {
508 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
509 if (portMap == null) {
510 throw new OpenRoadmInterfaceException(
511 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
513 // Depending on OCH-OTU4-ODU4 interface or OTSi-OTSi-group, supporting interface should
515 String interfaceOtu4Otucn = null;
516 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
517 // create OTU4 interface
518 interfaceOtu4Otucn = createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportingInterface,
520 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
522 interfaceOtu4Otucn = createOpenRoadmOtucnInterface(nodeId, logicalConnPoint, supportingInterface,
526 return interfaceOtu4Otucn;
529 public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint,
530 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
532 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
533 if (mapping == null) {
534 throw new OpenRoadmInterfaceException(
535 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
537 InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOdu.class,
538 logicalConnPoint + "-ODU4");
539 List<String> listSupportingOtu4Interface = new ArrayList<>();
540 if (mapping.getSupportingOtu4() != null) {
541 listSupportingOtu4Interface.add(mapping.getSupportingOtu4());
542 oduInterfaceBldr.setSupportingInterfaceList(listSupportingOtu4Interface);
546 OpuBuilder opuBuilder = new OpuBuilder()
547 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
548 .setPayloadType(PayloadTypeDef.getDefaultInstance("07"));
550 // Create an ODU4 object
551 OduBuilder oduBuilder = new OduBuilder()
553 .setOduFunction(ODUTTP.class)
554 .setMonitoringMode(MonitoringMode.Terminated)
555 .setOpu(opuBuilder.build());
557 if (apiInfoA != null) {
558 oduBuilder.setTxSapi(apiInfoA.getSapi())
559 .setTxDapi(apiInfoA.getDapi())
560 .setExpectedSapi(apiInfoA.getExpectedSapi())
561 .setExpectedDapi(apiInfoA.getExpectedDapi());
563 if (apiInfoZ != null) {
564 oduBuilder.setTxSapi(apiInfoZ.getSapi())
565 .setTxDapi(apiInfoZ.getDapi())
566 .setExpectedSapi(apiInfoZ.getExpectedSapi())
567 .setExpectedDapi(apiInfoZ.getExpectedDapi());
569 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
570 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
572 oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
574 // Post interface on the device
575 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr);
576 // Since this is not a CTP, we can update the port-mapping
577 LOG.info("{}-{} updating mapping with interface {}", nodeId, logicalConnPoint, oduInterfaceBldr.getName());
578 this.portMapping.updateMapping(nodeId, mapping);
580 return oduInterfaceBldr.getName();
584 public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint)
585 throws OpenRoadmInterfaceException {
586 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
587 if (mapping == null) {
588 throw new OpenRoadmInterfaceException(
589 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
590 nodeId, logicalConnPoint));
592 // Create ODUcn object
593 // Start with OPU object
595 OpuBuilder opuBuilder = new OpuBuilder()
596 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
597 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
599 // Create an ODUCn object
600 OduBuilder oduBuilder = new OduBuilder()
601 .setRate(ODUCn.class)
602 .setOduFunction(ODUTTP.class)
603 .setMonitoringMode(MonitoringMode.Terminated)
604 .setTimActEnabled(false)
605 .setTimDetectMode(TimDetectMode.Disabled)
606 .setDegmIntervals(Uint8.valueOf(2))
607 .setDegthrPercentage(Uint16.valueOf(100))
608 .setOducnNRate(Uint16.valueOf(4))
609 .setOpu(opuBuilder.build());
612 String supportingOtucn;
613 List<String> listSupportingOtucnInterface = new ArrayList<>();
614 if (mapping.getSupportingOtucn() != null) {
615 listSupportingOtucnInterface.add(mapping.getSupportingOtucn());
616 supportingOtucn = mapping.getSupportingOtucn();
618 throw new OpenRoadmInterfaceException(
619 String.format("Missing supporting OTUCn interface on port-mapping"));
622 // Set the ODUCn rate from OTUCn interface naming convention
623 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
624 // check if the oducnrate is a valid value and if it is invalid, then throw error
625 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
626 throw new OpenRoadmInterfaceException(
627 String.format(RATE_EXCEPTION_MESSAGE));
630 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
632 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOdu.class,
633 logicalConnPoint + "-ODUC" + oducnrate);
635 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
636 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
637 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
639 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
641 // Post interface on the device
642 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
644 // Post the equipment-state change on the device circuit-pack if xpdr node
645 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
646 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
649 return oduInterfaceBuilder.getName();
652 // Overloaded methods should be together
653 // With SAPI and DAPI information
654 public String createOpenRoadmOducnInterface(String anodeId, String alogicalConnPoint,
655 String supportingOtucn, String znodeId, String zlogicalConnPoint)
656 throws OpenRoadmInterfaceException {
657 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
658 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
659 if (portMapA == null) {
660 throw new OpenRoadmInterfaceException(
661 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
662 anodeId, alogicalConnPoint));
665 if (portMapZ == null) {
666 throw new OpenRoadmInterfaceException(
667 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
668 znodeId, zlogicalConnPoint));
671 // Create ODUcn object
672 // Start with OPU object
674 OpuBuilder opuBuilder = new OpuBuilder()
675 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
676 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
678 // Create an ODUC4 object
679 OduBuilder oduBuilder = new OduBuilder()
680 .setRate(ODUCn.class)
681 .setOduFunction(ODUTTP.class)
682 .setMonitoringMode(MonitoringMode.Terminated)
683 .setTimActEnabled(false)
684 .setTimDetectMode(TimDetectMode.Disabled)
685 .setDegmIntervals(Uint8.valueOf(2))
686 .setDegthrPercentage(Uint16.valueOf(100))
687 .setOpu(opuBuilder.build())
688 .setTxSapi(portMapA.getLcpHashVal())
689 .setTxDapi(portMapZ.getLcpHashVal())
690 .setExpectedSapi(portMapZ.getLcpHashVal())
691 .setExpectedDapi(portMapZ.getLcpHashVal());
693 // Set the ODUCn rate from OTUCn interface naming convention
694 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
696 // check if the oducnrate is a valid value and if it is invalid, then throw error
697 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
698 throw new OpenRoadmInterfaceException(
699 String.format(RATE_EXCEPTION_MESSAGE));
702 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
704 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
705 alogicalConnPoint + ODUC + oducnrate);
708 List<String> listSupportingOtucnInterface = new ArrayList<>();
709 listSupportingOtucnInterface.add(supportingOtucn);
711 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
712 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
713 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
715 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
717 // Post interface on the device
718 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
720 // Post the equipment-state change on the device circuit-pack if xpdr node
721 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
722 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
725 return oduInterfaceBuilder.getName();
729 // This is only for transponder
730 public String createOpenRoadmOduflexInterface(String nodeId, String logicalConnPoint,
731 String supportingOducn)
732 throws OpenRoadmInterfaceException {
733 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
734 if (portMap == null) {
735 throw new OpenRoadmInterfaceException(
736 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
737 nodeId, logicalConnPoint));
740 OpuBuilder opuBuilder = new OpuBuilder()
741 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
742 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
744 // Parent Odu-allocation
745 // Set the trib-slot array
746 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
747 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
748 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
750 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
751 .setTribPortNumber(Uint16.valueOf(1))
752 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
754 // Create an ODUFlex object
755 OduBuilder oduBuilder = new OduBuilder()
756 .setRate(ODUflexCbr.class)
757 .setOduflexCbrService(ODUflexCbr400G.class)
758 .setOduFunction(ODUTTPCTP.class)
759 .setMonitoringMode(MonitoringMode.Terminated)
760 .setTimActEnabled(false)
761 .setTimDetectMode(TimDetectMode.Disabled)
762 .setDegmIntervals(Uint8.valueOf(2))
763 .setDegthrPercentage(Uint16.valueOf(100))
764 .setOpu(opuBuilder.build())
765 .setParentOduAllocation(parentOduAllocationBuilder.build());
767 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
768 logicalConnPoint + "-ODUFLEX");
770 List<String> listSupportingOtucnInterface = new ArrayList<>();
771 listSupportingOtucnInterface.add(supportingOducn);
773 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
776 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
778 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
780 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
782 // Post interface on the device
783 openRoadmInterfaces.postInterface(nodeId, oduflexInterfaceBuilder);
785 // Post the equipment-state change on the device circuit-pack if xpdr node
786 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
787 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
790 return oduflexInterfaceBuilder.getName();
793 // Overloaded methods should be together
794 // This is only for transponder; with SAPI/DAPI information
795 public String createOpenRoadmOduflexInterface(String anodeId, String alogicalConnPoint,
796 String supportingOducn, String znodeId, String zlogicalConnPoint)
797 throws OpenRoadmInterfaceException {
798 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
799 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
800 if (portMapA == null) {
801 throw new OpenRoadmInterfaceException(
802 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
803 anodeId, alogicalConnPoint));
806 if (portMapZ == null) {
807 throw new OpenRoadmInterfaceException(
808 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
809 znodeId, zlogicalConnPoint));
813 OpuBuilder opuBuilder = new OpuBuilder()
814 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
815 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
817 // Parent Odu-allocation
818 // Set the trib-slot array
819 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
820 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
821 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
823 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
824 .setTribPortNumber(Uint16.valueOf(1))
825 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
827 // Create an ODUFlex object
828 OduBuilder oduBuilder = new OduBuilder()
829 .setRate(ODUflexCbr.class)
830 .setOduflexCbrService(ODUflexCbr400G.class)
831 .setOduFunction(ODUTTPCTP.class)
832 .setMonitoringMode(MonitoringMode.Terminated)
833 .setTimActEnabled(false)
834 .setTimDetectMode(TimDetectMode.Disabled)
835 .setDegmIntervals(Uint8.valueOf(2))
836 .setDegthrPercentage(Uint16.valueOf(100))
837 .setTxSapi(portMapA.getLcpHashVal())
838 .setTxDapi(portMapZ.getLcpHashVal())
839 .setExpectedSapi(portMapZ.getLcpHashVal())
840 .setExpectedDapi(portMapA.getLcpHashVal())
841 .setOpu(opuBuilder.build())
842 .setParentOduAllocation(parentOduAllocationBuilder.build());
844 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
845 alogicalConnPoint + "-ODUFLEX");
847 List<String> listSupportingOtucnInterface = new ArrayList<>();
848 listSupportingOtucnInterface.add(supportingOducn);
850 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
853 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
855 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
857 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
859 // Post interface on the device
860 openRoadmInterfaces.postInterface(anodeId, oduflexInterfaceBuilder);
862 // Post the equipment-state change on the device circuit-pack if xpdr node
863 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
864 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
867 return oduflexInterfaceBuilder.getName();
870 public String createOpenRoadmOdu4OducnOduflex(String nodeId, String logicalConnPoint,
871 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
873 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
874 if (portMap == null) {
875 throw new OpenRoadmInterfaceException(
876 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
878 // Depending on OTU4 or OTUCn, supporting interface should
880 String interfaceOdu4Oducn = null;
881 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
882 // create OTU4 interface
883 interfaceOdu4Oducn = createOpenRoadmOdu4Interface(nodeId, logicalConnPoint, apiInfoA, apiInfoZ);
884 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
885 // Create ODUCn and ODUFlex interface.
886 String interfaceOducn = createOpenRoadmOducnInterface(nodeId, logicalConnPoint);
887 interfaceOdu4Oducn = createOpenRoadmOduflexInterface(nodeId, logicalConnPoint, interfaceOducn);
890 return interfaceOdu4Oducn;
893 public String createOpenRoadmOtnOducnInterface(String nodeId, String logicalConnPoint,
894 String supportingOtucn)
895 throws OpenRoadmInterfaceException {
896 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
897 if (portMap == null) {
898 throw new OpenRoadmInterfaceException(
899 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
900 nodeId, logicalConnPoint));
902 // Create ODUcn object
903 // Start with OPU object
905 OpuBuilder opuBuilder = new OpuBuilder()
906 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
907 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
909 // Create an ODUC4 object
910 OduBuilder oduBuilder = new OduBuilder()
911 .setRate(ODUCn.class)
912 .setOduFunction(ODUTTP.class)
913 .setMonitoringMode(MonitoringMode.Terminated)
914 .setTimActEnabled(false)
915 .setTimDetectMode(TimDetectMode.Disabled)
916 .setDegmIntervals(Uint8.valueOf(2))
917 .setDegthrPercentage(Uint16.valueOf(100))
918 .setOpu(opuBuilder.build());
920 // Set the ODUCn rate from OTUCn interface naming convention
921 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
923 // check if the oducnrate is a valid value and if it is invalid, then throw error
924 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
925 throw new OpenRoadmInterfaceException(
926 String.format(RATE_EXCEPTION_MESSAGE));
929 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
931 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
932 logicalConnPoint + ODUC + oducnrate);
935 List<String> listSupportingOtucnInterface = new ArrayList<>();
936 listSupportingOtucnInterface.add(supportingOtucn);
938 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
939 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
940 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
942 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
944 // Post interface on the device
945 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
946 // Post the equipment-state change on the device circuit-pack if xpdr node
947 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
948 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
950 // Update the port-mapping with the interface information
951 this.portMapping.updateMapping(nodeId, portMap);
952 return oduInterfaceBuilder.getName();
956 // With SAPI and DAPI information
957 public String createOpenRoadmOtnOducnInterface(String anodeId, String alogicalConnPoint,
958 String supportingOtucn, String znodeId, String zlogicalConnPoint)
959 throws OpenRoadmInterfaceException {
960 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
961 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
962 if (portMapA == null) {
963 throw new OpenRoadmInterfaceException(
964 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
965 anodeId, alogicalConnPoint));
968 if (portMapZ == null) {
969 throw new OpenRoadmInterfaceException(
970 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
971 znodeId, zlogicalConnPoint));
974 // Create ODUcn object
975 // Start with OPU object
977 OpuBuilder opuBuilder = new OpuBuilder()
978 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
979 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
981 // Create an ODUCn object
982 OduBuilder oduBuilder = new OduBuilder()
983 .setRate(ODUCn.class)
984 .setOduFunction(ODUTTP.class)
985 .setMonitoringMode(MonitoringMode.Terminated)
986 .setTimActEnabled(false)
987 .setTimDetectMode(TimDetectMode.Disabled)
988 .setDegmIntervals(Uint8.valueOf(2))
989 .setDegthrPercentage(Uint16.valueOf(100))
990 .setOpu(opuBuilder.build())
991 .setTxSapi(portMapA.getLcpHashVal())
992 .setTxDapi(portMapZ.getLcpHashVal())
993 .setExpectedSapi(portMapZ.getLcpHashVal())
994 .setExpectedDapi(portMapZ.getLcpHashVal());
996 // Set the ODUCn rate from OTUCn interface naming convention
997 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
999 // check if the oducnrate is a valid value and if it is invalid, then throw error
1000 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
1001 throw new OpenRoadmInterfaceException(
1002 String.format(RATE_EXCEPTION_MESSAGE));
1005 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
1007 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
1008 alogicalConnPoint + ODUC + oducnrate);
1011 List<String> listSupportingOtucnInterface = new ArrayList<>();
1012 listSupportingOtucnInterface.add(supportingOtucn);
1014 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
1015 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
1016 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
1018 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
1020 // Post interface on the device
1021 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
1022 // Post the equipment-state change on the device circuit-pack if xpdr node
1023 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
1024 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
1026 // Update the port-mapping with the interface information
1027 this.portMapping.updateMapping(anodeId, portMapA);
1028 return oduInterfaceBuilder.getName();
1031 // This creates the name of the interface with slot numbers at the end
1032 public String createOpenRoadmOtsiInterfaceName(String logicalConnectionPoint, String spectralSlotName) {
1033 return String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, logicalConnectionPoint, spectralSlotName);
1036 private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, Class<? extends InterfaceType> type,
1038 return new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder()
1039 .setDescription(" TBD ")
1040 .setCircuitId(" TBD ")
1041 .setSupportingCircuitPackName(portMap.getSupportingCircuitPackName())
1042 .setSupportingPort(portMap.getSupportingPort())
1043 .setAdministrativeState(AdminStates.InService)
1046 .withKey(new InterfaceKey(key));
1049 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
1050 value = "UPM_UNCALLED_PRIVATE_METHOD",
1051 justification = "call in call() method")
1052 private int getServiceRate(ModulationFormat modulationFormat, SpectrumInformation spectrumInformation) {
1054 switch (modulationFormat) {
1056 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
1059 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
1062 // DpQam16 is possible for both 31.6 or 63.1 GBaud, for which spectral width is different
1063 // Here take the difference of highest and lowest spectral numbers and determine the width
1064 LOG.info("The width with guard band {}", (spectrumInformation.getHigherSpectralSlotNumber()
1065 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY);
1066 if ((spectrumInformation.getHigherSpectralSlotNumber()
1067 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY == 50.0) {
1068 // Based on roll-of-factor of 0.5, 50 - 12.5 = 37.5GHz translates to 31.6 GBaud
1069 LOG.info("The baud-rate is 31.6 GBaud");
1070 LOG.info("Given modulation format {} with 31.6 Gbaud rate is 200G", modulationFormat);
1073 // Based on roll-of-factor of 0.5, 87.5 - 12.5 = 75GHz translates to 63.1 GBaud
1074 LOG.info("The baud-rate is 63.1 GBaud");
1078 LOG.error("Modulation format is required to select the rate");