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.Foic36;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.Foic48;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.FrequencyTHz;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.ModulationFormat;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.ProvisionModeType;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R200GOtsi;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R300GOtsi;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.optical.channel.types.rev200529.R400GOtsi;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Ofec;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev200529.Rsfec;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceKey;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.Interface1Builder;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.ethernet.interfaces.rev200529.ethernet.container.EthernetBuilder;
46 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.EthernetCsmacd;
47 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.InterfaceType;
48 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnOdu;
49 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtnOtu;
50 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.Otsi;
51 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev191129.OtsiGroup;
52 import org.opendaylight.yang.gen.v1.http.org.openroadm.maintenance.loopback.rev191129.maint.loopback.MaintLoopbackBuilder;
53 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.attributes.FlexoBuilder;
54 import org.opendaylight.yang.gen.v1.http.org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.otsi.container.OtsiBuilder;
55 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUCn;
56 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTP;
57 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUTTPCTP;
58 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr;
59 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODUflexCbr400G;
60 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OTUCn;
61 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.OpucnTribSlotDef;
62 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.PayloadTypeDef;
63 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.OduAttributes.MonitoringMode;
64 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.odu.container.OduBuilder;
65 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.opu.OpuBuilder;
66 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.otu.container.OtuBuilder;
67 import org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.otsi.group.container.OtsiGroupBuilder;
68 import org.opendaylight.yangtools.yang.common.Uint16;
69 import org.opendaylight.yangtools.yang.common.Uint32;
70 import org.opendaylight.yangtools.yang.common.Uint8;
71 import org.slf4j.Logger;
72 import org.slf4j.LoggerFactory;
74 public class OpenRoadmInterface710 {
75 private static final String MAPPING_ERROR_EXCEPTION_MESSAGE =
76 "Unable to get mapping from PortMapping for node % and logical connection port %s";
77 private static final String MODULATION_FMT_EXCEPTION_MESSAGE =
78 "Unable to get the modulation format";
79 private static final String RATE_EXCEPTION_MESSAGE =
80 "Unable to get the rate";
81 private static final String ODUC = "-ODUC";
82 private static final List<String> SUPPORTED_ODUCN_RATES = new ArrayList<>() {
89 private final PortMapping portMapping;
90 private final OpenRoadmInterfaces openRoadmInterfaces;
91 private static final Logger LOG = LoggerFactory.getLogger(OpenRoadmInterface710.class);
93 public OpenRoadmInterface710(PortMapping portMapping, OpenRoadmInterfaces openRoadmInterfaces) {
94 this.portMapping = portMapping;
95 this.openRoadmInterfaces = openRoadmInterfaces;
98 public String createOpenRoadmEthInterface(String nodeId, String logicalConnPoint)
99 throws OpenRoadmInterfaceException {
100 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
101 if (portMap == null) {
102 throw new OpenRoadmInterfaceException(
103 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
106 // Ethernet interface specific data
107 EthernetBuilder ethIfBuilder = new EthernetBuilder()
109 .setSpeed(Uint32.valueOf(400000));
111 InterfaceBuilder ethInterfaceBldr = createGenericInterfaceBuilder(portMap, EthernetCsmacd.class,
112 logicalConnPoint + "-ETHERNET");
113 // Create Interface1 type object required for adding as augmentation
114 Interface1Builder ethIf1Builder = new Interface1Builder();
115 ethInterfaceBldr.addAugmentation(ethIf1Builder.setEthernet(ethIfBuilder.build()).build());
117 // Post interface on the device
118 openRoadmInterfaces.postInterface(nodeId, ethInterfaceBldr);
120 // Post the equipment-state change on the device circuit-pack
121 openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
123 return ethInterfaceBldr.getName();
127 public String createOpenRoadmOtsiInterface(String nodeId, String logicalConnPoint,
128 SpectrumInformation spectrumInformation)
129 throws OpenRoadmInterfaceException {
131 ModulationFormat modulationFormat;
132 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
133 .forName(spectrumInformation.getModulationFormat());
134 if (optionalModulationFormat.isPresent()) {
135 modulationFormat = optionalModulationFormat.get();
137 throw new OpenRoadmInterfaceException(
138 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
141 // OTSI interface specific data
142 OtsiBuilder otsiBuilder = new OtsiBuilder()
143 .setFrequency(new FrequencyTHz(spectrumInformation.getCenterFrequency()))
144 .setTransmitPower(new PowerDBm(new BigDecimal("-5")))
145 .setProvisionMode(ProvisionModeType.Explicit)
147 .setModulationFormat(modulationFormat);
149 // Set the Flexo values
150 FlexoBuilder flexoBuilder = new FlexoBuilder();
151 boolean rateNotFound = false;
152 // Use the rate to switch rather than modulation format
153 int serviceRate = getServiceRate(modulationFormat);
154 switch (serviceRate) {
156 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
157 flexoBuilder.setFoicType(Foic24.class)
158 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2))));
159 otsiBuilder.setOtsiRate(R200GOtsi.class)
160 .setFlexo(flexoBuilder.build());
163 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
164 flexoBuilder.setFoicType(Foic36.class)
165 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
167 otsiBuilder.setOtsiRate(R300GOtsi.class)
168 .setFlexo(flexoBuilder.build());
171 // Default baud-rate is 63.1 Gbaud
172 LOG.info("Given modulation format is {} and thus rate is 400G", modulationFormat);
173 flexoBuilder.setFoicType(Foic48.class)
174 .setIid(new ArrayList<>(Arrays.asList(Uint8.valueOf(1), Uint8.valueOf(2),
175 Uint8.valueOf(3), Uint8.valueOf(4))));
176 otsiBuilder.setModulationFormat(modulationFormat)
177 .setOtsiRate(R400GOtsi.class)
178 .setFlexo(flexoBuilder.build());
181 LOG.error("Rate {} is unsupported", serviceRate);
187 throw new OpenRoadmInterfaceException(
188 String.format(RATE_EXCEPTION_MESSAGE));
191 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
192 if (portMap == null) {
193 throw new OpenRoadmInterfaceException(
194 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE, nodeId, logicalConnPoint));
196 // Create generic interface
197 InterfaceBuilder otsiInterfaceBldr = createGenericInterfaceBuilder(portMap, Otsi.class,
198 spectrumInformation.getIdentifierFromParams(logicalConnPoint));
199 // Create Interface1 type object required for adding as augmentation
200 org.opendaylight.yang.gen.v1.http
201 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder otsiIf1Builder =
202 new org.opendaylight.yang.gen.v1.http
203 .org.openroadm.optical.channel.tributary.signal.interfaces.rev200529.Interface1Builder();
205 otsiInterfaceBldr.addAugmentation(otsiIf1Builder.setOtsi(otsiBuilder.build()).build());
207 // Post interface on the device
208 openRoadmInterfaces.postInterface(nodeId, otsiInterfaceBldr);
210 // Post the equipment-state change on the device circuit-pack if xpdr node
211 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
212 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
215 return otsiInterfaceBldr.getName();
218 // This is a transponder use-case where the supporting port is just one, but YANG model
219 // requires supporting port to be list
220 public String createOpenRoadmOtsiGroupInterface(String nodeId, String logicalConnPoint,
221 String supportingOtsiInterface, SpectrumInformation spectrumInformation)
222 throws OpenRoadmInterfaceException {
223 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
224 if (portMap == null) {
225 throw new OpenRoadmInterfaceException(
226 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
227 nodeId, logicalConnPoint));
229 // Check the modulation format
230 ModulationFormat modulationFormat;
231 Optional<ModulationFormat> optionalModulationFormat = ModulationFormat
232 .forName(spectrumInformation.getModulationFormat());
233 if (optionalModulationFormat.isPresent()) {
234 modulationFormat = optionalModulationFormat.get();
236 throw new OpenRoadmInterfaceException(
237 String.format(MODULATION_FMT_EXCEPTION_MESSAGE));
239 int serviceRate = getServiceRate(modulationFormat);
240 // Create an OTSI group object
241 OtsiGroupBuilder otsiGroupBuilder = new OtsiGroupBuilder()
242 .setGroupId(Uint32.valueOf(1));
243 boolean rateNotFound = false;
244 switch (serviceRate) {
246 otsiGroupBuilder.setGroupRate(R200GOtsi.class);
249 otsiGroupBuilder.setGroupRate(R300GOtsi.class);
252 otsiGroupBuilder.setGroupRate(R400GOtsi.class);
255 LOG.error("Rate {} is not supported", serviceRate);
260 throw new OpenRoadmInterfaceException(
261 String.format(RATE_EXCEPTION_MESSAGE));
264 // Create generic interface
265 InterfaceBuilder otsiGroupInterfaceBldr = createGenericInterfaceBuilder(portMap, OtsiGroup.class,
266 logicalConnPoint + String.join("-", "", "OTSIGROUP", serviceRate + "G"));
269 List<String> listSupportingOtsiInterface = new ArrayList<>();
270 listSupportingOtsiInterface.add(supportingOtsiInterface);
271 otsiGroupInterfaceBldr.setSupportingInterfaceList(listSupportingOtsiInterface);
273 org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder
274 otsiGroupIf1Builder =
275 new org.opendaylight.yang.gen.v1.http.org.openroadm.otsi.group.interfaces.rev200529.Interface1Builder();
276 otsiGroupInterfaceBldr.addAugmentation(otsiGroupIf1Builder.setOtsiGroup(otsiGroupBuilder.build()).build());
278 // Post interface on the device
279 openRoadmInterfaces.postInterface(nodeId, otsiGroupInterfaceBldr);
281 // Post the equipment-state change on the device circuit-pack if xpdr node
282 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
283 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
286 return otsiGroupInterfaceBldr.getName();
289 public String createOpenRoadmOtucnInterface(String nodeId, String logicalConnPoint,
290 String supportingOtsiGroupInterface, AEndApiInfo apiInfoA, ZEndApiInfo apiInfoZ)
291 throws OpenRoadmInterfaceException {
292 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
293 if (mapping == null) {
294 throw new OpenRoadmInterfaceException(
295 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
296 nodeId, logicalConnPoint));
298 // Create an OTUCn object
299 MaintLoopbackBuilder maintLoopbackBuilder = new MaintLoopbackBuilder();
300 maintLoopbackBuilder.setEnabled(false);
301 OtuBuilder otuBuilder = new OtuBuilder()
302 .setRate(OTUCn.class)
303 .setTimActEnabled(false)
304 .setTimDetectMode(TimDetectMode.Disabled)
305 .setDegmIntervals(Uint8.valueOf(2))
306 .setDegthrPercentage(Uint16.valueOf(100))
307 .setMaintLoopback(maintLoopbackBuilder.build());
308 if (apiInfoA != null) {
309 otuBuilder.setTxSapi(apiInfoA.getSapi())
310 .setTxDapi(apiInfoA.getDapi())
311 .setExpectedSapi(apiInfoA.getExpectedSapi())
312 .setExpectedDapi(apiInfoA.getExpectedDapi());
314 if (apiInfoZ != null) {
315 otuBuilder.setTxSapi(apiInfoZ.getSapi())
316 .setTxDapi(apiInfoZ.getDapi())
317 .setExpectedSapi(apiInfoZ.getExpectedSapi())
318 .setExpectedDapi(apiInfoZ.getExpectedDapi());
320 // Set the OTUCn rate for various rates
321 String rate = supportingOtsiGroupInterface.substring(supportingOtsiGroupInterface.lastIndexOf('-') + 1);
323 String otucnrate = null;
324 boolean rateNotFound = false;
327 otuBuilder.setOtucnNRate(Uint16.valueOf(2));
331 otuBuilder.setOtucnNRate(Uint16.valueOf(3));
335 otuBuilder.setOtucnNRate(Uint16.valueOf(4));
339 LOG.error("Rate {} is not supported", rate);
344 throw new OpenRoadmInterfaceException(
345 String.format(RATE_EXCEPTION_MESSAGE));
348 InterfaceBuilder otuInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOtu.class,
349 logicalConnPoint + "-OTUC" + otucnrate);
352 List<String> listSupportingOtsiGroupInterface = new ArrayList<>();
353 listSupportingOtsiGroupInterface.add(supportingOtsiGroupInterface);
355 otuInterfaceBuilder.setSupportingInterfaceList(listSupportingOtsiGroupInterface);
356 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder otuIf1Builder =
357 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.otu.interfaces.rev200529.Interface1Builder();
359 otuInterfaceBuilder.addAugmentation(otuIf1Builder.setOtu(otuBuilder.build()).build());
361 // Post interface on the device
362 openRoadmInterfaces.postInterface(nodeId, otuInterfaceBuilder);
363 // Post the equipment-state change on the device circuit-pack if xpdr node
364 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
365 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
367 this.portMapping.updateMapping(nodeId, mapping);
368 return otuInterfaceBuilder.getName();
371 public String createOpenRoadmOducnInterface(String nodeId, String logicalConnPoint)
372 throws OpenRoadmInterfaceException {
373 Mapping mapping = portMapping.getMapping(nodeId, logicalConnPoint);
374 if (mapping == null) {
375 throw new OpenRoadmInterfaceException(
376 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
377 nodeId, logicalConnPoint));
379 // Create ODUcn object
380 // Start with OPU object
382 OpuBuilder opuBuilder = new OpuBuilder()
383 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
384 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
386 // Create an ODUCn object
387 OduBuilder oduBuilder = new OduBuilder()
388 .setRate(ODUCn.class)
389 .setOduFunction(ODUTTP.class)
390 .setMonitoringMode(MonitoringMode.Terminated)
391 .setTimActEnabled(false)
392 .setTimDetectMode(TimDetectMode.Disabled)
393 .setDegmIntervals(Uint8.valueOf(2))
394 .setDegthrPercentage(Uint16.valueOf(100))
395 .setOducnNRate(Uint16.valueOf(4))
396 .setOpu(opuBuilder.build());
399 String supportingOtucn;
400 List<String> listSupportingOtucnInterface = new ArrayList<>();
401 if (mapping.getSupportingOtucn() != null) {
402 listSupportingOtucnInterface.add(mapping.getSupportingOtucn());
403 supportingOtucn = mapping.getSupportingOtucn();
405 throw new OpenRoadmInterfaceException(
406 String.format("Missing supporting OTUCn interface on port-mapping"));
409 // Set the ODUCn rate from OTUCn interface naming convention
410 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
411 // check if the oducnrate is a valid value and if it is invalid, then throw error
412 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
413 throw new OpenRoadmInterfaceException(
414 String.format(RATE_EXCEPTION_MESSAGE));
417 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
419 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(mapping, OtnOdu.class,
420 logicalConnPoint + "-ODUC" + oducnrate);
422 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
423 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
424 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
426 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
428 // Post interface on the device
429 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
431 // Post the equipment-state change on the device circuit-pack if xpdr node
432 if (mapping.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
433 this.openRoadmInterfaces.postEquipmentState(nodeId, mapping.getSupportingCircuitPackName(), true);
436 return oduInterfaceBuilder.getName();
439 // With SAPI and DAPI information
440 public String createOpenRoadmOducnInterface(String anodeId, String alogicalConnPoint,
441 String supportingOtucn, String znodeId, String zlogicalConnPoint)
442 throws OpenRoadmInterfaceException {
443 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
444 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
445 if (portMapA == null) {
446 throw new OpenRoadmInterfaceException(
447 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
448 anodeId, alogicalConnPoint));
451 if (portMapZ == null) {
452 throw new OpenRoadmInterfaceException(
453 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
454 znodeId, zlogicalConnPoint));
457 // Create ODUcn object
458 // Start with OPU object
460 OpuBuilder opuBuilder = new OpuBuilder()
461 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
462 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
464 // Create an ODUC4 object
465 OduBuilder oduBuilder = new OduBuilder()
466 .setRate(ODUCn.class)
467 .setOduFunction(ODUTTP.class)
468 .setMonitoringMode(MonitoringMode.Terminated)
469 .setTimActEnabled(false)
470 .setTimDetectMode(TimDetectMode.Disabled)
471 .setDegmIntervals(Uint8.valueOf(2))
472 .setDegthrPercentage(Uint16.valueOf(100))
473 .setOpu(opuBuilder.build())
474 .setTxSapi(portMapA.getLcpHashVal())
475 .setTxDapi(portMapZ.getLcpHashVal())
476 .setExpectedSapi(portMapZ.getLcpHashVal())
477 .setExpectedDapi(portMapZ.getLcpHashVal());
479 // Set the ODUCn rate from OTUCn interface naming convention
480 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
482 // check if the oducnrate is a valid value and if it is invalid, then throw error
483 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
484 throw new OpenRoadmInterfaceException(
485 String.format(RATE_EXCEPTION_MESSAGE));
488 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
490 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
491 alogicalConnPoint + ODUC + oducnrate);
494 List<String> listSupportingOtucnInterface = new ArrayList<>();
495 listSupportingOtucnInterface.add(supportingOtucn);
497 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
498 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
499 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
501 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
503 // Post interface on the device
504 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
506 // Post the equipment-state change on the device circuit-pack if xpdr node
507 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
508 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
511 return oduInterfaceBuilder.getName();
514 public String createOpenRoadmOtnOducnInterface(String nodeId, String logicalConnPoint,
515 String supportingOtucn)
516 throws OpenRoadmInterfaceException {
517 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
518 if (portMap == null) {
519 throw new OpenRoadmInterfaceException(
520 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
521 nodeId, logicalConnPoint));
523 // Create ODUcn object
524 // Start with OPU object
526 OpuBuilder opuBuilder = new OpuBuilder()
527 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("22"))
528 .setPayloadType(PayloadTypeDef.getDefaultInstance("22"));
530 // Create an ODUC4 object
531 OduBuilder oduBuilder = new OduBuilder()
532 .setRate(ODUCn.class)
533 .setOduFunction(ODUTTP.class)
534 .setMonitoringMode(MonitoringMode.Terminated)
535 .setTimActEnabled(false)
536 .setTimDetectMode(TimDetectMode.Disabled)
537 .setDegmIntervals(Uint8.valueOf(2))
538 .setDegthrPercentage(Uint16.valueOf(100))
539 .setOpu(opuBuilder.build());
541 // Set the ODUCn rate from OTUCn interface naming convention
542 String oducnrate = supportingOtucn.substring(supportingOtucn.length() - 1);
544 // check if the oducnrate is a valid value and if it is invalid, then throw error
545 if (!SUPPORTED_ODUCN_RATES.contains(oducnrate)) {
546 throw new OpenRoadmInterfaceException(
547 String.format(RATE_EXCEPTION_MESSAGE));
550 oduBuilder.setOducnNRate(Uint16.valueOf(oducnrate));
552 InterfaceBuilder oduInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
553 logicalConnPoint + ODUC + oducnrate);
556 List<String> listSupportingOtucnInterface = new ArrayList<>();
557 listSupportingOtucnInterface.add(supportingOtucn);
559 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
560 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
561 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
563 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
565 // Post interface on the device
566 openRoadmInterfaces.postInterface(nodeId, oduInterfaceBuilder);
567 // Post the equipment-state change on the device circuit-pack if xpdr node
568 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
569 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
571 // Update the port-mapping with the interface information
572 this.portMapping.updateMapping(nodeId, portMap);
573 return oduInterfaceBuilder.getName();
577 // With SAPI and DAPI information
578 public String createOpenRoadmOtnOducnInterface(String anodeId, String alogicalConnPoint,
579 String supportingOtucn, String znodeId, String zlogicalConnPoint)
580 throws OpenRoadmInterfaceException {
581 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
582 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
583 if (portMapA == null) {
584 throw new OpenRoadmInterfaceException(
585 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
586 anodeId, alogicalConnPoint));
589 if (portMapZ == null) {
590 throw new OpenRoadmInterfaceException(
591 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
592 znodeId, zlogicalConnPoint));
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 .setOpu(opuBuilder.build())
612 .setTxSapi(portMapA.getLcpHashVal())
613 .setTxDapi(portMapZ.getLcpHashVal())
614 .setExpectedSapi(portMapZ.getLcpHashVal())
615 .setExpectedDapi(portMapZ.getLcpHashVal());
617 // Set the ODUCn rate from OTUCn interface naming convention
618 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(portMapA, OtnOdu.class,
629 alogicalConnPoint + ODUC + oducnrate);
632 List<String> listSupportingOtucnInterface = new ArrayList<>();
633 listSupportingOtucnInterface.add(supportingOtucn);
635 oduInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
636 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder oduIf1Builder =
637 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
639 oduInterfaceBuilder.addAugmentation(oduIf1Builder.setOdu(oduBuilder.build()).build());
641 // Post interface on the device
642 openRoadmInterfaces.postInterface(anodeId, oduInterfaceBuilder);
643 // Post the equipment-state change on the device circuit-pack if xpdr node
644 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
645 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
647 // Update the port-mapping with the interface information
648 this.portMapping.updateMapping(anodeId, portMapA);
649 return oduInterfaceBuilder.getName();
652 // This is only for transponder
653 public String createOpenRoadmOduflexInterface(String nodeId, String logicalConnPoint,
654 String supportingOducn)
655 throws OpenRoadmInterfaceException {
656 Mapping portMap = portMapping.getMapping(nodeId, logicalConnPoint);
657 if (portMap == null) {
658 throw new OpenRoadmInterfaceException(
659 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
660 nodeId, logicalConnPoint));
663 OpuBuilder opuBuilder = new OpuBuilder()
664 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
665 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
667 // Parent Odu-allocation
668 // Set the trib-slot array
669 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
670 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
671 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
673 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
674 .setTribPortNumber(Uint16.valueOf(1))
675 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
677 // Create an ODUFlex object
678 OduBuilder oduBuilder = new OduBuilder()
679 .setRate(ODUflexCbr.class)
680 .setOduflexCbrService(ODUflexCbr400G.class)
681 .setOduFunction(ODUTTPCTP.class)
682 .setMonitoringMode(MonitoringMode.Terminated)
683 .setTimActEnabled(false)
684 .setTimDetectMode(TimDetectMode.Disabled)
685 .setDegmIntervals(Uint8.valueOf(2))
686 .setDegthrPercentage(Uint16.valueOf(100))
687 .setOpu(opuBuilder.build())
688 .setParentOduAllocation(parentOduAllocationBuilder.build());
690 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMap, OtnOdu.class,
691 logicalConnPoint + "-ODUFLEX");
693 List<String> listSupportingOtucnInterface = new ArrayList<>();
694 listSupportingOtucnInterface.add(supportingOducn);
696 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
699 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
701 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
703 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
705 // Post interface on the device
706 openRoadmInterfaces.postInterface(nodeId, oduflexInterfaceBuilder);
708 // Post the equipment-state change on the device circuit-pack if xpdr node
709 if (portMap.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
710 this.openRoadmInterfaces.postEquipmentState(nodeId, portMap.getSupportingCircuitPackName(), true);
713 return oduflexInterfaceBuilder.getName();
716 // This is only for transponder; with SAPI/DAPI information
717 public String createOpenRoadmOduflexInterface(String anodeId, String alogicalConnPoint,
718 String supportingOducn, String znodeId, String zlogicalConnPoint)
719 throws OpenRoadmInterfaceException {
720 Mapping portMapA = portMapping.getMapping(anodeId, alogicalConnPoint);
721 Mapping portMapZ = portMapping.getMapping(znodeId, zlogicalConnPoint);
722 if (portMapA == null) {
723 throw new OpenRoadmInterfaceException(
724 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
725 anodeId, alogicalConnPoint));
728 if (portMapZ == null) {
729 throw new OpenRoadmInterfaceException(
730 String.format(MAPPING_ERROR_EXCEPTION_MESSAGE,
731 znodeId, zlogicalConnPoint));
735 OpuBuilder opuBuilder = new OpuBuilder()
736 .setExpPayloadType(PayloadTypeDef.getDefaultInstance("32"))
737 .setPayloadType(PayloadTypeDef.getDefaultInstance("32"));
739 // Parent Odu-allocation
740 // Set the trib-slot array
741 List<OpucnTribSlotDef> tribslots = new ArrayList<>();
742 IntStream.range(1, 5).forEach(a -> IntStream.range(1, 21).forEach(b -> tribslots.add(
743 OpucnTribSlotDef.getDefaultInstance(a + "." + b))));
745 ParentOduAllocationBuilder parentOduAllocationBuilder = new ParentOduAllocationBuilder()
746 .setTribPortNumber(Uint16.valueOf(1))
747 .setTribSlotsChoice(new OpucnBuilder().setOpucnTribSlots(tribslots).build());
749 // Create an ODUFlex object
750 OduBuilder oduBuilder = new OduBuilder()
751 .setRate(ODUflexCbr.class)
752 .setOduflexCbrService(ODUflexCbr400G.class)
753 .setOduFunction(ODUTTPCTP.class)
754 .setMonitoringMode(MonitoringMode.Terminated)
755 .setTimActEnabled(false)
756 .setTimDetectMode(TimDetectMode.Disabled)
757 .setDegmIntervals(Uint8.valueOf(2))
758 .setDegthrPercentage(Uint16.valueOf(100))
759 .setTxSapi(portMapA.getLcpHashVal())
760 .setTxDapi(portMapZ.getLcpHashVal())
761 .setExpectedSapi(portMapZ.getLcpHashVal())
762 .setExpectedDapi(portMapA.getLcpHashVal())
763 .setOpu(opuBuilder.build())
764 .setParentOduAllocation(parentOduAllocationBuilder.build());
766 InterfaceBuilder oduflexInterfaceBuilder = createGenericInterfaceBuilder(portMapA, OtnOdu.class,
767 alogicalConnPoint + "-ODUFLEX");
769 List<String> listSupportingOtucnInterface = new ArrayList<>();
770 listSupportingOtucnInterface.add(supportingOducn);
772 oduflexInterfaceBuilder.setSupportingInterfaceList(listSupportingOtucnInterface);
775 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder
777 new org.opendaylight.yang.gen.v1.http.org.openroadm.otn.odu.interfaces.rev200529.Interface1Builder();
779 oduflexInterfaceBuilder.addAugmentation(oduflexIf1Builder.setOdu(oduBuilder.build()).build());
781 // Post interface on the device
782 openRoadmInterfaces.postInterface(anodeId, oduflexInterfaceBuilder);
784 // Post the equipment-state change on the device circuit-pack if xpdr node
785 if (portMapA.getLogicalConnectionPoint().contains(StringConstants.NETWORK_TOKEN)) {
786 this.openRoadmInterfaces.postEquipmentState(anodeId, portMapA.getSupportingCircuitPackName(), true);
789 return oduflexInterfaceBuilder.getName();
792 // This creates the name of the interface with slot numbers at the end
793 public String createOpenRoadmOtsiInterfaceName(String logicalConnectionPoint, String spectralSlotName) {
794 return String.join(GridConstant.NAME_PARAMETERS_SEPARATOR, logicalConnectionPoint, spectralSlotName);
797 private InterfaceBuilder createGenericInterfaceBuilder(Mapping portMap, Class<? extends InterfaceType> type,
799 return new org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev200529.interfaces.grp.InterfaceBuilder()
800 .setDescription(" TBD ")
801 .setCircuitId(" TBD ")
802 .setSupportingCircuitPackName(portMap.getSupportingCircuitPackName())
803 .setSupportingPort(portMap.getSupportingPort())
804 .setAdministrativeState(AdminStates.InService)
807 .withKey(new InterfaceKey(key));
810 @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
811 value = "UPM_UNCALLED_PRIVATE_METHOD",
812 justification = "call in call() method")
813 private int getServiceRate(ModulationFormat modulationFormat) {
815 switch (modulationFormat) {
817 LOG.info("Given modulation format is {} and thus rate is 200G", modulationFormat);
820 LOG.info("Given modulation format is {} and thus rate is 300G", modulationFormat);
823 // Based on roll-of-factor of 0.5, 87.5 - 12.5 = 75GHz translates to 63.1 GBaud
824 LOG.info("Given modulation format is {} and thus rate is 400G", modulationFormat);
827 LOG.error("Modulation format is required to select the rate");