2 * Copyright © 2023 Orange, Inc. 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
8 package org.opendaylight.transportpce.tapi.topology;
10 import java.math.RoundingMode;
11 import java.nio.charset.Charset;
12 import java.util.ArrayList;
13 import java.util.Arrays;
14 import java.util.Collection;
15 import java.util.Collections;
16 import java.util.Comparator;
17 import java.util.HashMap;
18 import java.util.HashSet;
19 import java.util.List;
22 import java.util.TreeMap;
23 import java.util.UUID;
24 import java.util.stream.Collectors;
25 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
26 import org.opendaylight.transportpce.common.fixedflex.GridUtils;
27 import org.opendaylight.transportpce.tapi.TapiStringConstants;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.TerminationPoint1;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev230526.degree.used.wavelengths.UsedWavelengths;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.degree.rev230526.degree.used.wavelengths.UsedWavelengthsKey;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.node.termination.point.PpAttributes;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.node.termination.point.TxTtpAttributes;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.networks.network.node.termination.point.XpdrNetworkAttributes;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPools;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.OduSwitchingPoolsBuilder;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
39 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListBuilder;
40 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev230526.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingListKey;
41 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmNodeType;
42 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.OpenroadmTpType;
43 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev230526.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
44 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.Node1;
45 import org.opendaylight.yang.gen.v1.http.org.openroadm.xponder.rev230526.xpdr.mode.attributes.supported.operational.modes.OperationalModeKey;
46 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
47 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
48 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
49 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.AdministrativeState;
50 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.CAPACITYUNITGBPS;
51 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Direction;
52 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LAYERPROTOCOLQUALIFIER;
53 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LayerProtocolName;
54 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.LifecycleState;
55 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OperationalState;
56 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.PortRole;
57 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
58 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.pac.AvailableCapacityBuilder;
59 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.capacity.pac.TotalPotentialCapacityBuilder;
60 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.Name;
61 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameBuilder;
62 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.global._class.NameKey;
63 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.payload.structure.CapacityBuilder;
64 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
65 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointBuilder;
66 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
67 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU0;
68 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2;
69 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU2E;
70 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODU4;
71 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.ODUTYPEODUCN;
72 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.digital.otn.rev221121.OTUTYPEOTUCN;
73 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE100GigE;
74 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPE10GigELAN;
75 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.dsr.rev221121.DIGITALSIGNALTYPEGigE;
76 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTS;
77 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSi;
78 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.PHOTONICLAYERQUALIFIEROTSiMC;
79 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpecBuilder;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.photonic.media.node.edge.point.spec.SpectrumCapabilityPacBuilder;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrum;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumBuilder;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumKey;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrum;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrumBuilder;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrumKey;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrum;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrumBuilder;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrumKey;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULE;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULECANNOTFORWARDACROSSGROUP;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroup;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroupBuilder;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroupKey;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroup;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroupBuilder;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroupKey;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupBuilder;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupKey;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructure;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructureBuilder;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePoint;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointBuilder;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedPayloadStructure;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedPayloadStructureBuilder;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleBuilder;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleKey;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristic;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeBuilder;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristic;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristicBuilder;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristic;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristicBuilder;
129 import org.opendaylight.yangtools.yang.common.Decimal64;
130 import org.opendaylight.yangtools.yang.common.Uint16;
131 import org.opendaylight.yangtools.yang.common.Uint64;
132 import org.slf4j.Logger;
133 import org.slf4j.LoggerFactory;
136 public class ConvertORToTapiTopology {
138 private static final Logger LOG = LoggerFactory.getLogger(ConvertORToTapiTopology.class);
139 private static final TreeMap<Integer, String> OPMODE_LOOPRATE_MAP;
140 private static final int OPMODE_LOOPRATE_MAX;
141 private static final Map<String, Map<String, Map<LAYERPROTOCOLQUALIFIER, Uint64>>> LPN_MAP;
142 private String ietfNodeId;
143 private OpenroadmNodeType ietfNodeType;
144 private AdminStates ietfNodeAdminState;
145 private State ietfNodeOperState;
146 private List<TerminationPoint> oorClientPortList;
147 private List<TerminationPoint> oorNetworkPortList;
148 private OduSwitchingPools oorOduSwitchingPool;
149 private Uuid tapiTopoUuid;
150 private Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node>
152 private Map<LinkKey, Link> tapiLinks;
153 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> tapiSips;
154 private Map<String, Uuid> uuidMap;
157 OPMODE_LOOPRATE_MAP = new TreeMap<>(Comparator.reverseOrder());
158 OPMODE_LOOPRATE_MAP.putAll(Map.of(8, "800G", 6, "600G" , 4, "400G" , 3, "300G" , 2, "200G" , 1, "100G"));
159 OPMODE_LOOPRATE_MAX = Collections.max(OPMODE_LOOPRATE_MAP.keySet());
160 LPN_MAP = new HashMap<>(Map.of(
161 "ETH", new HashMap<>(Map.of(
163 ODUTYPEODU0.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPEGigE.VALUE, Uint64.valueOf(0)),
164 "If10GEODU2e", Map.of(
165 ODUTYPEODU2E.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPE10GigELAN.VALUE, Uint64.valueOf(0)),
166 "If10GEODU2", Map.of(
167 ODUTYPEODU2.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPE10GigELAN.VALUE, Uint64.valueOf(0)),
168 "If10GE", Map.of(DIGITALSIGNALTYPE10GigELAN.VALUE, Uint64.valueOf(0)),
169 "If100GEODU4", Map.of(
170 ODUTYPEODU4.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPE100GigE.VALUE, Uint64.valueOf(0)),
171 "If100GE", Map.of(DIGITALSIGNALTYPE100GigE.VALUE, Uint64.valueOf(0)),
172 "IfOCH", Map.of(ODUTYPEODU4.VALUE, Uint64.valueOf(0)))),
173 "ODU", new HashMap<>(Map.of(
174 "If1GEODU0", Map.of(ODUTYPEODU0.VALUE, Uint64.valueOf(0)),
175 "If10GEODU2e", Map.of(ODUTYPEODU2E.VALUE, Uint64.valueOf(0)),
176 "If10GEODU2", Map.of(ODUTYPEODU2.VALUE, Uint64.valueOf(0)),
177 "If100GEODU4", Map.of(ODUTYPEODU4.VALUE, Uint64.valueOf(0)))),
178 "PHOTONIC_MEDIA", new HashMap<>(Map.of(
180 Map.of(ODUTYPEODUCN.VALUE, Uint64.valueOf(1), OTUTYPEOTUCN.VALUE, Uint64.valueOf(1)),
182 Map.of(ODUTYPEODUCN.VALUE, Uint64.valueOf(1), OTUTYPEOTUCN.VALUE, Uint64.valueOf(1),
183 PHOTONICLAYERQUALIFIEROTSiMC.VALUE, Uint64.valueOf(1),
184 PHOTONICLAYERQUALIFIEROTS.VALUE, Uint64.valueOf(1))))));
185 LPN_MAP.get("ETH").put("IfOCHOTU4ODU4", LPN_MAP.get("ETH").get("IfOCH"));
186 LPN_MAP.put("DSR", LPN_MAP.get("ETH"));
187 LPN_MAP.get("ODU").put("If10GE", LPN_MAP.get("ODU").get("If10GEODU2"));
188 LPN_MAP.get("ODU").put("If100GE", LPN_MAP.get("ODU").get("If100GEODU4"));
189 LPN_MAP.get("ODU").put("IfOCHOTU4ODU4", LPN_MAP.get("ODU").get("If100GEODU4"));
190 LPN_MAP.get("ODU").put("IfOCH", LPN_MAP.get("ODU").get("If100GEODU4"));
191 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOtsiOtucnOducn", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCHOTUCnODUCn"));
192 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTUCnODUCnRegen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCHOTUCnODUCn"));
194 .get("PHOTONIC_MEDIA").put("IfOCHOTUCnODUCnUniregen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCHOTUCnODUCn"));
195 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTU4ODU4", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCH"));
196 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTU4ODU4Regen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCH"));
197 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTU4ODU4Uniregen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCH"));
201 public ConvertORToTapiTopology(Uuid tapiTopoUuid) {
202 this.tapiTopoUuid = tapiTopoUuid;
203 this.tapiNodes = new HashMap<>();
204 this.tapiLinks = new HashMap<>();
205 this.uuidMap = new HashMap<>();
206 this.tapiSips = new HashMap<>();
209 public void convertNode(Node ietfNode, List<String> networkPorts) {
210 this.ietfNodeId = ietfNode.getNodeId().getValue();
212 ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class);
213 if (ietfAug == null) {
216 this.ietfNodeType = ietfAug.getNodeType();
217 this.ietfNodeAdminState = ietfAug.getAdministrativeState();
218 this.ietfNodeOperState = ietfAug.getOperationalState();
220 ietfNode.augmentation(
221 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
222 this.oorNetworkPortList = ietfAugTopo.getTerminationPoint().values().stream()
223 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
224 == OpenroadmTpType.XPONDERNETWORK.getIntValue()
225 && networkPorts.contains(tp.getTpId().getValue()))
226 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
227 .collect(Collectors.toList());
228 if (this.ietfNodeType.equals(OpenroadmNodeType.TPDR)) {
229 this.oorOduSwitchingPool = createOduSwitchingPoolForTp100G();
230 List<TpId> tpList = this.oorOduSwitchingPool.getNonBlockingList().values().stream()
231 .flatMap(nbl -> nbl.getTpList().stream())
232 .collect(Collectors.toList());
233 this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
234 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
235 == OpenroadmTpType.XPONDERCLIENT.getIntValue()
236 && tpList.contains(tp.getTpId()))
237 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
238 .collect(Collectors.toList());
239 this.oorClientPortList.forEach(tp -> LOG.info("tp = {}", tp.getTpId()));
241 this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
242 .values().stream().findFirst().orElseThrow();
243 this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
244 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
245 == OpenroadmTpType.XPONDERCLIENT.getIntValue())
246 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
247 .collect(Collectors.toList());
250 // node creation [DSR/ODU] ([DSR/ODU] and OTSI merged in R 2.4.X)
251 LOG.info("creation of a DSR/ODU node for {}", this.ietfNodeId);
252 String nodeIdXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
253 this.uuidMap.put(nodeIdXpdr,
255 new Uuid(UUID.nameUUIDFromBytes(nodeIdXpdr.getBytes(Charset.forName("UTF-8"))).toString()));
256 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(nodeIdXpdr).build();
257 Name namePhot = new NameBuilder().setValueName("otsi node name").setValue(nodeIdXpdr).build();
258 Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
259 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node dsrNode =
261 Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot, nameNodeType.key(), nameNodeType),
263 Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
264 LayerProtocolName.DIGITALOTN, LayerProtocolName.PHOTONICMEDIA));
265 LOG.debug("XPDR Node {} should have {} NEPs and SIPs",
266 this.ietfNodeId, this.oorClientPortList.size() + this.oorNetworkPortList.size());
267 LOG.info("XPDR Node {} has {} NEPs and {} SIPs",
269 dsrNode.getOwnedNodeEdgePoint().values().size(),
270 dsrNode.getOwnedNodeEdgePoint().values().stream()
271 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
272 tapiNodes.put(dsrNode.key(), dsrNode);
275 public Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String topoType, Uuid nodeUuid,
276 String subNodeName, List<OwnedNodeEdgePointKey> onepl, FORWARDINGRULE forwardingRule, int index) {
277 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
278 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
279 nepMap = new HashMap<>();
280 for (OwnedNodeEdgePointKey onepKey : onepl) {
281 var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
282 .node.rule.group.NodeEdgePointBuilder()
283 .setTopologyUuid(tapiTopoUuid)
284 .setNodeUuid(nodeUuid)
285 .setNodeEdgePointUuid(onepKey.getUuid())
287 nepMap.put(nep.key(), nep);
289 String nrgNameValue = String.join("-", subNodeName, "node-rule-group-" + index);
290 Rule rule = new RuleBuilder()
291 .setLocalId("forward")
292 .setForwardingRule(forwardingRule)
293 .setRuleType(new HashSet<RuleType>(Set.of(RuleType.FORWARDING)))
295 Name nrgName = new NameBuilder().setValueName("nrg name").setValue(nrgNameValue).build();
296 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
297 .setName(Map.of(nrgName.key(), nrgName))
298 .setUuid(new Uuid(UUID.nameUUIDFromBytes((nrgNameValue).getBytes(Charset.forName("UTF-8"))).toString()))
299 .setRule(new HashMap<RuleKey, Rule>(Map.of(rule.key(), rule)))
300 .setNodeEdgePoint(nepMap)
302 return new HashMap<>(Map.of(nodeRuleGroup.key(), nodeRuleGroup));
305 public Map<NodeRuleGroupKey, NodeRuleGroup> createAllNodeRuleGroupForRdmNode(
306 String topoType, Uuid nodeUuid, String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
307 List<OwnedNodeEdgePoint> otsNepList = topoType.equals("T0ML") ? onepl.stream().collect(Collectors.toList())
309 .filter(onep -> onep.getName().keySet().contains(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
310 .collect(Collectors.toList());
311 LOG.info("Creating NRG for {} {}", topoType, otsNepList);
312 List<OwnedNodeEdgePointKey> degOnepKeyList = new ArrayList<>();
313 List<String> srgNames = new ArrayList<>();
314 Map<OwnedNodeEdgePointKey,String> srgMap = new HashMap<>();
315 for (OwnedNodeEdgePoint onep : otsNepList) {
316 String onepName = onep.getName()
317 .get(new NameKey(topoType.equals("T0ML") ? "NodeEdgePoint name" : "PHOTONIC_MEDIA_OTSNodeEdgePoint"))
319 String subNodeName = topoType.equals("T0ML") ? "ROADMINFRA-SRG-PP"
320 : String.join("-", onepName.split("\\+")[0], onepName.split("\\+")[2]);
321 if (subNodeName.contains("DEG")) {
322 subNodeName = subNodeName.split("\\-TTP")[0];
323 degOnepKeyList.add(onep.key());
324 } else if (subNodeName.contains("SRG")) {
325 subNodeName = subNodeName.split("\\-PP")[0];
326 srgMap.put(onep.key(), subNodeName);
327 if (!srgNames.contains(subNodeName)) {
328 srgNames.add(subNodeName);
333 Map<NodeRuleGroupKey, NodeRuleGroup> globalNrgMap = new HashMap<>();
334 if (topoType.equals("Full")) {
335 globalNrgMap.putAll(createNodeRuleGroupForRdmNode(
336 topoType, nodeUuid, String.join("-", orNodeId, "DEG"),
337 degOnepKeyList, FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, index));
340 for (String srgName : srgNames) {
341 globalNrgMap.putAll(createNodeRuleGroupForRdmNode(
345 srgMap.entrySet().stream()
346 .filter(item -> item.getValue().equals(srgName))
347 .map(item -> item.getKey())
348 .collect(Collectors.toList()),
349 // For T0ML we consider any port of ROADM INFRA can connect to potentially any other port
350 //topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
351 topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
352 : FORWARDINGRULECANNOTFORWARDACROSSGROUP.VALUE,
353 // Whereas for Abstracted or Full Topology we consider any port of the same SRG can not forward to
354 // another port of the same SRG. Connectivity between SRGS will be defined through inter-rule-group
357 LOG.debug("AllNodeRuleGroup : creating a NRG for {}", srgName);
362 public Map<InterRuleGroupKey, InterRuleGroup> createInterRuleGroupForRdmNode(
363 String topoType, Uuid nodeUuid,String orNodeId, List<NodeRuleGroupKey> nrgList) {
364 Map<AssociatedNodeRuleGroupKey, AssociatedNodeRuleGroup> associatedNrgMap = new HashMap<>();
365 for (NodeRuleGroupKey nrgKey : nrgList) {
366 AssociatedNodeRuleGroup associatedNrg = new AssociatedNodeRuleGroupBuilder()
367 .setTopologyUuid(tapiTopoUuid)
368 .setNodeUuid(nodeUuid)
369 .setNodeRuleGroupUuid(nrgKey.getUuid())
371 associatedNrgMap.put(associatedNrg.key(), associatedNrg);
373 var rule = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
374 .inter.rule.group.RuleBuilder()
375 .setLocalId("forward")
376 .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
377 .setRuleType(new HashSet<RuleType>(Set.of(RuleType.FORWARDING)))
379 String irgNameValue = topoType.equals("Full") ? orNodeId + " inter rule group-" : "rdm infra inter rule group-";
380 Name irgName = new NameBuilder().setValueName("irg name").setValue(irgNameValue).build();
381 InterRuleGroup interRuleGroup = new InterRuleGroupBuilder()
382 .setUuid(new Uuid(UUID.nameUUIDFromBytes((irgNameValue).getBytes(Charset.forName("UTF-8"))).toString()))
383 .setName(Map.of(irgName.key(), irgName))
384 .setRule(new HashMap<>(Map.of(rule.key(), rule)))
385 .setAssociatedNodeRuleGroup(associatedNrgMap)
387 return new HashMap<>(Map.of(new InterRuleGroupKey(interRuleGroup.getUuid()), interRuleGroup));
390 public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(
391 int nb, LayerProtocolName layerProtocol, String tpId, String nodeid,
392 Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
393 OperationalState operState, AdministrativeState adminState) {
394 // add them to SIP context
395 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
396 for (int i = 0; i < nb; i++) {
397 String sipName = nb == 1 ? String.join("+", "SIP", nodeid, tpId)
398 : String.join("+", "SIP", nodeid, tpId, "Nber", String.valueOf(i));
399 LOG.info("SIP = {}", sipName);
400 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(sipName.getBytes(Charset.forName("UTF-8"))).toString());
401 MappedServiceInterfacePoint msip =
402 new MappedServiceInterfacePointBuilder().setServiceInterfacePointUuid(sipUuid).build();
403 ServiceInterfacePoint sip =
404 createSIP(sipUuid, layerProtocol, tpId, nodeid, supportedInterfaceCapability, operState, adminState);
405 this.tapiSips.put(sip.key(), sip);
406 msipl.put(msip.key(), msip);
407 LOG.debug("SIP created {}", sip.getUuid());
408 LOG.debug("This SIP corresponds to SIP+nodeId {} + TpId {}", nodeid, tpId);
413 public List<AvailablePayloadStructure> createAvailablePayloadStructureForPhtncMedia(
414 Boolean otsiProvisioned,
415 Collection<SupportedInterfaceCapability> sicList,
416 List<OperationalModeKey> supportedOpModes) {
417 if (supportedOpModes == null || supportedOpModes.isEmpty()) {
421 Integer loopRate = 0;
422 for (OperationalModeKey operationalMode : supportedOpModes) {
423 for (Map.Entry<Integer, String> entry: OPMODE_LOOPRATE_MAP.entrySet()) {
424 if (operationalMode.toString().contains(entry.getValue())) {
425 loopRate = entry.getKey();
429 if (loopRate > nepRate) {
431 if (nepRate >= OPMODE_LOOPRATE_MAX) {
436 List<AvailablePayloadStructure> aps = new ArrayList<>();
437 Integer cepInstanceNber = otsiProvisioned ? 0 : 1;
438 for (SupportedInterfaceCapability sic : sicList) {
439 switch (sic.getIfCapType().toString().split("\\{")[0]) {
440 case "IfOCHOTU4ODU4":
441 case "IfOCHOTU4ODU4Regen":
442 case "IfOCHOTU4ODU4Uniregen":
443 aps.add(new AvailablePayloadStructureBuilder()
444 .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
445 .setNumberOfCepInstances(Uint64.valueOf(cepInstanceNber))
447 new CapacityBuilder()
448 .setUnit(CAPACITYUNITGBPS.VALUE)
449 .setValue(Decimal64.valueOf(100.0 * cepInstanceNber, RoundingMode.DOWN))
453 case "IfOCHOTUCnODUCn":
454 case "IfOtsiOtucnOducn":
455 case "IfOCHOTUCnODUCnRegen":
456 case "IfOCHOTUCnODUCnUniregen":
457 aps.add(new AvailablePayloadStructureBuilder()
458 .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
459 ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
460 .setNumberOfCepInstances(Uint64.valueOf(nepRate * cepInstanceNber))
462 new CapacityBuilder()
463 .setUnit(CAPACITYUNITGBPS.VALUE)
464 .setValue(Decimal64.valueOf(nepRate * 100.0 * cepInstanceNber, RoundingMode.DOWN))
472 return aps.stream().distinct().toList();
475 public List<SupportedPayloadStructure> createSupportedPayloadStructureForPhtncMedia(
476 Collection<SupportedInterfaceCapability> sicList, List<OperationalModeKey> supportedOpModes) {
477 if (supportedOpModes == null || supportedOpModes.isEmpty()) {
481 Integer loopRate = 0;
482 for (OperationalModeKey operationalMode : supportedOpModes) {
483 for (Map.Entry<Integer, String> entry: OPMODE_LOOPRATE_MAP.entrySet()) {
484 if (operationalMode.toString().contains(entry.getValue())) {
485 loopRate = entry.getKey();
489 if (loopRate > nepRate) {
491 if (nepRate >= OPMODE_LOOPRATE_MAX) {
496 List<SupportedPayloadStructure> sps = new ArrayList<>();
497 for (SupportedInterfaceCapability sic : sicList) {
498 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
500 case "IfOCHOTU4ODU4":
501 case "IfOCHOTU4ODU4Regen":
502 case "IfOCHOTU4ODU4Uniregen":
503 sps.add(new SupportedPayloadStructureBuilder()
504 .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
505 .setNumberOfCepInstances(Uint64.valueOf(1))
507 new CapacityBuilder()
508 .setUnit(CAPACITYUNITGBPS.VALUE)
509 .setValue(Decimal64.valueOf(100.0, RoundingMode.DOWN))
513 case "IfOCHOTUCnODUCn":
514 case "IfOtsiOtucnOducn":
515 case "IfOCHOTUCnODUCnRegen":
516 case "IfOCHOTUCnODUCnUniregen":
517 sps.add(new SupportedPayloadStructureBuilder()
518 .setMultiplexingSequence(Set.of(
519 PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
520 ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
521 .setNumberOfCepInstances(Uint64.valueOf(nepRate))
523 new CapacityBuilder()
524 .setUnit(CAPACITYUNITGBPS.VALUE)
525 .setValue(Decimal64.valueOf(nepRate * 100.0, RoundingMode.DOWN))
533 return sps.stream().distinct().toList();
536 public List<SupportedCepLayerProtocolQualifierInstances> createSupportedCepLayerProtocolQualifier(
537 Collection<SupportedInterfaceCapability> sicList, LayerProtocolName lpn) {
538 if (sicList == null) {
539 return new ArrayList<>(List.of(
540 new SupportedCepLayerProtocolQualifierInstancesBuilder()
541 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
542 .setNumberOfCepInstances(Uint64.valueOf(1))
545 LOG.debug("SIC list = {}", sicList);
546 List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
547 String lpnName = lpn.getName();
548 for (SupportedInterfaceCapability sic : sicList) {
549 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
550 if (!LPN_MAP.containsKey(lpnName)) {
551 LOG.error("Layer Protocol Name is unknown {}", lpnName);
554 var ifCapTypeMap = LPN_MAP.get(lpnName);
555 if (!ifCapTypeMap.containsKey(ifCapType)) {
556 LOG.error("IfCapability type {} not managed", ifCapType);
559 for (LAYERPROTOCOLQUALIFIER qualifier: ifCapTypeMap.get(ifCapType).keySet()) {
560 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
561 .setLayerProtocolQualifier(qualifier)
562 .setNumberOfCepInstances(Uint64.valueOf(1))
566 return sclpqiList.stream().distinct().toList();
569 public Map<Double, Double> getXpdrUsedWavelength(TerminationPoint tp) {
570 var tpAug = tp.augmentation(
571 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
575 XpdrNetworkAttributes xnatt = tpAug.getXpdrNetworkAttributes();
579 var xnattWvlgth = xnatt.getWavelength();
580 if (xnattWvlgth == null) {
583 var freq = xnattWvlgth.getFrequency();
587 var width = xnattWvlgth.getWidth();
591 Double freqValue = freq.getValue().doubleValue();
592 Double widthValue = width.getValue().doubleValue();
593 return new HashMap<>(Map.of(freqValue - widthValue * 0.001 / 2, freqValue + widthValue * 0.001 / 2));
596 public Map<Double, Double> getPPUsedWavelength(TerminationPoint tp) {
597 var tpAug = tp.augmentation(
598 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
602 PpAttributes ppAtt = tpAug.getPpAttributes();
606 var usedWvl = ppAtt.getUsedWavelength();
607 if (usedWvl == null || usedWvl.isEmpty()) {
610 var usedWvlfirstValue = usedWvl.entrySet().iterator().next().getValue();
611 Double centFreq = usedWvlfirstValue.getFrequency().getValue().doubleValue();
612 Double width = usedWvlfirstValue.getWidth().getValue().doubleValue();
613 return new HashMap<>(Map.of(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2));
616 public Map<Double, Double> getTTPUsedFreqMap(TerminationPoint tp) {
617 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
618 Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE);
619 var termPoint1 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
620 .TerminationPoint1.class);
621 if (termPoint1 == null) {
624 TxTtpAttributes txttpAtt = termPoint1.getTxTtpAttributes();
625 if (txttpAtt == null) {
628 var txttpAttUsedWvl = txttpAtt.getUsedWavelengths();
629 if (txttpAttUsedWvl == null || txttpAttUsedWvl.isEmpty()) {
630 var txttpAttAvlFreqMaps = txttpAtt.getAvailFreqMaps();
631 if (txttpAttAvlFreqMaps == null || !txttpAttAvlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
634 byte[] freqBitSet = new byte[GridConstant.NB_OCTECTS];
635 LOG.debug("Creation of Bitset {}", freqBitSet);
636 freqBitSet = txttpAttAvlFreqMaps.entrySet().stream()
637 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
638 .findFirst().orElseThrow().getValue().getFreqMap();
639 for (int i = 0; i < GridConstant.EFFECTIVE_BITS; i++) {
640 if (freqBitSet[i] == 0) {
646 return getFreqMapFromBitSet(freqBitSet);
648 Map<Double,Double> freqMap = new HashMap<>();
649 for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas : txttpAttUsedWvl.entrySet()) {
650 Double centFreq = usedLambdas.getValue().getFrequency().getValue().doubleValue();
651 Double width = usedLambdas.getValue().getWidth().getValue().doubleValue();
652 freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
657 public Map<Double, Double> getTTPAvailableFreqMap(TerminationPoint tp) {
658 var termPoint1 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
659 .TerminationPoint1.class);
660 if (termPoint1 == null) {
663 TxTtpAttributes txttpAtt = termPoint1.getTxTtpAttributes();
664 if (txttpAtt == null) {
667 var avlFreqMaps = txttpAtt.getAvailFreqMaps();
668 if (avlFreqMaps == null || !avlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
671 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
672 LOG.debug("Creation of Bitset {}", byteArray);
673 return getFreqMapFromBitSet(
674 avlFreqMaps.entrySet().stream()
675 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
676 .findFirst().orElseThrow().getValue().getFreqMap());
679 public Map<Double, Double> getTTP11AvailableFreqMap(
680 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
684 TxTtpAttributes txttpAtt = tp.getTxTtpAttributes();
685 if (txttpAtt == null) {
688 var avlFreqMaps = txttpAtt.getAvailFreqMaps();
689 if (avlFreqMaps == null || !avlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
692 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
693 LOG.debug("Creation of Bitset {}", byteArray);
694 return getFreqMapFromBitSet(
695 avlFreqMaps.entrySet().stream()
696 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
697 .findFirst().orElseThrow().getValue().getFreqMap());
700 public Map<Double, Double> getPP11UsedWavelength(
701 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
705 PpAttributes ppAtt = tp.getPpAttributes();
709 var usedWvl = ppAtt.getUsedWavelength();
710 if (usedWvl == null || usedWvl.isEmpty()) {
713 var usedWvlFirstValue = usedWvl.entrySet().iterator().next().getValue();
714 Double centFreq = usedWvlFirstValue.getFrequency().getValue().doubleValue();
715 Double width = usedWvlFirstValue.getWidth().getValue().doubleValue();
716 return new HashMap<>(Map.of(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2));
719 public Map<Double, Double> getTTP11UsedFreqMap(
720 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
721 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
722 Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE);
726 TxTtpAttributes txttpAtt = tp.getTxTtpAttributes();
727 if (txttpAtt == null) {
730 var txttpAttUsedWvl = txttpAtt.getUsedWavelengths();
731 if (txttpAttUsedWvl == null || txttpAttUsedWvl.isEmpty()) {
732 var txttpAttAvlFreqMaps = txttpAtt.getAvailFreqMaps();
733 if (txttpAttAvlFreqMaps == null || !txttpAttAvlFreqMaps.keySet().toString().contains(GridConstant.C_BAND)) {
736 byte[] freqBitSet = new byte[GridConstant.NB_OCTECTS];
737 LOG.debug("Creation of Bitset {}", freqBitSet);
738 freqBitSet = txttpAttAvlFreqMaps.entrySet().stream()
739 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
740 .findFirst().orElseThrow().getValue().getFreqMap();
741 for (int i = 0; i < GridConstant.EFFECTIVE_BITS; i++) {
742 if (freqBitSet[i] == 0) {
748 return getFreqMapFromBitSet(freqBitSet);
750 Map<Double,Double> freqMap = new HashMap<>();
751 for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas : txttpAttUsedWvl.entrySet()) {
752 var usedLambdasValue = usedLambdas.getValue();
753 Double centFreq = usedLambdasValue.getFrequency().getValue().doubleValue();
754 Double width = usedLambdasValue.getWidth().getValue().doubleValue();
755 freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
760 public Map<Double, Double> getFreqMapFromBitSet(byte[] byteArray) {
761 // Provides a Map <LowerFreq, HigherFreq> describing start and stop frequencies of all slots that are available
762 // in the ByteArray describing the spectrum : bit sets initially sets to 1/true
763 // In case the byte array has been inverted before calling this method, it provides respectively a map
764 // describing all occupied slots!
765 Map<Double,Double> freqMap = new HashMap<>();
766 Double startFreq = GridConstant.START_EDGE_FREQUENCY;
767 Double stopFreq = 0.0;
768 boolean occupied = false;
769 if (byteArray[0] == 0) {
772 for (int index = 0 ; index < GridConstant.EFFECTIVE_BITS ; index++) {
774 if (byteArray[index] == 1) {
775 startFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
776 stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
780 if (byteArray[index] == 0) {
781 stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
786 if (stopFreq.doubleValue() > startFreq.doubleValue()) {
787 freqMap.put(startFreq, stopFreq);
788 startFreq = stopFreq;
791 if (index == GridConstant.EFFECTIVE_BITS - 1 && startFreq.doubleValue() == stopFreq.doubleValue()) {
792 stopFreq = GridUtils.getStopFrequencyFromIndex(index).doubleValue();
793 freqMap.put(startFreq, stopFreq);
800 public OwnedNodeEdgePointBuilder addPayloadStructureAndPhotSpecToOnep(String nodeId,
801 Map<Double, Double> freqMap, List<OperationalModeKey> operModeList,
802 Collection<SupportedInterfaceCapability> sicColl, OwnedNodeEdgePointBuilder onepBldr, String keyword) {
803 if (!String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
804 && !String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
807 LOG.debug("Entering LOOP Step1");
809 Double lowSupFreq = GridConstant.START_EDGE_FREQUENCY * 1E09 ;
810 Double upSupFreq = lowSupFreq + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz;
812 // Creating OTS & OTSI_MC NEP specific attributes
813 onepBldr.setSupportedPayloadStructure(
814 createSupportedPayloadStructureForPhtncMedia(sicColl,operModeList));
815 SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
816 OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
817 if (freqMap == null || freqMap.isEmpty()) {
818 // TODO: verify if we need to fill OcupiedSpectrum as follows when no lambda provisioned
820 // .setUpperFrequency(Uint64.valueOf(0))
821 // .setLowerFrequency(Uint64.valueOf(0));
822 onepBldr.setAvailablePayloadStructure(
823 createAvailablePayloadStructureForPhtncMedia(false, sicColl,operModeList));
824 AvailableSpectrum aspec = new AvailableSpectrumBuilder()
825 .setLowerFrequency(Uint64.valueOf(Math.round(lowSupFreq)))
826 .setUpperFrequency(Uint64.valueOf(Math.round(upSupFreq)))
828 spectrumPac.setAvailableSpectrum(
829 new HashMap<AvailableSpectrumKey, AvailableSpectrum>(Map.of(
830 new AvailableSpectrumKey(aspec.getLowerFrequency(), aspec.getUpperFrequency()), aspec)));
832 LOG.debug("Entering LOOP Step2");
833 onepBldr.setAvailablePayloadStructure(
834 createAvailablePayloadStructureForPhtncMedia(true, sicColl,operModeList));
835 for (Map.Entry<Double, Double> frequency : freqMap.entrySet()) {
837 .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
838 .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
840 OccupiedSpectrum ospec = ospecBd.build();
841 spectrumPac.setOccupiedSpectrum(
842 new HashMap<OccupiedSpectrumKey, OccupiedSpectrum>(Map.of(
843 new OccupiedSpectrumKey(ospec.getLowerFrequency(), ospec.getUpperFrequency()), ospec)));
845 LOG.debug("Entering LOOP Step3");
846 SupportableSpectrum sspec = new SupportableSpectrumBuilder()
847 .setLowerFrequency(Uint64.valueOf(Math.round(lowSupFreq)))
848 .setUpperFrequency(Uint64.valueOf(Math.round(upSupFreq)))
850 spectrumPac.setSupportableSpectrum(
851 new HashMap<SupportableSpectrumKey, SupportableSpectrum>(Map.of(
852 new SupportableSpectrumKey(sspec.getLowerFrequency(), sspec.getUpperFrequency()), sspec)));
853 LOG.debug("Entering LOOP Step4");
854 var onep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
855 .OwnedNodeEdgePoint1Builder()
856 .setPhotonicMediaNodeEdgePointSpec(
857 new PhotonicMediaNodeEdgePointSpecBuilder().setSpectrumCapabilityPac(spectrumPac.build()).build())
859 LOG.debug("creating Photonic NEP SPEC for node {} and nep {}", nodeId, onep1);
860 onepBldr.addAugmentation(onep1);
861 LOG.debug("Entering LOOP Step5");
866 public OwnedNodeEdgePointBuilder addPhotSpecToRoadmOnep(String nodeId,
867 Map<Double, Double> usedFreqMap, Map<Double, Double> availableFreqMap,
868 OwnedNodeEdgePointBuilder onepBldr, String keyword) {
869 if (!String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)
870 && !String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OMS).equals(keyword)) {
873 // Creating OTS/OMS NEP specific attributes
875 Double lowSupFreq = GridConstant.START_EDGE_FREQUENCY * 1E09 ;
876 Double upSupFreq = lowSupFreq + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz;
878 SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
879 Map<Double, Double> freqMap = null;
880 if (usedFreqMap == null || usedFreqMap.isEmpty()) {
881 freqMap = Map.of(lowSupFreq, upSupFreq);
883 Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
884 OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
885 for (Map.Entry<Double, Double> frequency : usedFreqMap.entrySet()) {
887 .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
888 .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
889 OccupiedSpectrum ospec = ospecBd.build();
890 ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(), ospec.getUpperFrequency()), ospec);
892 spectrumPac.setOccupiedSpectrum(ospecMap);
894 if (availableFreqMap != null && !availableFreqMap.isEmpty()) {
895 freqMap = availableFreqMap;
897 if (freqMap != null) {
898 Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
899 AvailableSpectrumBuilder aspecBd = new AvailableSpectrumBuilder();
900 for (Map.Entry<Double, Double> frequency : availableFreqMap.entrySet()) {
902 .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
903 .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
904 AvailableSpectrum aspec = aspecBd.build();
905 aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(), aspec.getUpperFrequency()), aspec);
907 spectrumPac.setAvailableSpectrum(aspecMap);
909 SupportableSpectrum sspec = new SupportableSpectrumBuilder()
910 .setLowerFrequency(Uint64.valueOf(Math.round(lowSupFreq)))
911 .setUpperFrequency(Uint64.valueOf(Math.round(upSupFreq)))
913 spectrumPac.setSupportableSpectrum(
914 new HashMap<SupportableSpectrumKey, SupportableSpectrum>(Map.of(
915 new SupportableSpectrumKey(sspec.getLowerFrequency(), sspec.getUpperFrequency()), sspec)));
916 var onep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
917 .OwnedNodeEdgePoint1Builder()
918 .setPhotonicMediaNodeEdgePointSpec(
919 new PhotonicMediaNodeEdgePointSpecBuilder().setSpectrumCapabilityPac(spectrumPac.build()).build())
921 onepBldr.addAugmentation(onep1);
922 LOG.debug("Add Photonic Node Edge point Spec to {} including available Spectrum {} = ",
924 onep1.getPhotonicMediaNodeEdgePointSpec().getSpectrumCapabilityPac().getAvailableSpectrum());
928 private OduSwitchingPools createOduSwitchingPoolForTp100G() {
929 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
931 for (TerminationPoint tp : this.oorNetworkPortList) {
932 NonBlockingList nbl = new NonBlockingListBuilder()
933 .setNblNumber(Uint16.valueOf(count))
934 .setTpList(new HashSet<>(Set.of(
936 tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526
937 .TerminationPoint1.class)
938 .getAssociatedConnectionMapTp().iterator().next())))
940 nblMap.put(nbl.key(), nbl);
943 return new OduSwitchingPoolsBuilder()
944 .setNonBlockingList(nblMap)
945 .setSwitchingPoolNumber(Uint16.valueOf(1))
949 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node createTapiNode(
950 Map<NameKey, Name> nodeNames, Set<LayerProtocolName> layerProtocols) {
951 Uuid nodeUuid = null;
952 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
953 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
954 if (layerProtocols.contains(LayerProtocolName.DSR)
955 || layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
956 Rule rule = new RuleBuilder()
957 .setLocalId("forward")
958 .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
959 .setRuleType(new HashSet<>(Set.of(RuleType.FORWARDING)))
961 nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, new HashMap<>(Map.of(rule.key(), rule)));
963 var nodeName = nodeNames.get(nodeNames.keySet().iterator().next());
964 LOG.error("Undefined LayerProtocolName for {} node {}", nodeName.getValueName(), nodeName.getValue());
966 // Empty random creation of mandatory fields for avoiding errors....
967 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
968 .setCostAlgorithm("Restricted Shortest Path - RSP")
969 .setCostName("HOP_COUNT")
970 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
972 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
973 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
974 .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
975 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
976 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
977 .setTrafficPropertyName("FIXED_LATENCY")
979 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
980 .setRiskCharacteristicName("risk characteristic")
981 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
983 return new NodeBuilder()
986 .setLayerProtocolName(layerProtocols)
987 .setAdministrativeState(transformAsToTapiAdminState(this.ietfNodeAdminState.getName()))
988 .setOperationalState(transformOsToTapiOperationalState(this.ietfNodeOperState.getName()))
989 .setLifecycleState(LifecycleState.INSTALLED)
990 .setOwnedNodeEdgePoint(onepl)
991 .setNodeRuleGroup(nodeRuleGroupList)
992 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
993 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
994 .setRiskParameterPac(
995 new RiskParameterPacBuilder()
996 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
998 .setErrorCharacteristic("error")
999 .setLossCharacteristic("loss")
1000 .setRepeatDeliveryCharacteristic("repeat delivery")
1001 .setDeliveryOrderCharacteristic("delivery order")
1002 .setUnavailableTimeCharacteristic("unavailable time")
1003 .setServerIntegrityProcessCharacteristic("server integrity process")
1007 private Uuid getNodeUuid4Dsr(
1008 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
1009 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList,
1010 Map<RuleKey, Rule> ruleList) {
1011 // client NEP DSR creation on DSR/ODU node
1012 for (int i = 0; i < oorClientPortList.size(); i++) {
1013 String nodeIdDsr = String.join("+",
1014 this.ietfNodeId, TapiStringConstants.DSR, oorClientPortList.get(i).getTpId().getValue());
1015 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(nodeIdDsr.getBytes(Charset.forName("UTF-8"))).toString());
1016 LOG.info("NEP = {} has Uuid {} ", nodeIdDsr, nepUuid);
1017 this.uuidMap.put(nodeIdDsr, nepUuid);
1018 Name name = new NameBuilder()
1019 .setValue(nodeIdDsr)
1020 .setValueName(OpenroadmNodeType.TPDR.equals(this.ietfNodeType) ? "100G-tpdr" : "NodeEdgePoint_C")
1022 OwnedNodeEdgePoint onep = createNep(
1023 oorClientPortList.get(i),
1024 Map.of(name.key(), name),
1025 LayerProtocolName.DSR, LayerProtocolName.DSR, true,
1026 String.join("+", this.ietfNodeId, TapiStringConstants.DSR));
1027 onepl.put(onep.key(), onep);
1029 // CLIENT NEP E_ODU creation on DSR/ODU node
1030 for (int i = 0; i < oorClientPortList.size(); i++) {
1031 String nodeIdEodu = String.join("+",
1032 this.ietfNodeId, TapiStringConstants.E_ODU, oorClientPortList.get(i).getTpId().getValue());
1033 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdEodu.getBytes(Charset.forName("UTF-8"))).toString());
1034 LOG.info("NEP = {} has Uuid {} ", nodeIdEodu, nepUuid1);
1035 this.uuidMap.put(nodeIdEodu, nepUuid1);
1036 Name onedName = new NameBuilder()
1037 .setValueName("eNodeEdgePoint_N")
1038 .setValue(nodeIdEodu)
1040 OwnedNodeEdgePoint onep = createNep(
1041 oorClientPortList.get(i),
1042 Map.of(onedName.key(), onedName),
1043 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
1044 String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU));
1045 onepl.put(onep.key(), onep);
1047 // NETWORK NEPs I_ODU creation on DSR/ODU node
1048 for (int i = 0; i < oorNetworkPortList.size(); i++) {
1049 String nodeIdIodu = String.join("+",
1050 this.ietfNodeId, TapiStringConstants.I_ODU, oorNetworkPortList.get(i).getTpId().getValue());
1051 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdIodu.getBytes(Charset.forName("UTF-8"))).toString());
1052 LOG.info("NEP = {} has Uuid {} ", nodeIdIodu, nepUuid1);
1053 this.uuidMap.put(nodeIdIodu, nepUuid1);
1054 Name onedName = new NameBuilder()
1055 .setValueName("iNodeEdgePoint_N")
1056 .setValue(nodeIdIodu)
1058 OwnedNodeEdgePoint onep = createNep(
1059 oorNetworkPortList.get(i),
1060 Map.of(onedName.key(), onedName),
1061 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
1062 String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU));
1063 onepl.put(onep.key(), onep);
1065 // NETWORK NEP OTS network on DSR/ODU node
1066 for (int i = 0; i < oorNetworkPortList.size(); i++) {
1067 String nodeIdPmOts = String.join("+",
1068 this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS, oorNetworkPortList.get(i).getTpId().getValue());
1069 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(nodeIdPmOts.getBytes(Charset.forName("UTF-8"))).toString());
1070 LOG.info("NEP = {} has Uuid {} ", nodeIdPmOts, nepUuid2);
1071 this.uuidMap.put(nodeIdPmOts, nepUuid2);
1072 Name onedName = new NameBuilder()
1073 .setValueName("eNodeEdgePoint")
1074 .setValue(nodeIdPmOts)
1076 OwnedNodeEdgePoint onep = createNep(
1077 oorNetworkPortList.get(i),
1078 Map.of(onedName.key(), onedName),
1079 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
1080 String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS));
1081 onepl.put(onep.key(), onep);
1083 for (int i = 0; i < oorNetworkPortList.size(); i++) {
1084 String nodeIdOtMc = String.join("+",
1085 this.ietfNodeId, TapiStringConstants.OTSI_MC, oorNetworkPortList.get(i).getTpId().getValue());
1086 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(nodeIdOtMc.getBytes(Charset.forName("UTF-8"))).toString());
1087 LOG.info("NEP = {} has Uuid {} ", nodeIdOtMc, nepUuid3);
1088 this.uuidMap.put(nodeIdOtMc, nepUuid3);
1089 Name onedName = new NameBuilder()
1090 .setValueName("PhotMedNodeEdgePoint")
1091 .setValue(nodeIdOtMc)
1093 OwnedNodeEdgePoint onep = createNep(
1094 oorNetworkPortList.get(i),
1095 Map.of(onedName.key(), onedName),
1096 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
1097 String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC));
1098 onepl.put(onep.key(), onep);
1100 // create NodeRuleGroup
1102 LOG.debug("ODU switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
1103 String ietfXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
1104 for (NonBlockingList nbl : this.oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1105 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
1106 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
1107 nepList = new HashMap<>();
1108 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
1109 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
1110 oduNepList = new HashMap<>();
1111 LOG.debug("UUidMap={}", this.uuidMap.keySet());
1112 LOG.debug("TP list = {}", nbl.getTpList());
1113 for (TpId tp : nbl.getTpList()) {
1114 String tpValue = tp.getValue();
1115 LOG.debug("TP={}", tpValue);
1116 String ietfEoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU, tpValue);
1117 LOG.debug("UuidKey={}", ietfEoduTp);
1118 String ietfIoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU, tpValue);
1119 if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR, tpValue))
1120 || this.uuidMap.containsKey(ietfIoduTp)) {
1121 var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1122 .node.rule.group.NodeEdgePointBuilder()
1123 .setTopologyUuid(tapiTopoUuid)
1124 .setNodeUuid(this.uuidMap.get(ietfXpdr))
1125 .setNodeEdgePointUuid(this.uuidMap.get(
1128 tpValue.contains("CLIENT") ? TapiStringConstants.DSR : TapiStringConstants.I_ODU,
1131 nepList.put(nep.key(), nep);
1133 if (this.uuidMap.containsKey(ietfEoduTp)) {
1134 var nep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1135 .node.rule.group.NodeEdgePointBuilder()
1136 .setTopologyUuid(tapiTopoUuid)
1137 .setNodeUuid(this.uuidMap.get(ietfXpdr))
1138 .setNodeEdgePointUuid(this.uuidMap.get(ietfEoduTp))
1140 oduNepList.put(nep1.key(), nep1);
1142 if (this.uuidMap.containsKey(ietfIoduTp)) {
1143 // TODO already checked with DSR above -> potential factorization ?
1144 var nep2 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1145 .node.rule.group.NodeEdgePointBuilder()
1146 .setTopologyUuid(tapiTopoUuid)
1147 .setNodeUuid(this.uuidMap.get(ietfXpdr))
1148 .setNodeEdgePointUuid(this.uuidMap.get(ietfIoduTp))
1150 oduNepList.put(nep2.key(), nep2);
1153 LOG.debug("NEPLIST (DSR/I_ODU) of [dsr node rule group] is {}", nepList);
1154 LOG.debug("NEPLIST (E_ODU/I_ODU) of [odu node rule group] is {}", nepList);
1155 // Empty random creation of mandatory fields for avoiding errors....
1156 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1157 .setCostAlgorithm("Restricted Shortest Path - RSP")
1158 .setCostName("HOP_COUNT")
1159 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1161 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1162 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1163 .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1164 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1165 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1166 .setTrafficPropertyName("FIXED_LATENCY")
1168 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1169 .setRiskCharacteristicName("risk characteristic")
1170 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1172 Name nrgName = new NameBuilder()
1173 .setValueName("nrg name")
1174 .setValue("odu node rule group " + count)
1176 NodeRuleGroup nodeRuleGroup1 = new NodeRuleGroupBuilder()
1177 .setName(Map.of(nrgName.key(), nrgName))
1178 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("dsr node rule group " + count)
1179 .getBytes(Charset.forName("UTF-8"))).toString()))
1181 .setNodeEdgePoint(nepList)
1182 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1183 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1184 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1186 nodeRuleGroupList.put(nodeRuleGroup1.key(), nodeRuleGroup1);
1187 NodeRuleGroup nodeRuleGroup2 = new NodeRuleGroupBuilder()
1188 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("odu node rule group " + count)
1189 .getBytes(Charset.forName("UTF-8"))).toString()))
1191 .setNodeEdgePoint(oduNepList)
1192 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1193 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1194 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1196 nodeRuleGroupList.put(nodeRuleGroup2.key(), nodeRuleGroup2);
1199 return this.uuidMap.get(ietfXpdr);
1202 private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
1203 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword) {
1204 var tp1 = oorTp.augmentation(
1205 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class);
1206 var oorTpId = oorTp.getTpId();
1207 var oorTpIdValue = oorTpId.getValue();
1208 if (tp1.getTpSupportedInterfaces() == null) {
1209 LOG.warn("Tp supported interface doesnt exist on TP {}", oorTpIdValue);
1212 TerminationPoint1 oorTpAug = oorTp.augmentation(TerminationPoint1.class);
1213 var oorTpAugAdmState = oorTpAug.getAdministrativeState();
1214 AdministrativeState adminState =
1215 oorTpAugAdmState == null ? null : transformAsToTapiAdminState(oorTpAugAdmState.getName());
1216 var oorTpAugOprState = oorTpAug.getOperationalState();
1217 OperationalState operState =
1218 oorTpAugOprState == null ? null : transformOsToTapiOperationalState(oorTpAugOprState.getName());
1219 Collection<SupportedInterfaceCapability> sicColl =
1220 tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values();
1221 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
1222 .setUuid(this.uuidMap.get(String.join("+", keyword, oorTpIdValue)))
1223 .setLayerProtocolName(nepProtocol)
1225 .setSupportedCepLayerProtocolQualifierInstances(
1226 createSupportedCepLayerProtocolQualifier(sicColl, nepProtocol))
1227 .setDirection(Direction.BIDIRECTIONAL)
1228 .setLinkPortRole(PortRole.SYMMETRIC)
1229 .setAdministrativeState(adminState)
1230 .setOperationalState(operState)
1231 .setLifecycleState(LifecycleState.INSTALLED);
1233 onepBldr.setMappedServiceInterfacePoint(
1234 createMSIP(1, nepProtocol, oorTpIdValue, keyword, sicColl, operState, adminState));
1236 if (oorTpAug.getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
1237 List<OperationalModeKey> opModeList = new ArrayList<>();
1238 var tp11 = oorTp.augmentation(
1239 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
1240 if (tp11 == null || tp11.getXpdrNetworkAttributes() == null) {
1241 for (SupportedInterfaceCapability sic : sicColl) {
1242 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1243 switch (ifCapType) {
1244 case "IfOCHOTUCnODUCn":
1245 case "IfOCHOTUCnODUCnUniregen":
1246 case "IfOCHOTUCnODUCnRegen":
1247 opModeList.add(new OperationalModeKey("400G"));
1248 LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTpId);
1254 opModeList.add(new OperationalModeKey("100G"));
1255 LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTpId);
1257 opModeList = tp11.getXpdrNetworkAttributes().getSupportedOperationalModes().getOperationalMode()
1258 .keySet().stream().toList();
1260 onepBldr = addPayloadStructureAndPhotSpecToOnep(
1261 this.ietfNodeId, getXpdrUsedWavelength(oorTp), opModeList, sicColl, onepBldr, keyword);
1263 OwnedNodeEdgePoint onep = onepBldr.build();
1264 LOG.debug("ConvertORToTapiTopology 1360, onep = {}", onep);
1268 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpId,
1269 String nodeid, Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
1270 OperationalState operState, AdministrativeState adminState) {
1271 // TODO: what value should be set in total capacity and available capacity??
1272 LOG.debug("SIP name = {}", String.join("+", nodeid, tpId));
1273 Name sipName = new NameBuilder()
1274 .setValueName("SIP name")
1275 .setValue(String.join("+", nodeid, tpId))
1277 return new ServiceInterfacePointBuilder()
1279 .setName(Map.of(sipName.key(), sipName))
1280 .setLayerProtocolName(layerProtocol)
1281 .setAdministrativeState(adminState)
1282 .setOperationalState(operState)
1283 .setLifecycleState(LifecycleState.INSTALLED)
1284 .setAvailableCapacity(new AvailableCapacityBuilder().build())
1285 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
1286 .setSupportedCepLayerProtocolQualifierInstances(createSipSupportedLayerProtocolQualifier(
1287 supportedInterfaceCapability, layerProtocol))
1291 private List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1292 .service._interface.point.SupportedCepLayerProtocolQualifierInstances>
1293 createSipSupportedLayerProtocolQualifier(
1294 Collection<SupportedInterfaceCapability> supportedInterfaceCapability, LayerProtocolName lpn) {
1295 if (supportedInterfaceCapability == null) {
1296 return new ArrayList<>(List.of(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1297 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1298 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
1299 .setNumberOfCepInstances(Uint64.valueOf(1))
1302 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1303 .service._interface.point.SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
1304 String lpnName = lpn.getName();
1305 for (SupportedInterfaceCapability sic : supportedInterfaceCapability) {
1306 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1307 if (!LPN_MAP.containsKey(lpnName)) {
1308 LOG.error("Layer Protocol Name is unknown {}", lpnName);
1311 var ifCapTypeMap = LPN_MAP.get(lpnName);
1312 if (!ifCapTypeMap.containsKey(ifCapType)) {
1313 LOG.error("IfCapability type {} not managed", ifCapType);
1316 for (Map.Entry<LAYERPROTOCOLQUALIFIER, Uint64> entry: ifCapTypeMap.get(ifCapType).entrySet()) {
1318 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1319 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1320 .setLayerProtocolQualifier(entry.getKey())
1321 .setNumberOfCepInstances(entry.getValue())
1325 return sclpqiList.stream().distinct().toList();
1328 public Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node>
1333 public Map<LinkKey, Link> getTapiLinks() {
1337 public AdministrativeState transformAsToTapiAdminState(String adminState) {
1338 return adminState == null ? null
1339 : adminState.equals(AdminStates.InService.getName())
1340 || adminState.equals(AdministrativeState.UNLOCKED.getName())
1341 ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
1344 public OperationalState transformOsToTapiOperationalState(String operState) {
1345 return operState == null ? null
1346 : operState.equals("inService") || operState.equals(OperationalState.ENABLED.getName())
1347 ? OperationalState.ENABLED : OperationalState.DISABLED;
1350 public Map<ServiceInterfacePointKey, ServiceInterfacePoint> getTapiSips() {
1354 public void setTapiSips(Map<ServiceInterfacePointKey, ServiceInterfacePoint> tapiSip) {
1355 this.tapiSips.putAll(tapiSip);