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.maintenance.loopback.rev191129.maint.loopback.MaintLoopbackBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529.och.container.OchBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.attributes.FlexoBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.container.OtsiBuilder;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUCn;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTP;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTPCTP;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr400G;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTU4;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTUCn;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.PayloadTypeDef;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.OduAttributes.MonitoringMode;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.odu.container.OduBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.opu.OpuBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.otsi.group.container.OtsiGroupBuilder;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GE;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
77 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOtsiOtsigroup;
78 import org.opendaylight.yangtools.yang.common.Uint16;
79 import org.opendaylight.yangtools.yang.common.Uint32;
80 import org.opendaylight.yangtools.yang.common.Uint8;
81 import org.slf4j.Logger;
82 import org.slf4j.LoggerFactory;
84 public class OpenRoadmInterface710 {
85 private static final String MAPPING_ERROR_EXCEPTION_MESSAGE =
86 "Unable to get mapping from PortMapping for node % and logical connection port %s";
87 private static final String MODULATION_FMT_EXCEPTION_MESSAGE =
88 "Unable to get the modulation format";
89 private static final String RATE_EXCEPTION_MESSAGE =
90 "Unable to get the rate";
91 private static final String ODUC = "-ODUC";
92 private static final List<String> SUPPORTED_ODUCN_RATES = new ArrayList<>() {
99 private final PortMapping portMapping;
100 private final OpenRoadmInterfaces openRoadmInterfaces;
101 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface710.class);
103 public OpenRoadmInterface710(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
104 this.portMapping = portMapping;
105 this.openRoadmInterfaces = openRoadmInterfaces;
108 public String createOpenRoadmEthInterface(String nodeId, String logicalConnPoint)
109 throws OpenRoadmInterfaceException {
110 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
111 if (portMap == null) {
112 throw new OpenRoadmInterfaceException(
113 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
115 // Ethernet interface specific data
116 EthernetBuilder ethIfBuilder = new EthernetBuilder()
118 // Default set to 400G
119 .setSpeed(Uint32.valueOf(400000));
120 // We have to differentiate if-100GE vs if-400GE
121 if (portMap.getSupportedInterfaceCapability().contains(If100GE.class)) {
122 ethIfBuilder.setSpeed(Uint32.valueOf(100000));
125 InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class,
126 logicalConnPoint + "-ETHERNET");
128 // Create Interface1 type object required for adding as augmentation
129 Interface1Builder ethIf1Builder = new Interface1Builder();
130 ethInterfaceBldr.addAugmentation(ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
132 // Post interface on the device
133 openRoadmInterfaces.postInterface(nodeId, ethInterfaceBldr);
135 // Post the equipment-state change on the device circuit-pack
136 openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
138 return ethInterfaceBldr.getName();
141 public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint,
142 SpectrumInformation spectrumInformation)
143 throws OpenRoadmInterfaceException {
145 ModulationFormat modulationFormat = ModulationFormat.DpQpsk;
146 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
147 .forName(spectrumInformation.getModulationFormat());
148 if (optionalModulationFormat.isPresent()) {
149 modulationFormat = optionalModulationFormat.get();
151 // OCH interface specific data
152 OchBuilder ocIfBuilder = new OchBuilder()
153 .setFrequency(new FrequencyTHz(spectrumInformation.getCenterFrequency()))
154 .setRate(R100G.class)
155 .setTransmitPower(new PowerDBm(new BigDecimal("-5")))
156 .setModulationFormat(modulationFormat);
157 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
158 if (portMap == null) {
159 throw new OpenRoadmInterfaceException(
160 String.format("Unable to get mapping from PortMapping for node %s and logical connection port %s",
161 nodeId, logicalConnPoint));
163 // Create generic interface
165 ochInterfaceBldr = createGenericInterfaceBuilder(portMap, OpticalChannel.class,
166 spectrumInformation.getIdentifierFromParams(logicalConnPoint));
167 // Create Interface1 type object required for adding as augmentation
168 // TODO look at imports of different versions of class
169 org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529.Interface1Builder
170 ochIf1Builder = new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529
171 .Interface1Builder();
172 ochInterfaceBldr.addAugmentation(ochIf1Builder.setOch(ocIfBuilder.build()).build());
174 // Post interface on the device
175 openRoadmInterfaces.postInterface(nodeId, ochInterfaceBldr);
177 // Post the equipment-state change on the device circuit-pack if xpdr node
178 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
179 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
182 return ochInterfaceBldr.getName();
185 public String createOpenRoadmOtsiInterface(String nodeId, String logicalConnPoint,
186 SpectrumInformation spectrumInformation)
187 throws OpenRoadmInterfaceException {
189 ModulationFormat modulationFormat;
190 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
191 .forName(spectrumInformation.getModulationFormat());
192 if (optionalModulationFormat.isPresent()) {
193 modulationFormat = optionalModulationFormat.get();
195 throw new OpenRoadmInterfaceException(
196 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
199 // OTSI interface specific data
200 OtsiBuilder otsiBuilder = new OtsiBuilder()
201 .setFrequency(new FrequencyTHz(spectrumInformation.getCenterFrequency()))
202 .setTransmitPower(new PowerDBm(new BigDecimal("-5")))
203 .setProvisionMode(ProvisionModeType.Explicit)
205 .setModulationFormat(modulationFormat);
207 // Set the Flexo values
208 FlexoBuilder flexoBuilder = new FlexoBuilder();
209 boolean rateNotFound = false;
210 // Use the rate to switch rather than modulation format
211 int serviceRate = getServiceRate(modulationFormat, spectrumInformation);
212 switch (serviceRate) {
214 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
215 if (modulationFormat == ModulationFormat.DpQam16) {
216 LOG.info("FOIC is 2.8 for 31.6 Gbaud and rate is 200");
217 // FOIC rate is different
218 flexoBuilder.setFoicType(Foic28.class)
219 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
220 Uint8.valueOf(3), Uint8.valueOf(4))));
222 // default is dp-qpsk for 200G under 63.1 GBaud
223 flexoBuilder.setFoicType(Foic24.class)
224 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2))));
226 otsiBuilder.setOtsiRate(R200GOtsi.class)
227 .setFlexo(flexoBuilder.build());
230 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
231 flexoBuilder.setFoicType(Foic36.class)
232 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
234 otsiBuilder.setOtsiRate(R300GOtsi.class)
235 .setFlexo(flexoBuilder.build());
238 // Default baud-rate is 63.1 Gbaud
239 LOG.info("Given modulation format is {} and thus rate is 400G", modulationFormat);
240 flexoBuilder.setFoicType(Foic48.class)
241 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
242 Uint8.valueOf(3), Uint8.valueOf(4))));
243 otsiBuilder.setModulationFormat(modulationFormat)
244 .setOtsiRate(R400GOtsi.class)
245 .setFlexo(flexoBuilder.build());
248 LOG.error("Rate {} is unsupported", serviceRate);
254 throw new OpenRoadmInterfaceException(
255 String.format(RATE_EXCEPTION_MESSAGE));
258 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
259 if (portMap == null) {
260 throw new OpenRoadmInterfaceException(
261 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
263 // Create generic interface
264 InterfaceBuilder otsiInterfaceBldr = createGenericInterfaceBuilder(portMap, Otsi.class,
265 spectrumInformation.getIdentifierFromParams(logicalConnPoint));
266 // Create Interface1 type object required for adding as augmentation
267 org.opendaylight.yang.gen.v1.http
268 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder otsiIf1Builder =
269 new org.opendaylight.yang.gen.v1.http
270 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder();
272 otsiInterfaceBldr.addAugmentation(otsiIf1Builder.setOtsi(otsiBuilder.build()).build());
274 // Post interface on the device
275 openRoadmInterfaces.postInterface(nodeId, otsiInterfaceBldr);
277 // Post the equipment-state change on the device circuit-pack if xpdr node
278 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
279 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
282 return otsiInterfaceBldr.getName();
285 // This is a transponder use-case where the supporting port is just one, but YANG model
286 // requires supporting port to be list
287 public String createOpenRoadmOtsiGroupInterface(String nodeId, String logicalConnPoint,
288 String supportingOtsiInterface, SpectrumInformation spectrumInformation)
289 throws OpenRoadmInterfaceException {
290 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
291 if (portMap == null) {
292 throw new OpenRoadmInterfaceException(
293 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
294 nodeId, logicalConnPoint));
296 // Check the modulation format
297 ModulationFormat modulationFormat;
298 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
299 .forName(spectrumInformation.getModulationFormat());
300 if (optionalModulationFormat.isPresent()) {
301 modulationFormat = optionalModulationFormat.get();
303 throw new OpenRoadmInterfaceException(
304 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
306 int serviceRate = getServiceRate(modulationFormat, spectrumInformation);
307 // Create an OTSI group object
308 OtsiGroupBuilder otsiGroupBuilder = new OtsiGroupBuilder()
309 .setGroupId(Uint32.valueOf(1));
310 boolean rateNotFound = false;
311 switch (serviceRate) {
313 otsiGroupBuilder.setGroupRate(R200GOtsi.class);
316 otsiGroupBuilder.setGroupRate(R300GOtsi.class);
319 otsiGroupBuilder.setGroupRate(R400GOtsi.class);
322 LOG.error("Rate {} is not supported", serviceRate);
327 throw new OpenRoadmInterfaceException(
328 String.format(RATE_EXCEPTION_MESSAGE));
331 // Create generic interface
332 InterfaceBuilder otsiGroupInterfaceBldr = createGenericInterfaceBuilder(portMap, OtsiGroup.class,
333 logicalConnPoint + String.join("-", "", "OTSIGROUP", serviceRate + "G"));
336 List<String> listSupportingOtsiInterface = new ArrayList<>();
337 listSupportingOtsiInterface.add(supportingOtsiInterface);
338 otsiGroupInterfaceBldr.setSupportingInterfaceList(listSupportingOtsiInterface);
340 org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder
341 otsiGroupIf1Builder =
342 new org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder();
343 otsiGroupInterfaceBldr.addAugmentation(otsiGroupIf1Builder.setOtsiGroup(otsiGroupBuilder.build()).build());
345 // Post interface on the device
346 openRoadmInterfaces.postInterface(nodeId, otsiGroupInterfaceBldr);
348 // Post the equipment-state change on the device circuit-pack if xpdr node
349 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
350 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
353 return otsiGroupInterfaceBldr.getName();
356 public String createOpenRoadmOchOtsiOtsigroupInterface(String nodeId, String logicalConnPoint,
357 SpectrumInformation spectrumInformation)
358 throws OpenRoadmInterfaceException {
359 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
360 if (portMap == null) {
361 throw new OpenRoadmInterfaceException(
362 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
364 String interfaceOchOtsiOtsigroup = null;
365 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
366 // create OCH interface
367 interfaceOchOtsiOtsigroup = createOpenRoadmOchInterface(nodeId, logicalConnPoint, spectrumInformation);
368 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
369 // Create OTSi and OTSi-group
370 String interfaceOtsiName = createOpenRoadmOtsiInterface(nodeId, logicalConnPoint, spectrumInformation);
371 interfaceOchOtsiOtsigroup = createOpenRoadmOtsiGroupInterface(nodeId, logicalConnPoint, interfaceOtsiName,
372 spectrumInformation);
375 return interfaceOchOtsiOtsigroup;
378 public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface,
379 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
381 Mapping mapping = this.portMapping.getMapping(nodeId, logicalConnPoint);
382 if (mapping == null) {
383 throw new OpenRoadmInterfaceException(
384 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
387 otuInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOtu.class,
388 logicalConnPoint + "-OTU4");
389 // Supporting interface list
390 List<String> listSupportingOChInterface = new ArrayList<>();
391 listSupportingOChInterface.add(supportOchInterface);
392 otuInterfaceBldr.setSupportingInterfaceList(listSupportingOChInterface);
394 // OTU interface specific data
395 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder
396 otuIfBuilder = new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu
397 .interfaces.rev200529.otu.container.OtuBuilder()
399 .setRate(OTU4.class);
400 if (apiInfoA != null) {
401 otuIfBuilder.setTxSapi(apiInfoA.getSapi())
402 .setTxDapi(apiInfoA.getDapi())
403 .setExpectedSapi(apiInfoA.getExpectedSapi())
404 .setExpectedDapi(apiInfoA.getExpectedDapi());
406 if (apiInfoZ != null) {
407 otuIfBuilder.setTxSapi(apiInfoZ.getSapi())
408 .setTxDapi(apiInfoZ.getDapi())
409 .setExpectedSapi(apiInfoZ.getExpectedSapi())
410 .setExpectedDapi(apiInfoZ.getExpectedDapi());
413 // Create Interface1 type object required for adding as augmentation
414 // TODO look at imports of different versions of class
415 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
416 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
417 otuInterfaceBldr.addAugmentation(otuIf1Builder.setOtu(otuIfBuilder.build()).build());
419 // Post interface on the device
420 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBldr);
421 this.portMapping.updateMapping(nodeId, mapping);
422 return otuInterfaceBldr.getName();
426 public String createOpenRoadmOtucnInterface(String nodeId, String logicalConnPoint,
427 String supportingOtsiGroupInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
428 throws OpenRoadmInterfaceException {
429 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
430 if (mapping == null) {
431 throw new OpenRoadmInterfaceException(
432 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
433 nodeId, logicalConnPoint));
435 // Create an OTUCn object
436 MaintLoopbackBuilder maintLoopbackBuilder = new MaintLoopbackBuilder();
437 maintLoopbackBuilder.setEnabled(false);
438 OtuBuilder otuBuilder = new OtuBuilder()
439 .setRate(OTUCn.class)
440 .setTimActEnabled(false)
441 .setTimDetectMode(TimDetectMode.Disabled)
442 .setDegmIntervals(Uint8.valueOf(2))
443 .setDegthrPercentage(Uint16.valueOf(100))
444 .setMaintLoopback(maintLoopbackBuilder.build());
445 if (apiInfoA != null) {
446 otuBuilder.setTxSapi(apiInfoA.getSapi())
447 .setTxDapi(apiInfoA.getDapi())
448 .setExpectedSapi(apiInfoA.getExpectedSapi())
449 .setExpectedDapi(apiInfoA.getExpectedDapi());
451 if (apiInfoZ != null) {
452 otuBuilder.setTxSapi(apiInfoZ.getSapi())
453 .setTxDapi(apiInfoZ.getDapi())
454 .setExpectedSapi(apiInfoZ.getExpectedSapi())
455 .setExpectedDapi(apiInfoZ.getExpectedDapi());
457 // Set the OTUCn rate for various rates
458 String rate = supportingOtsiGroupInterface.substring(supportingOtsiGroupInterface.lastIndexOf('-') + 1);
460 String otucnrate = null;
461 boolean rateNotFound = false;
464 otuBuilder.setOtucnNRate(Uint16.valueOf(2));
468 otuBuilder.setOtucnNRate(Uint16.valueOf(3));
472 otuBuilder.setOtucnNRate(Uint16.valueOf(4));
476 LOG.error("Rate {} is not supported", rate);
481 throw new OpenRoadmInterfaceException(
482 String.format(RATE_EXCEPTION_MESSAGE));
485 InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOtu.class,
486 logicalConnPoint + "-OTUC" + otucnrate);
489 List<String> listSupportingOtsiGroupInterface = new ArrayList<>();
490 listSupportingOtsiGroupInterface.add(supportingOtsiGroupInterface);
492 otuInterfaceBuilder.setSupportingInterfaceList(listSupportingOtsiGroupInterface);
493 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
494 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
496 otuInterfaceBuilder.addAugmentation(otuIf1Builder.setOtu(otuBuilder.build()).build());
498 // Post interface on the device
499 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBuilder);
500 // Post the equipment-state change on the device circuit-pack if xpdr node
501 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
502 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
504 this.portMapping.updateMapping(nodeId, mapping);
505 return otuInterfaceBuilder.getName();
508 public String createOpenRoadmOtu4OtucnInterface(String nodeId, String logicalConnPoint,
509 String supportingInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
510 throws OpenRoadmInterfaceException {
511 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
512 if (portMap == null) {
513 throw new OpenRoadmInterfaceException(
514 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
516 // Depending on OCH-OTU4-ODU4 interface or OTSi-OTSi-group, supporting interface should
518 String interfaceOtu4Otucn = null;
519 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
520 // create OTU4 interface
521 interfaceOtu4Otucn = createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportingInterface,
523 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
525 interfaceOtu4Otucn = createOpenRoadmOtucnInterface(nodeId, logicalConnPoint, supportingInterface,
529 return interfaceOtu4Otucn;
532 public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint,
533 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
535 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
536 if (mapping == null) {
537 throw new OpenRoadmInterfaceException(
538 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
540 InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOdu.class,
541 logicalConnPoint + "-ODU4");
542 List<String> listSupportingOtu4Interface = new ArrayList<>();
543 if (mapping.getSupportingOtu4() != null) {
544 listSupportingOtu4Interface.add(mapping.getSupportingOtu4());
545 oduInterfaceBldr.setSupportingInterfaceList(listSupportingOtu4Interface);
549 OpuBuilder opuBuilder = new OpuBuilder()
550 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
551 .setPayloadType(PayloadTypeDef.getDefaultInstance("07"));
553 // Create an ODU4 object
554 OduBuilder oduBuilder = new OduBuilder()
556 .setOduFunction(ODUTTP.class)
557 .setMonitoringMode(MonitoringMode.Terminated)
558 .setOpu(opuBuilder.build());
560 if (apiInfoA != null) {
561 oduBuilder.setTxSapi(apiInfoA.getSapi())
562 .setTxDapi(apiInfoA.getDapi())
563 .setExpectedSapi(apiInfoA.getExpectedSapi())
564 .setExpectedDapi(apiInfoA.getExpectedDapi());
566 if (apiInfoZ != null) {
567 oduBuilder.setTxSapi(apiInfoZ.getSapi())
568 .setTxDapi(apiInfoZ.getDapi())
569 .setExpectedSapi(apiInfoZ.getExpectedSapi())
570 .setExpectedDapi(apiInfoZ.getExpectedDapi());
572 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
573 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
575 oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
577 // Post interface on the device
578 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr);
579 // Since this is not a CTP, we can update the port-mapping
580 LOG.info("{}-{} updating mapping with interface {}", nodeId, logicalConnPoint, oduInterfaceBldr.getName());
581 this.portMapping.updateMapping(nodeId, mapping);
583 return oduInterfaceBldr.getName();
587 public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint)
588 throws OpenRoadmInterfaceException {
589 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
590 if (mapping == null) {
591 throw new OpenRoadmInterfaceException(
592 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
593 nodeId, logicalConnPoint));
595 // Create ODUcn object
596 // Start with OPU object
598 OpuBuilder opuBuilder = new OpuBuilder()
599 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
600 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
602 // Create an ODUCn object
603 OduBuilder oduBuilder = new OduBuilder()
604 .setRate(ODUCn.class)
605 .setOduFunction(ODUTTP.class)
606 .setMonitoringMode(MonitoringMode.Terminated)
607 .setTimActEnabled(false)
608 .setTimDetectMode(TimDetectMode.Disabled)
609 .setDegmIntervals(Uint8.valueOf(2))
610 .setDegthrPercentage(Uint16.valueOf(100))
611 .setOducnNRate(Uint16.valueOf(4))
612 .setOpu(opuBuilder.build());
615 String supportingOtucn;
616 List<String> listSupportingOtucnInterface = new ArrayList<>();
617 if (mapping.getSupportingOtucn() != null) {
618 listSupportingOtucnInterface.add(mapping.getSupportingOtucn());
619 supportingOtucn = mapping.getSupportingOtucn();
621 throw new OpenRoadmInterfaceException(
622 String.format("Missing supporting OTUCn interface on port-mapping"));
625 // Set the ODUCn rate from OTUCn interface naming convention
626 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
627 // check if the oducnrate is a valid value and if it is invalid, then throw error
628 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
629 throw new OpenRoadmInterfaceException(
630 String.format(RATE_EXCEPTION_MESSAGE));
633 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
635 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOdu.class,
636 logicalConnPoint + "-ODUC" + oducnrate);
638 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
639 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
640 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
642 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
644 // Post interface on the device
645 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
647 // Post the equipment-state change on the device circuit-pack if xpdr node
648 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
649 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
652 return oduInterfaceBuilder.getName();
655 // Overloaded methods should be together
656 // With SAPI and DAPI information
657 public String createOpenRoadmOducnInterface(String anodeId, String alogicalConnPoint,
658 String supportingOtucn, String znodeId, String zlogicalConnPoint)
659 throws OpenRoadmInterfaceException {
660 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
661 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
662 if (portMapA == null) {
663 throw new OpenRoadmInterfaceException(
664 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
665 anodeId, alogicalConnPoint));
668 if (portMapZ == null) {
669 throw new OpenRoadmInterfaceException(
670 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
671 znodeId, zlogicalConnPoint));
674 // Create ODUcn object
675 // Start with OPU object
677 OpuBuilder opuBuilder = new OpuBuilder()
678 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
679 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
681 // Create an ODUC4 object
682 OduBuilder oduBuilder = new OduBuilder()
683 .setRate(ODUCn.class)
684 .setOduFunction(ODUTTP.class)
685 .setMonitoringMode(MonitoringMode.Terminated)
686 .setTimActEnabled(false)
687 .setTimDetectMode(TimDetectMode.Disabled)
688 .setDegmIntervals(Uint8.valueOf(2))
689 .setDegthrPercentage(Uint16.valueOf(100))
690 .setOpu(opuBuilder.build())
691 .setTxSapi(portMapA.getLcpHashVal())
692 .setTxDapi(portMapZ.getLcpHashVal())
693 .setExpectedSapi(portMapZ.getLcpHashVal())
694 .setExpectedDapi(portMapZ.getLcpHashVal());
696 // Set the ODUCn rate from OTUCn interface naming convention
697 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
699 // check if the oducnrate is a valid value and if it is invalid, then throw error
700 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
701 throw new OpenRoadmInterfaceException(
702 String.format(RATE_EXCEPTION_MESSAGE));
705 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
707 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
708 alogicalConnPoint + ODUC + oducnrate);
711 List<String> listSupportingOtucnInterface = new ArrayList<>();
712 listSupportingOtucnInterface.add(supportingOtucn);
714 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
715 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
716 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
718 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
720 // Post interface on the device
721 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
723 // Post the equipment-state change on the device circuit-pack if xpdr node
724 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
725 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
728 return oduInterfaceBuilder.getName();
732 // This is only for transponder
733 public String createOpenRoadmOduflexInterface(String nodeId, String logicalConnPoint,
734 String supportingOducn)
735 throws OpenRoadmInterfaceException {
736 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
737 if (portMap == null) {
738 throw new OpenRoadmInterfaceException(
739 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
740 nodeId, logicalConnPoint));
743 OpuBuilder opuBuilder = new OpuBuilder()
744 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
745 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
747 // Parent Odu-allocation
748 // Set the trib-slot array
749 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
750 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
751 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
753 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
754 .setTribPortNumber(Uint16.valueOf(1))
755 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
757 // Create an ODUFlex object
758 OduBuilder oduBuilder = new OduBuilder()
759 .setRate(ODUflexCbr.class)
760 .setOduflexCbrService(ODUflexCbr400G.class)
761 .setOduFunction(ODUTTPCTP.class)
762 .setMonitoringMode(MonitoringMode.Terminated)
763 .setTimActEnabled(false)
764 .setTimDetectMode(TimDetectMode.Disabled)
765 .setDegmIntervals(Uint8.valueOf(2))
766 .setDegthrPercentage(Uint16.valueOf(100))
767 .setOpu(opuBuilder.build())
768 .setParentOduAllocation(parentOduAllocationBuilder.build());
770 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
771 logicalConnPoint + "-ODUFLEX");
773 List<String> listSupportingOtucnInterface = new ArrayList<>();
774 listSupportingOtucnInterface.add(supportingOducn);
776 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
779 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
781 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
783 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
785 // Post interface on the device
786 openRoadmInterfaces.postInterface(nodeId, oduflexInterfaceBuilder);
788 // Post the equipment-state change on the device circuit-pack if xpdr node
789 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
790 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
793 return oduflexInterfaceBuilder.getName();
796 // Overloaded methods should be together
797 // This is only for transponder; with SAPI/DAPI information
798 public String createOpenRoadmOduflexInterface(String anodeId, String alogicalConnPoint,
799 String supportingOducn, String znodeId, String zlogicalConnPoint)
800 throws OpenRoadmInterfaceException {
801 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
802 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
803 if (portMapA == null) {
804 throw new OpenRoadmInterfaceException(
805 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
806 anodeId, alogicalConnPoint));
809 if (portMapZ == null) {
810 throw new OpenRoadmInterfaceException(
811 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
812 znodeId, zlogicalConnPoint));
816 OpuBuilder opuBuilder = new OpuBuilder()
817 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
818 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
820 // Parent Odu-allocation
821 // Set the trib-slot array
822 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
823 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
824 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
826 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
827 .setTribPortNumber(Uint16.valueOf(1))
828 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
830 // Create an ODUFlex object
831 OduBuilder oduBuilder = new OduBuilder()
832 .setRate(ODUflexCbr.class)
833 .setOduflexCbrService(ODUflexCbr400G.class)
834 .setOduFunction(ODUTTPCTP.class)
835 .setMonitoringMode(MonitoringMode.Terminated)
836 .setTimActEnabled(false)
837 .setTimDetectMode(TimDetectMode.Disabled)
838 .setDegmIntervals(Uint8.valueOf(2))
839 .setDegthrPercentage(Uint16.valueOf(100))
840 .setTxSapi(portMapA.getLcpHashVal())
841 .setTxDapi(portMapZ.getLcpHashVal())
842 .setExpectedSapi(portMapZ.getLcpHashVal())
843 .setExpectedDapi(portMapA.getLcpHashVal())
844 .setOpu(opuBuilder.build())
845 .setParentOduAllocation(parentOduAllocationBuilder.build());
847 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
848 alogicalConnPoint + "-ODUFLEX");
850 List<String> listSupportingOtucnInterface = new ArrayList<>();
851 listSupportingOtucnInterface.add(supportingOducn);
853 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
856 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
858 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
860 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
862 // Post interface on the device
863 openRoadmInterfaces.postInterface(anodeId, oduflexInterfaceBuilder);
865 // Post the equipment-state change on the device circuit-pack if xpdr node
866 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
867 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
870 return oduflexInterfaceBuilder.getName();
873 public String createOpenRoadmOdu4OducnOduflex(String nodeId, String logicalConnPoint,
874 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
876 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
877 if (portMap == null) {
878 throw new OpenRoadmInterfaceException(
879 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
881 // Depending on OTU4 or OTUCn, supporting interface should
883 String interfaceOdu4Oducn = null;
884 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
885 // create OTU4 interface
886 interfaceOdu4Oducn = createOpenRoadmOdu4Interface(nodeId, logicalConnPoint, apiInfoA, apiInfoZ);
887 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
888 // Create ODUCn and ODUFlex interface.
889 String interfaceOducn = createOpenRoadmOducnInterface(nodeId, logicalConnPoint);
890 interfaceOdu4Oducn = createOpenRoadmOduflexInterface(nodeId, logicalConnPoint, interfaceOducn);
893 return interfaceOdu4Oducn;
896 public String createOpenRoadmOtnOducnInterface(String nodeId, String logicalConnPoint,
897 String supportingOtucn)
898 throws OpenRoadmInterfaceException {
899 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
900 if (portMap == null) {
901 throw new OpenRoadmInterfaceException(
902 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
903 nodeId, logicalConnPoint));
905 // Create ODUcn object
906 // Start with OPU object
908 OpuBuilder opuBuilder = new OpuBuilder()
909 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
910 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
912 // Create an ODUC4 object
913 OduBuilder oduBuilder = new OduBuilder()
914 .setRate(ODUCn.class)
915 .setOduFunction(ODUTTP.class)
916 .setMonitoringMode(MonitoringMode.Terminated)
917 .setTimActEnabled(false)
918 .setTimDetectMode(TimDetectMode.Disabled)
919 .setDegmIntervals(Uint8.valueOf(2))
920 .setDegthrPercentage(Uint16.valueOf(100))
921 .setOpu(opuBuilder.build());
923 // Set the ODUCn rate from OTUCn interface naming convention
924 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
926 // check if the oducnrate is a valid value and if it is invalid, then throw error
927 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
928 throw new OpenRoadmInterfaceException(
929 String.format(RATE_EXCEPTION_MESSAGE));
932 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
934 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
935 logicalConnPoint + ODUC + oducnrate);
938 List<String> listSupportingOtucnInterface = new ArrayList<>();
939 listSupportingOtucnInterface.add(supportingOtucn);
941 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
942 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
943 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
945 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
947 // Post interface on the device
948 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
949 // Post the equipment-state change on the device circuit-pack if xpdr node
950 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
951 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
953 // Update the port-mapping with the interface information
954 this.portMapping.updateMapping(nodeId, portMap);
955 return oduInterfaceBuilder.getName();
959 // With SAPI and DAPI information
960 public String createOpenRoadmOtnOducnInterface(String anodeId, String alogicalConnPoint,
961 String supportingOtucn, String znodeId, String zlogicalConnPoint)
962 throws OpenRoadmInterfaceException {
963 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
964 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
965 if (portMapA == null) {
966 throw new OpenRoadmInterfaceException(
967 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
968 anodeId, alogicalConnPoint));
971 if (portMapZ == null) {
972 throw new OpenRoadmInterfaceException(
973 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
974 znodeId, zlogicalConnPoint));
977 // Create ODUcn object
978 // Start with OPU object
980 OpuBuilder opuBuilder = new OpuBuilder()
981 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
982 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
984 // Create an ODUCn object
985 OduBuilder oduBuilder = new OduBuilder()
986 .setRate(ODUCn.class)
987 .setOduFunction(ODUTTP.class)
988 .setMonitoringMode(MonitoringMode.Terminated)
989 .setTimActEnabled(false)
990 .setTimDetectMode(TimDetectMode.Disabled)
991 .setDegmIntervals(Uint8.valueOf(2))
992 .setDegthrPercentage(Uint16.valueOf(100))
993 .setOpu(opuBuilder.build())
994 .setTxSapi(portMapA.getLcpHashVal())
995 .setTxDapi(portMapZ.getLcpHashVal())
996 .setExpectedSapi(portMapZ.getLcpHashVal())
997 .setExpectedDapi(portMapZ.getLcpHashVal());
999 // Set the ODUCn rate from OTUCn interface naming convention
1000 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
1002 // check if the oducnrate is a valid value and if it is invalid, then throw error
1003 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
1004 throw new OpenRoadmInterfaceException(
1005 String.format(RATE_EXCEPTION_MESSAGE));
1008 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
1010 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
1011 alogicalConnPoint + ODUC + oducnrate);
1014 List<String> listSupportingOtucnInterface = new ArrayList<>();
1015 listSupportingOtucnInterface.add(supportingOtucn);
1017 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
1018 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
1019 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
1021 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
1023 // Post interface on the device
1024 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
1025 // Post the equipment-state change on the device circuit-pack if xpdr node
1026 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
1027 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
1029 // Update the port-mapping with the interface information
1030 this.portMapping.updateMapping(anodeId, portMapA);
1031 return oduInterfaceBuilder.getName();
1034 // This creates the name of the interface with slot numbers at the end
1035 public String createOpenRoadmOtsiInterfaceName(String logicalConnectionPoint, String spectralSlotName) {
1036 return String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, logicalConnectionPoint, spectralSlotName);
1039 private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, Class<? extends InterfaceType> type,
1041 return new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder()
1042 .setDescription(" TBD ")
1043 .setCircuitId(" TBD ")
1044 .setSupportingCircuitPackName(portMap.getSupportingCircuitPackName())
1045 .setSupportingPort(portMap.getSupportingPort())
1046 .setAdministrativeState(AdminStates.InService)
1049 .withKey(new InterfaceKey(key));
1052 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
1053 value = "UPM_UNCALLED_PRIVATE_METHOD",
1054 justification = "call in call() method")
1055 private int getServiceRate(ModulationFormat modulationFormat, SpectrumInformation spectrumInformation) {
1057 switch (modulationFormat) {
1059 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
1062 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
1065 // DpQam16 is possible for both 31.6 or 63.1 GBaud, for which spectral width is different
1066 // Here take the difference of highest and lowest spectral numbers and determine the width
1067 LOG.info("The width with guard band {}", (spectrumInformation.getHigherSpectralSlotNumber()
1068 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY);
1069 if ((spectrumInformation.getHigherSpectralSlotNumber()
1070 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY == 50.0) {
1071 // Based on roll-of-factor of 0.5, 50 - 12.5 = 37.5GHz translates to 31.6 GBaud
1072 LOG.info("The baud-rate is 31.6 GBaud");
1073 LOG.info("Given modulation format {} with 31.6 Gbaud rate is 200G", modulationFormat);
1076 // Based on roll-of-factor of 0.5, 87.5 - 12.5 = 75GHz translates to 63.1 GBaud
1077 LOG.info("The baud-rate is 63.1 GBaud");
1081 LOG.error("Modulation format is required to select the rate");