2 * Copyright © 2021 AT&T and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.renderer.openroadminterface;
11 import java.math.BigDecimal;
12 import java.util.ArrayList;
13 import java.util.Arrays;
14 import java.util.List;
15 import java.util.Optional;
16 import java.util.stream.IntStream;
17 import org.opendaylight.transportpce.common.StringConstants;
18 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
19 import org.opendaylight.transportpce.common.fixedflex.SpectrumInformation;
20 import org.opendaylight.transportpce.common.mapping.PortMapping;
21 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaceException;
22 import org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces;
23 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.AEndApiInfo;
24 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.az.api.info.ZEndApiInfo;
25 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316.mapping.Mapping;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.TrailTraceOther.TimDetectMode;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.parent.odu.allocation.ParentOduAllocationBuilder;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.attributes.rev200327.parent.odu.allocation.parent.odu.allocation.trib.slots.choice.OpucnBuilder;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.link.types.rev191129.PowerDBm;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic24;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic28;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic36;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic48;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyTHz;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.ModulationFormat;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.ProvisionModeType;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R100G;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R200GOtsi;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R300GOtsi;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R400GOtsi;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Ofec;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Rsfec;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Scfec;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.Interface1Builder;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.ethernet.container.EthernetBuilder;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.EthernetCsmacd;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.InterfaceType;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OpticalChannel;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnOdu;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnOtu;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.Otsi;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtsiGroup;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529.och.container.OchBuilder;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.attributes.FlexoBuilder;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.container.OtsiBuilder;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODU4;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUCn;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTP;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTPCTP;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr400G;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTU4;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTUCn;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef;
68 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.PayloadTypeDef;
69 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.OduAttributes.MonitoringMode;
70 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.odu.container.OduBuilder;
71 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.opu.OpuBuilder;
72 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder;
73 import org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.otsi.group.container.OtsiGroupBuilder;
74 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.If100GE;
75 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOCHOTU4ODU4;
76 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOtsiOtsigroup;
77 import org.opendaylight.yangtools.yang.common.Uint16;
78 import org.opendaylight.yangtools.yang.common.Uint32;
79 import org.opendaylight.yangtools.yang.common.Uint8;
80 import org.slf4j.Logger;
81 import org.slf4j.LoggerFactory;
83 public class OpenRoadmInterface710 {
84 private static final String MAPPING_ERROR_EXCEPTION_MESSAGE =
85 "Unable to get mapping from PortMapping for node % and logical connection port %s";
86 private static final String MODULATION_FMT_EXCEPTION_MESSAGE =
87 "Unable to get the modulation format";
88 private static final String RATE_EXCEPTION_MESSAGE =
89 "Unable to get the rate";
90 private static final String ODUC = "-ODUC";
91 private static final List<String> SUPPORTED_ODUCN_RATES = List.of("2", "3", "4");
92 private final PortMapping portMapping;
93 private final OpenRoadmInterfaces openRoadmInterfaces;
94 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface710.class);
96 public OpenRoadmInterface710(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
97 this.portMapping = portMapping;
98 this.openRoadmInterfaces = openRoadmInterfaces;
101 public String createOpenRoadmEthInterface(String nodeId, String logicalConnPoint)
102 throws OpenRoadmInterfaceException {
103 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
104 if (portMap == null) {
105 throw new OpenRoadmInterfaceException(
106 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
108 // Ethernet interface specific data
109 EthernetBuilder ethIfBuilder = new EthernetBuilder()
111 // Default set to 400G
112 .setSpeed(Uint32.valueOf(400000));
113 // We have to differentiate if-100GE vs if-400GE
114 if (portMap.getSupportedInterfaceCapability().contains(If100GE.class)) {
115 ethIfBuilder.setSpeed(Uint32.valueOf(100000));
118 InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class,
119 logicalConnPoint + "-ETHERNET");
121 // Create Interface1 type object required for adding as augmentation
122 Interface1Builder ethIf1Builder = new Interface1Builder();
123 ethInterfaceBldr.addAugmentation(ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
125 // Post interface on the device
126 openRoadmInterfaces.postInterface(nodeId, ethInterfaceBldr);
128 // Post the equipment-state change on the device circuit-pack
129 openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
131 return ethInterfaceBldr.getName();
134 public String createOpenRoadmOchInterface(String nodeId, String logicalConnPoint,
135 SpectrumInformation spectrumInformation)
136 throws OpenRoadmInterfaceException {
138 ModulationFormat modulationFormat = ModulationFormat.DpQpsk;
139 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
140 .forName(spectrumInformation.getModulationFormat());
141 if (optionalModulationFormat.isPresent()) {
142 modulationFormat = optionalModulationFormat.get();
144 // OCH interface specific data
145 OchBuilder ocIfBuilder = new OchBuilder()
146 .setFrequency(new FrequencyTHz(spectrumInformation.getCenterFrequency()))
147 .setRate(R100G.class)
148 .setTransmitPower(new PowerDBm(new BigDecimal("-5")))
149 .setModulationFormat(modulationFormat);
150 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
151 if (portMap == null) {
152 throw new OpenRoadmInterfaceException(
153 String.format("Unable to get mapping from PortMapping for node %s and logical connection port %s",
154 nodeId, logicalConnPoint));
156 // Create generic interface
158 ochInterfaceBldr = createGenericInterfaceBuilder(portMap, OpticalChannel.class,
159 spectrumInformation.getIdentifierFromParams(logicalConnPoint));
160 // Create Interface1 type object required for adding as augmentation
161 // TODO look at imports of different versions of class
162 org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529.Interface1Builder
163 ochIf1Builder = new org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.interfaces.rev200529
164 .Interface1Builder();
165 ochInterfaceBldr.addAugmentation(ochIf1Builder.setOch(ocIfBuilder.build()).build());
167 // Post interface on the device
168 openRoadmInterfaces.postInterface(nodeId, ochInterfaceBldr);
170 // Post the equipment-state change on the device circuit-pack if xpdr node
171 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
172 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
175 return ochInterfaceBldr.getName();
178 public String createOpenRoadmOtsiInterface(String nodeId, String logicalConnPoint,
179 SpectrumInformation spectrumInformation)
180 throws OpenRoadmInterfaceException {
182 ModulationFormat modulationFormat;
183 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
184 .forName(spectrumInformation.getModulationFormat());
185 if (optionalModulationFormat.isPresent()) {
186 modulationFormat = optionalModulationFormat.get();
188 throw new OpenRoadmInterfaceException(
189 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
192 // OTSI interface specific data
193 OtsiBuilder otsiBuilder = new OtsiBuilder()
194 .setFrequency(new FrequencyTHz(spectrumInformation.getCenterFrequency()))
195 .setTransmitPower(new PowerDBm(new BigDecimal("-5")))
196 .setProvisionMode(ProvisionModeType.Explicit)
198 .setModulationFormat(modulationFormat);
200 // Set the Flexo values
201 FlexoBuilder flexoBuilder = new FlexoBuilder();
202 boolean rateNotFound = false;
203 // Use the rate to switch rather than modulation format
204 int serviceRate = getServiceRate(modulationFormat, spectrumInformation);
205 switch (serviceRate) {
207 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
208 if (modulationFormat == ModulationFormat.DpQam16) {
209 LOG.info("FOIC is 2.8 for 31.6 Gbaud and rate is 200");
210 // FOIC rate is different
211 flexoBuilder.setFoicType(Foic28.class)
212 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
213 Uint8.valueOf(3), Uint8.valueOf(4))));
215 // default is dp-qpsk for 200G under 63.1 GBaud
216 flexoBuilder.setFoicType(Foic24.class)
217 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2))));
219 otsiBuilder.setOtsiRate(R200GOtsi.class)
220 .setFlexo(flexoBuilder.build());
223 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
224 flexoBuilder.setFoicType(Foic36.class)
225 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
227 otsiBuilder.setOtsiRate(R300GOtsi.class)
228 .setFlexo(flexoBuilder.build());
231 // Default baud-rate is 63.1 Gbaud
232 LOG.info("Given modulation format is {} and thus rate is 400G", modulationFormat);
233 flexoBuilder.setFoicType(Foic48.class)
234 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
235 Uint8.valueOf(3), Uint8.valueOf(4))));
236 otsiBuilder.setModulationFormat(modulationFormat)
237 .setOtsiRate(R400GOtsi.class)
238 .setFlexo(flexoBuilder.build());
241 LOG.error("Rate {} is unsupported", serviceRate);
247 throw new OpenRoadmInterfaceException(
248 String.format(RATE_EXCEPTION_MESSAGE));
251 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
252 if (portMap == null) {
253 throw new OpenRoadmInterfaceException(
254 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
256 // Create generic interface
257 InterfaceBuilder otsiInterfaceBldr = createGenericInterfaceBuilder(portMap, Otsi.class,
258 spectrumInformation.getIdentifierFromParams(logicalConnPoint));
259 // Create Interface1 type object required for adding as augmentation
260 org.opendaylight.yang.gen.v1.http
261 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder otsiIf1Builder =
262 new org.opendaylight.yang.gen.v1.http
263 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder();
265 otsiInterfaceBldr.addAugmentation(otsiIf1Builder.setOtsi(otsiBuilder.build()).build());
267 // Post interface on the device
268 openRoadmInterfaces.postInterface(nodeId, otsiInterfaceBldr);
270 // Post the equipment-state change on the device circuit-pack if xpdr node
271 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
272 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
275 return otsiInterfaceBldr.getName();
278 // This is a transponder use-case where the supporting port is just one, but YANG model
279 // requires supporting port to be list
280 public String createOpenRoadmOtsiGroupInterface(String nodeId, String logicalConnPoint,
281 String supportingOtsiInterface, SpectrumInformation spectrumInformation)
282 throws OpenRoadmInterfaceException {
283 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
284 if (portMap == null) {
285 throw new OpenRoadmInterfaceException(
286 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
287 nodeId, logicalConnPoint));
289 // Check the modulation format
290 ModulationFormat modulationFormat;
291 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
292 .forName(spectrumInformation.getModulationFormat());
293 if (optionalModulationFormat.isPresent()) {
294 modulationFormat = optionalModulationFormat.get();
296 throw new OpenRoadmInterfaceException(
297 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
299 int serviceRate = getServiceRate(modulationFormat, spectrumInformation);
300 // Create an OTSI group object
301 OtsiGroupBuilder otsiGroupBuilder = new OtsiGroupBuilder()
302 .setGroupId(Uint32.valueOf(1));
303 boolean rateNotFound = false;
304 switch (serviceRate) {
306 otsiGroupBuilder.setGroupRate(R200GOtsi.class);
309 otsiGroupBuilder.setGroupRate(R300GOtsi.class);
312 otsiGroupBuilder.setGroupRate(R400GOtsi.class);
315 LOG.error("Rate {} is not supported", serviceRate);
320 throw new OpenRoadmInterfaceException(
321 String.format(RATE_EXCEPTION_MESSAGE));
324 // Create generic interface
325 InterfaceBuilder otsiGroupInterfaceBldr = createGenericInterfaceBuilder(portMap, OtsiGroup.class,
326 logicalConnPoint + String.join("-", "", "OTSIGROUP", serviceRate + "G"));
329 List<String> listSupportingOtsiInterface = new ArrayList<>();
330 listSupportingOtsiInterface.add(supportingOtsiInterface);
331 otsiGroupInterfaceBldr.setSupportingInterfaceList(listSupportingOtsiInterface);
333 org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder
334 otsiGroupIf1Builder =
335 new org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder();
336 otsiGroupInterfaceBldr.addAugmentation(otsiGroupIf1Builder.setOtsiGroup(otsiGroupBuilder.build()).build());
338 // Post interface on the device
339 openRoadmInterfaces.postInterface(nodeId, otsiGroupInterfaceBldr);
341 // Post the equipment-state change on the device circuit-pack if xpdr node
342 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
343 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
346 return otsiGroupInterfaceBldr.getName();
349 public String createOpenRoadmOchOtsiOtsigroupInterface(String nodeId, String logicalConnPoint,
350 SpectrumInformation spectrumInformation)
351 throws OpenRoadmInterfaceException {
352 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
353 if (portMap == null) {
354 throw new OpenRoadmInterfaceException(
355 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
357 String interfaceOchOtsiOtsigroup = null;
358 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
359 // create OCH interface
360 interfaceOchOtsiOtsigroup = createOpenRoadmOchInterface(nodeId, logicalConnPoint, spectrumInformation);
361 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
362 // Create OTSi and OTSi-group and concat the names of the interface
363 String interfaceOtsiName = createOpenRoadmOtsiInterface(nodeId, logicalConnPoint, spectrumInformation);
364 // Concat the two names for this interface
365 interfaceOchOtsiOtsigroup = interfaceOtsiName
366 + "#" + createOpenRoadmOtsiGroupInterface(nodeId, logicalConnPoint, interfaceOtsiName,
367 spectrumInformation);
370 return interfaceOchOtsiOtsigroup;
373 public String createOpenRoadmOtu4Interface(String nodeId, String logicalConnPoint, String supportOchInterface,
374 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
376 Mapping mapping = this.portMapping.getMapping(nodeId, logicalConnPoint);
377 if (mapping == null) {
378 throw new OpenRoadmInterfaceException(
379 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
382 otuInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOtu.class,
383 logicalConnPoint + "-OTU4");
384 // Supporting interface list
385 List<String> listSupportingOChInterface = new ArrayList<>();
386 listSupportingOChInterface.add(supportOchInterface);
387 otuInterfaceBldr.setSupportingInterfaceList(listSupportingOChInterface);
389 // OTU interface specific data
390 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder
391 otuIfBuilder = new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu
392 .interfaces.rev200529.otu.container.OtuBuilder()
394 .setRate(OTU4.class);
395 if (apiInfoA != null) {
396 otuIfBuilder.setTxSapi(apiInfoA.getSapi())
397 .setTxDapi(apiInfoA.getDapi())
398 .setExpectedSapi(apiInfoA.getExpectedSapi())
399 .setExpectedDapi(apiInfoA.getExpectedDapi());
401 if (apiInfoZ != null) {
402 otuIfBuilder.setTxSapi(apiInfoZ.getSapi())
403 .setTxDapi(apiInfoZ.getDapi())
404 .setExpectedSapi(apiInfoZ.getExpectedSapi())
405 .setExpectedDapi(apiInfoZ.getExpectedDapi());
408 // Create Interface1 type object required for adding as augmentation
409 // TODO look at imports of different versions of class
410 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
411 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
412 otuInterfaceBldr.addAugmentation(otuIf1Builder.setOtu(otuIfBuilder.build()).build());
414 // Post interface on the device
415 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBldr);
416 this.portMapping.updateMapping(nodeId, mapping);
417 return otuInterfaceBldr.getName();
421 public String createOpenRoadmOtucnInterface(String nodeId, String logicalConnPoint,
422 String supportingOtsiGroupInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
423 throws OpenRoadmInterfaceException {
424 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
425 if (mapping == null) {
426 throw new OpenRoadmInterfaceException(
427 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
428 nodeId, logicalConnPoint));
430 // Create an OTUCn object
431 OtuBuilder otuBuilder = new OtuBuilder()
432 .setRate(OTUCn.class)
433 .setTimActEnabled(false)
434 .setTimDetectMode(TimDetectMode.Disabled)
435 .setDegmIntervals(Uint8.valueOf(2))
436 .setDegthrPercentage(Uint16.valueOf(100));
438 if (apiInfoA != null) {
439 otuBuilder.setTxSapi(apiInfoA.getSapi())
440 .setTxDapi(apiInfoA.getDapi())
441 .setExpectedSapi(apiInfoA.getExpectedSapi())
442 .setExpectedDapi(apiInfoA.getExpectedDapi());
444 if (apiInfoZ != null) {
445 otuBuilder.setTxSapi(apiInfoZ.getSapi())
446 .setTxDapi(apiInfoZ.getDapi())
447 .setExpectedSapi(apiInfoZ.getExpectedSapi())
448 .setExpectedDapi(apiInfoZ.getExpectedDapi());
450 // Set the OTUCn rate for various rates
451 String rate = supportingOtsiGroupInterface.substring(supportingOtsiGroupInterface.lastIndexOf('-') + 1);
453 String otucnrate = null;
454 boolean rateNotFound = false;
457 otuBuilder.setOtucnNRate(Uint16.valueOf(2));
461 otuBuilder.setOtucnNRate(Uint16.valueOf(3));
465 otuBuilder.setOtucnNRate(Uint16.valueOf(4));
469 LOG.error("Rate {} is not supported", rate);
474 throw new OpenRoadmInterfaceException(
475 String.format(RATE_EXCEPTION_MESSAGE));
478 InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOtu.class,
479 logicalConnPoint + "-OTUC" + otucnrate);
482 List<String> listSupportingOtsiGroupInterface = new ArrayList<>();
483 listSupportingOtsiGroupInterface.add(supportingOtsiGroupInterface);
485 otuInterfaceBuilder.setSupportingInterfaceList(listSupportingOtsiGroupInterface);
486 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
487 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
489 otuInterfaceBuilder.addAugmentation(otuIf1Builder.setOtu(otuBuilder.build()).build());
491 // Post interface on the device
492 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBuilder);
493 // Post the equipment-state change on the device circuit-pack if xpdr node
494 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
495 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
497 this.portMapping.updateMapping(nodeId, mapping);
498 return otuInterfaceBuilder.getName();
501 public String createOpenRoadmOtu4OtucnInterface(String nodeId, String logicalConnPoint,
502 String supportingInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
503 throws OpenRoadmInterfaceException {
504 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
505 if (portMap == null) {
506 throw new OpenRoadmInterfaceException(
507 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
509 // Depending on OCH-OTU4-ODU4 interface or OTSi-OTSi-group, supporting interface should
511 String interfaceOtu4Otucn = null;
512 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
513 // create OTU4 interface
514 interfaceOtu4Otucn = createOpenRoadmOtu4Interface(nodeId, logicalConnPoint, supportingInterface,
516 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
518 interfaceOtu4Otucn = createOpenRoadmOtucnInterface(nodeId, logicalConnPoint, supportingInterface,
522 return interfaceOtu4Otucn;
525 public String createOpenRoadmOdu4Interface(String nodeId, String logicalConnPoint,
526 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
528 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
529 if (mapping == null) {
530 throw new OpenRoadmInterfaceException(
531 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
533 InterfaceBuilder oduInterfaceBldr = createGenericInterfaceBuilder(mapping, OtnOdu.class,
534 logicalConnPoint + "-ODU4");
535 List<String> listSupportingOtu4Interface = new ArrayList<>();
536 if (mapping.getSupportingOtu4() != null) {
537 listSupportingOtu4Interface.add(mapping.getSupportingOtu4());
538 oduInterfaceBldr.setSupportingInterfaceList(listSupportingOtu4Interface);
542 OpuBuilder opuBuilder = new OpuBuilder()
543 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("07"))
544 .setPayloadType(PayloadTypeDef.getDefaultInstance("07"));
546 // Create an ODU4 object
547 OduBuilder oduBuilder = new OduBuilder()
549 .setOduFunction(ODUTTP.class)
550 .setMonitoringMode(MonitoringMode.Terminated)
551 .setOpu(opuBuilder.build());
553 if (apiInfoA != null) {
554 oduBuilder.setTxSapi(apiInfoA.getSapi())
555 .setTxDapi(apiInfoA.getDapi())
556 .setExpectedSapi(apiInfoA.getExpectedSapi())
557 .setExpectedDapi(apiInfoA.getExpectedDapi());
559 if (apiInfoZ != null) {
560 oduBuilder.setTxSapi(apiInfoZ.getSapi())
561 .setTxDapi(apiInfoZ.getDapi())
562 .setExpectedSapi(apiInfoZ.getExpectedSapi())
563 .setExpectedDapi(apiInfoZ.getExpectedDapi());
565 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
566 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
568 oduInterfaceBldr.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
570 // Post interface on the device
571 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBldr);
572 // Since this is not a CTP, we can update the port-mapping
573 LOG.info("{}-{} updating mapping with interface {}", nodeId, logicalConnPoint, oduInterfaceBldr.getName());
574 this.portMapping.updateMapping(nodeId, mapping);
576 return oduInterfaceBldr.getName();
580 public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint)
581 throws OpenRoadmInterfaceException {
582 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
583 if (mapping == null) {
584 throw new OpenRoadmInterfaceException(
585 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
586 nodeId, logicalConnPoint));
588 // Create ODUcn object
589 // Start with OPU object
591 OpuBuilder opuBuilder = new OpuBuilder()
592 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
593 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
595 // Create an ODUCn object
596 OduBuilder oduBuilder = new OduBuilder()
597 .setRate(ODUCn.class)
598 .setOduFunction(ODUTTP.class)
599 .setMonitoringMode(MonitoringMode.Terminated)
600 .setTimActEnabled(false)
601 .setTimDetectMode(TimDetectMode.Disabled)
602 .setDegmIntervals(Uint8.valueOf(2))
603 .setDegthrPercentage(Uint16.valueOf(100))
604 .setOducnNRate(Uint16.valueOf(4))
605 .setOpu(opuBuilder.build());
608 String supportingOtucn;
609 List<String> listSupportingOtucnInterface = new ArrayList<>();
610 if (mapping.getSupportingOtucn() != null) {
611 listSupportingOtucnInterface.add(mapping.getSupportingOtucn());
612 supportingOtucn = mapping.getSupportingOtucn();
614 throw new OpenRoadmInterfaceException(
615 String.format("Missing supporting OTUCn interface on port-mapping"));
618 // Set the ODUCn rate from OTUCn interface naming convention
619 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
620 // check if the oducnrate is a valid value and if it is invalid, then throw error
621 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
622 throw new OpenRoadmInterfaceException(
623 String.format(RATE_EXCEPTION_MESSAGE));
626 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
628 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOdu.class,
629 logicalConnPoint + "-ODUC" + oducnrate);
631 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
632 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
633 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
635 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
637 // Post interface on the device
638 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
640 // Post the equipment-state change on the device circuit-pack if xpdr node
641 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
642 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
645 return oduInterfaceBuilder.getName();
648 // Overloaded methods should be together
649 // With SAPI and DAPI information
650 public String createOpenRoadmOducnInterface(String anodeId, String alogicalConnPoint,
651 String supportingOtucn, String znodeId, String zlogicalConnPoint)
652 throws OpenRoadmInterfaceException {
653 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
654 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
655 if (portMapA == null) {
656 throw new OpenRoadmInterfaceException(
657 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
658 anodeId, alogicalConnPoint));
661 if (portMapZ == null) {
662 throw new OpenRoadmInterfaceException(
663 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
664 znodeId, zlogicalConnPoint));
667 // Create ODUcn object
668 // Start with OPU object
670 OpuBuilder opuBuilder = new OpuBuilder()
671 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
672 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
674 // Create an ODUC4 object
675 OduBuilder oduBuilder = new OduBuilder()
676 .setRate(ODUCn.class)
677 .setOduFunction(ODUTTP.class)
678 .setMonitoringMode(MonitoringMode.Terminated)
679 .setTimActEnabled(false)
680 .setTimDetectMode(TimDetectMode.Disabled)
681 .setDegmIntervals(Uint8.valueOf(2))
682 .setDegthrPercentage(Uint16.valueOf(100))
683 .setOpu(opuBuilder.build())
684 .setTxSapi(portMapA.getLcpHashVal())
685 .setTxDapi(portMapZ.getLcpHashVal())
686 .setExpectedSapi(portMapZ.getLcpHashVal())
687 .setExpectedDapi(portMapZ.getLcpHashVal());
689 // Set the ODUCn rate from OTUCn interface naming convention
690 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
692 // check if the oducnrate is a valid value and if it is invalid, then throw error
693 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
694 throw new OpenRoadmInterfaceException(
695 String.format(RATE_EXCEPTION_MESSAGE));
698 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
700 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
701 alogicalConnPoint + ODUC + oducnrate);
704 List<String> listSupportingOtucnInterface = new ArrayList<>();
705 listSupportingOtucnInterface.add(supportingOtucn);
707 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
708 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
709 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
711 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
713 // Post interface on the device
714 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
716 // Post the equipment-state change on the device circuit-pack if xpdr node
717 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
718 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
721 return oduInterfaceBuilder.getName();
725 // This is only for transponder
726 public String createOpenRoadmOduflexInterface(String nodeId, String logicalConnPoint,
727 String supportingOducn)
728 throws OpenRoadmInterfaceException {
729 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
730 if (portMap == null) {
731 throw new OpenRoadmInterfaceException(
732 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
733 nodeId, logicalConnPoint));
736 OpuBuilder opuBuilder = new OpuBuilder()
737 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
738 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
740 // Parent Odu-allocation
741 // Set the trib-slot array
742 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
743 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
744 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
746 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
747 .setTribPortNumber(Uint16.valueOf(1))
748 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
750 // Create an ODUFlex object
751 OduBuilder oduBuilder = new OduBuilder()
752 .setRate(ODUflexCbr.class)
753 .setOduflexCbrService(ODUflexCbr400G.class)
754 .setOduFunction(ODUTTPCTP.class)
755 .setMonitoringMode(MonitoringMode.Terminated)
756 .setTimActEnabled(false)
757 .setTimDetectMode(TimDetectMode.Disabled)
758 .setDegmIntervals(Uint8.valueOf(2))
759 .setDegthrPercentage(Uint16.valueOf(100))
760 .setOpu(opuBuilder.build())
761 .setParentOduAllocation(parentOduAllocationBuilder.build());
763 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
764 logicalConnPoint + "-ODUFLEX");
766 List<String> listSupportingOtucnInterface = new ArrayList<>();
767 listSupportingOtucnInterface.add(supportingOducn);
769 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
772 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
774 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
776 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
778 // Post interface on the device
779 openRoadmInterfaces.postInterface(nodeId, oduflexInterfaceBuilder);
781 // Post the equipment-state change on the device circuit-pack if xpdr node
782 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
783 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
786 return oduflexInterfaceBuilder.getName();
789 // Overloaded methods should be together
790 // This is only for transponder; with SAPI/DAPI information
791 public String createOpenRoadmOduflexInterface(String anodeId, String alogicalConnPoint,
792 String supportingOducn, String znodeId, String zlogicalConnPoint)
793 throws OpenRoadmInterfaceException {
794 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
795 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
796 if (portMapA == null) {
797 throw new OpenRoadmInterfaceException(
798 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
799 anodeId, alogicalConnPoint));
802 if (portMapZ == null) {
803 throw new OpenRoadmInterfaceException(
804 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
805 znodeId, zlogicalConnPoint));
809 OpuBuilder opuBuilder = new OpuBuilder()
810 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
811 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
813 // Parent Odu-allocation
814 // Set the trib-slot array
815 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
816 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
817 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
819 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
820 .setTribPortNumber(Uint16.valueOf(1))
821 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
823 // Create an ODUFlex object
824 OduBuilder oduBuilder = new OduBuilder()
825 .setRate(ODUflexCbr.class)
826 .setOduflexCbrService(ODUflexCbr400G.class)
827 .setOduFunction(ODUTTPCTP.class)
828 .setMonitoringMode(MonitoringMode.Terminated)
829 .setTimActEnabled(false)
830 .setTimDetectMode(TimDetectMode.Disabled)
831 .setDegmIntervals(Uint8.valueOf(2))
832 .setDegthrPercentage(Uint16.valueOf(100))
833 .setTxSapi(portMapA.getLcpHashVal())
834 .setTxDapi(portMapZ.getLcpHashVal())
835 .setExpectedSapi(portMapZ.getLcpHashVal())
836 .setExpectedDapi(portMapA.getLcpHashVal())
837 .setOpu(opuBuilder.build())
838 .setParentOduAllocation(parentOduAllocationBuilder.build());
840 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
841 alogicalConnPoint + "-ODUFLEX");
843 List<String> listSupportingOtucnInterface = new ArrayList<>();
844 listSupportingOtucnInterface.add(supportingOducn);
846 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
849 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
851 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
853 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
855 // Post interface on the device
856 openRoadmInterfaces.postInterface(anodeId, oduflexInterfaceBuilder);
858 // Post the equipment-state change on the device circuit-pack if xpdr node
859 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
860 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
863 return oduflexInterfaceBuilder.getName();
866 public String createOpenRoadmOdu4OducnOduflex(String nodeId, String logicalConnPoint,
867 AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ) throws OpenRoadmInterfaceException {
869 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
870 if (portMap == null) {
871 throw new OpenRoadmInterfaceException(
872 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
874 // Depending on OTU4 or OTUCn, supporting interface should
876 String interfaceOdu4OducnOduflex = null;
877 if (portMap.getSupportedInterfaceCapability().contains(IfOCHOTU4ODU4.class)) {
878 // create OTU4 interface
879 interfaceOdu4OducnOduflex = createOpenRoadmOdu4Interface(nodeId, logicalConnPoint, apiInfoA, apiInfoZ);
880 } else if (portMap.getSupportedInterfaceCapability().contains(IfOtsiOtsigroup.class)) {
881 // Create ODUCn and ODUFlex interface.
882 String interfaceOducn = createOpenRoadmOducnInterface(nodeId, logicalConnPoint);
883 // Here we concat the two interfaces
884 interfaceOdu4OducnOduflex = interfaceOducn + "#"
885 + createOpenRoadmOduflexInterface(nodeId, logicalConnPoint, interfaceOducn);
888 return interfaceOdu4OducnOduflex;
891 public String createOpenRoadmOtnOducnInterface(String nodeId, String logicalConnPoint,
892 String supportingOtucn)
893 throws OpenRoadmInterfaceException {
894 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
895 if (portMap == null) {
896 throw new OpenRoadmInterfaceException(
897 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
898 nodeId, logicalConnPoint));
900 // Create ODUcn object
901 // Start with OPU object
903 OpuBuilder opuBuilder = new OpuBuilder()
904 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
905 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
907 // Create an ODUC4 object
908 OduBuilder oduBuilder = new OduBuilder()
909 .setRate(ODUCn.class)
910 .setOduFunction(ODUTTP.class)
911 .setMonitoringMode(MonitoringMode.Terminated)
912 .setTimActEnabled(false)
913 .setTimDetectMode(TimDetectMode.Disabled)
914 .setDegmIntervals(Uint8.valueOf(2))
915 .setDegthrPercentage(Uint16.valueOf(100))
916 .setOpu(opuBuilder.build());
918 // Set the ODUCn rate from OTUCn interface naming convention
919 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
921 // check if the oducnrate is a valid value and if it is invalid, then throw error
922 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
923 throw new OpenRoadmInterfaceException(
924 String.format(RATE_EXCEPTION_MESSAGE));
927 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
929 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
930 logicalConnPoint + ODUC + oducnrate);
933 List<String> listSupportingOtucnInterface = new ArrayList<>();
934 listSupportingOtucnInterface.add(supportingOtucn);
936 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
937 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
938 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
940 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
942 // Post interface on the device
943 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
944 // Post the equipment-state change on the device circuit-pack if xpdr node
945 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
946 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
948 // Update the port-mapping with the interface information
949 this.portMapping.updateMapping(nodeId, portMap);
950 return oduInterfaceBuilder.getName();
954 // With SAPI and DAPI information
955 public String createOpenRoadmOtnOducnInterface(String anodeId, String alogicalConnPoint,
956 String supportingOtucn, String znodeId, String zlogicalConnPoint)
957 throws OpenRoadmInterfaceException {
958 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
959 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
960 if (portMapA == null) {
961 throw new OpenRoadmInterfaceException(
962 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
963 anodeId, alogicalConnPoint));
966 if (portMapZ == null) {
967 throw new OpenRoadmInterfaceException(
968 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
969 znodeId, zlogicalConnPoint));
972 // Create ODUcn object
973 // Start with OPU object
975 OpuBuilder opuBuilder = new OpuBuilder()
976 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
977 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
979 // Create an ODUCn object
980 OduBuilder oduBuilder = new OduBuilder()
981 .setRate(ODUCn.class)
982 .setOduFunction(ODUTTP.class)
983 .setMonitoringMode(MonitoringMode.Terminated)
984 .setTimActEnabled(false)
985 .setTimDetectMode(TimDetectMode.Disabled)
986 .setDegmIntervals(Uint8.valueOf(2))
987 .setDegthrPercentage(Uint16.valueOf(100))
988 .setOpu(opuBuilder.build())
989 .setTxSapi(portMapA.getLcpHashVal())
990 .setTxDapi(portMapZ.getLcpHashVal())
991 .setExpectedSapi(portMapZ.getLcpHashVal())
992 .setExpectedDapi(portMapZ.getLcpHashVal());
994 // Set the ODUCn rate from OTUCn interface naming convention
995 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
997 // check if the oducnrate is a valid value and if it is invalid, then throw error
998 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
999 throw new OpenRoadmInterfaceException(
1000 String.format(RATE_EXCEPTION_MESSAGE));
1003 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
1005 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
1006 alogicalConnPoint + ODUC + oducnrate);
1009 List<String> listSupportingOtucnInterface = new ArrayList<>();
1010 listSupportingOtucnInterface.add(supportingOtucn);
1012 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
1013 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
1014 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
1016 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
1018 // Post interface on the device
1019 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
1020 // Post the equipment-state change on the device circuit-pack if xpdr node
1021 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
1022 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
1024 // Update the port-mapping with the interface information
1025 this.portMapping.updateMapping(anodeId, portMapA);
1026 return oduInterfaceBuilder.getName();
1029 // This creates the name of the interface with slot numbers at the end
1030 public String createOpenRoadmOtsiInterfaceName(String logicalConnectionPoint, String spectralSlotName) {
1031 return String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, logicalConnectionPoint, spectralSlotName);
1034 private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, Class<? extends InterfaceType> type,
1036 return new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder()
1037 .setDescription(" TBD ")
1038 .setCircuitId(" TBD ")
1039 .setSupportingCircuitPackName(portMap.getSupportingCircuitPackName())
1040 .setSupportingPort(portMap.getSupportingPort())
1041 .setAdministrativeState(AdminStates.InService)
1044 .withKey(new InterfaceKey(key));
1047 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
1048 value = "UPM_UNCALLED_PRIVATE_METHOD",
1049 justification = "call in call() method")
1050 private int getServiceRate(ModulationFormat modulationFormat, SpectrumInformation spectrumInformation) {
1052 switch (modulationFormat) {
1054 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
1057 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
1060 // DpQam16 is possible for both 31.6 or 63.1 GBaud, for which spectral width is different
1061 // Here take the difference of highest and lowest spectral numbers and determine the width
1062 LOG.info("The width with guard band {}", (spectrumInformation.getHigherSpectralSlotNumber()
1063 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY);
1064 if ((spectrumInformation.getHigherSpectralSlotNumber()
1065 - spectrumInformation.getLowerSpectralSlotNumber() + 1) * GridConstant.GRANULARITY == 50.0) {
1066 // Based on roll-of-factor of 0.5, 50 - 12.5 = 37.5GHz translates to 31.6 GBaud
1067 LOG.info("The baud-rate is 31.6 GBaud");
1068 LOG.info("Given modulation format {} with 31.6 Gbaud rate is 200G", modulationFormat);
1071 // Based on roll-of-factor of 0.5, 87.5 - 12.5 = 75GHz translates to 63.1 GBaud
1072 LOG.info("The baud-rate is 63.1 GBaud");
1076 LOG.error("Modulation format is required to select the rate");