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.PhotonicMediaNodeEdgePointSpec;
80 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.context.topology.context.topology.node.owned.node.edge.point.PhotonicMediaNodeEdgePointSpecBuilder;
81 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.photonic.media.node.edge.point.spec.SpectrumCapabilityPacBuilder;
82 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrum;
83 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumBuilder;
84 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.AvailableSpectrumKey;
85 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrum;
86 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrumBuilder;
87 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.OccupiedSpectrumKey;
88 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrum;
89 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrumBuilder;
90 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.spectrum.capability.pac.SupportableSpectrumKey;
91 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULE;
92 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULECANNOTFORWARDACROSSGROUP;
93 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.FORWARDINGRULEMAYFORWARDACROSSGROUP;
94 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.RuleType;
95 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroup;
96 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroupBuilder;
97 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.AssociatedNodeRuleGroupKey;
98 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroup;
99 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroupBuilder;
100 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.InterRuleGroupKey;
101 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroup;
102 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupBuilder;
103 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.NodeRuleGroupKey;
104 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePoint;
105 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointBuilder;
106 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.OwnedNodeEdgePointKey;
107 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.RiskParameterPacBuilder;
108 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructure;
109 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.AvailablePayloadStructureBuilder;
110 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePoint;
111 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointBuilder;
112 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.MappedServiceInterfacePointKey;
113 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstances;
114 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedCepLayerProtocolQualifierInstancesBuilder;
115 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedPayloadStructure;
116 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.edge.point.SupportedPayloadStructureBuilder;
117 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.Rule;
118 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleBuilder;
119 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.RuleKey;
120 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristic;
121 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.risk.parameter.pac.RiskCharacteristicBuilder;
122 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Link;
123 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.LinkKey;
124 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeBuilder;
125 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.NodeKey;
126 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristic;
127 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.cost.pac.CostCharacteristicBuilder;
128 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristic;
129 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.transfer.timing.pac.LatencyCharacteristicBuilder;
130 import org.opendaylight.yangtools.yang.common.Decimal64;
131 import org.opendaylight.yangtools.yang.common.Uint16;
132 import org.opendaylight.yangtools.yang.common.Uint64;
133 import org.slf4j.Logger;
134 import org.slf4j.LoggerFactory;
137 public class ConvertORToTapiTopology {
139 private static final Logger LOG = LoggerFactory.getLogger(ConvertORToTapiTopology.class);
140 private static final TreeMap<Integer, String> OPMODE_LOOPRATE_MAP;
141 private static final int OPMODE_LOOPRATE_MAX;
142 private static final Map<String, Map<String, Map<LAYERPROTOCOLQUALIFIER, Uint64>>> LPN_MAP;
143 private String ietfNodeId;
144 private OpenroadmNodeType ietfNodeType;
145 private AdminStates ietfNodeAdminState;
146 private State ietfNodeOperState;
147 private List<TerminationPoint> oorClientPortList;
148 private List<TerminationPoint> oorNetworkPortList;
149 private OduSwitchingPools oorOduSwitchingPool;
150 private Uuid tapiTopoUuid;
151 private Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node>
153 private Map<LinkKey, Link> tapiLinks;
154 private Map<ServiceInterfacePointKey, ServiceInterfacePoint> tapiSips;
155 private Map<String, Uuid> uuidMap;
158 OPMODE_LOOPRATE_MAP = new TreeMap<>(Comparator.reverseOrder());
159 OPMODE_LOOPRATE_MAP.putAll(Map.of(8, "800G", 6, "600G" , 4, "400G" , 3, "300G" , 2, "200G" , 1, "100G"));
160 OPMODE_LOOPRATE_MAX = Collections.max(OPMODE_LOOPRATE_MAP.keySet());
161 LPN_MAP = new HashMap<>(Map.of(
162 "ETH", new HashMap<>(Map.of(
164 ODUTYPEODU0.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPEGigE.VALUE, Uint64.valueOf(0)),
165 "If10GEODU2e", Map.of(
166 ODUTYPEODU2E.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPE10GigELAN.VALUE, Uint64.valueOf(0)),
167 "If10GEODU2", Map.of(
168 ODUTYPEODU2.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPE10GigELAN.VALUE, Uint64.valueOf(0)),
169 "If10GE", Map.of(DIGITALSIGNALTYPE10GigELAN.VALUE, Uint64.valueOf(0)),
170 "If100GEODU4", Map.of(
171 ODUTYPEODU4.VALUE, Uint64.valueOf(0), DIGITALSIGNALTYPE100GigE.VALUE, Uint64.valueOf(0)),
172 "If100GE", Map.of(DIGITALSIGNALTYPE100GigE.VALUE, Uint64.valueOf(0)),
173 "IfOCH", Map.of(ODUTYPEODU4.VALUE, Uint64.valueOf(0)))),
174 "ODU", new HashMap<>(Map.of(
175 "If1GEODU0", Map.of(ODUTYPEODU0.VALUE, Uint64.valueOf(0)),
176 "If10GEODU2e", Map.of(ODUTYPEODU2E.VALUE, Uint64.valueOf(0)),
177 "If10GEODU2", Map.of(ODUTYPEODU2.VALUE, Uint64.valueOf(0)),
178 "If100GEODU4", Map.of(ODUTYPEODU4.VALUE, Uint64.valueOf(0)))),
179 "PHOTONIC_MEDIA", new HashMap<>(Map.of(
181 Map.of(ODUTYPEODUCN.VALUE, Uint64.valueOf(1), OTUTYPEOTUCN.VALUE, Uint64.valueOf(1)),
183 Map.of(ODUTYPEODUCN.VALUE, Uint64.valueOf(1), OTUTYPEOTUCN.VALUE, Uint64.valueOf(1),
184 PHOTONICLAYERQUALIFIEROTSiMC.VALUE, Uint64.valueOf(1),
185 PHOTONICLAYERQUALIFIEROTS.VALUE, Uint64.valueOf(1))))));
186 LPN_MAP.get("ETH").put("IfOCHOTU4ODU4", LPN_MAP.get("ETH").get("IfOCH"));
187 LPN_MAP.put("DSR", LPN_MAP.get("ETH"));
188 LPN_MAP.get("ODU").put("If10GE", LPN_MAP.get("ODU").get("If10GEODU2"));
189 LPN_MAP.get("ODU").put("If100GE", LPN_MAP.get("ODU").get("If100GEODU4"));
190 LPN_MAP.get("ODU").put("IfOCHOTU4ODU4", LPN_MAP.get("ODU").get("If100GEODU4"));
191 LPN_MAP.get("ODU").put("IfOCH", LPN_MAP.get("ODU").get("If100GEODU4"));
192 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOtsiOtucnOducn", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCHOTUCnODUCn"));
193 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTUCnODUCnRegen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCHOTUCnODUCn"));
195 .get("PHOTONIC_MEDIA").put("IfOCHOTUCnODUCnUniregen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCHOTUCnODUCn"));
196 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTU4ODU4", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCH"));
197 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTU4ODU4Regen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCH"));
198 LPN_MAP.get("PHOTONIC_MEDIA").put("IfOCHOTU4ODU4Uniregen", LPN_MAP.get("PHOTONIC_MEDIA").get("IfOCH"));
202 public ConvertORToTapiTopology(Uuid tapiTopoUuid) {
203 this.tapiTopoUuid = tapiTopoUuid;
204 this.tapiNodes = new HashMap<>();
205 this.tapiLinks = new HashMap<>();
206 this.uuidMap = new HashMap<>();
207 this.tapiSips = new HashMap<>();
210 public void convertNode(Node ietfNode, List<String> networkPorts) {
211 this.ietfNodeId = ietfNode.getNodeId().getValue();
213 ietfNode.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526.Node1.class);
214 if (ietfAug == null) {
217 this.ietfNodeType = ietfAug.getNodeType();
218 this.ietfNodeAdminState = ietfAug.getAdministrativeState();
219 this.ietfNodeOperState = ietfAug.getOperationalState();
221 ietfNode.augmentation(
222 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class);
223 this.oorNetworkPortList = ietfAugTopo.getTerminationPoint().values().stream()
224 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
225 == OpenroadmTpType.XPONDERNETWORK.getIntValue()
226 && networkPorts.contains(tp.getTpId().getValue()))
227 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
228 .collect(Collectors.toList());
229 if (OpenroadmNodeType.TPDR.equals(this.ietfNodeType)) {
230 this.oorOduSwitchingPool = createOduSwitchingPoolForTp100G();
231 List<TpId> tpList = this.oorOduSwitchingPool.getNonBlockingList().values().stream()
232 .flatMap(nbl -> nbl.getTpList().stream())
233 .collect(Collectors.toList());
234 this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
235 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
236 == OpenroadmTpType.XPONDERCLIENT.getIntValue()
237 && tpList.contains(tp.getTpId()))
238 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
239 .collect(Collectors.toList());
240 this.oorClientPortList.forEach(tp -> LOG.info("tp = {}", tp.getTpId()));
242 this.oorOduSwitchingPool = ietfNode.augmentation(Node1.class).getSwitchingPools().getOduSwitchingPools()
243 .values().stream().findFirst().orElseThrow();
244 this.oorClientPortList = ietfAugTopo.getTerminationPoint().values().stream()
245 .filter(tp -> tp.augmentation(TerminationPoint1.class).getTpType().getIntValue()
246 == OpenroadmTpType.XPONDERCLIENT.getIntValue())
247 .sorted((tp1, tp2) -> tp1.getTpId().getValue().compareTo(tp2.getTpId().getValue()))
248 .collect(Collectors.toList());
251 // node creation [DSR/ODU] ([DSR/ODU] and OTSI merged in R 2.4.X)
252 LOG.info("creation of a DSR/ODU node for {}", this.ietfNodeId);
253 String nodeIdXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
254 this.uuidMap.put(nodeIdXpdr,
256 new Uuid(UUID.nameUUIDFromBytes(nodeIdXpdr.getBytes(Charset.forName("UTF-8"))).toString()));
257 Name nameDsr = new NameBuilder().setValueName("dsr/odu node name").setValue(nodeIdXpdr).build();
258 Name namePhot = new NameBuilder().setValueName("otsi node name").setValue(nodeIdXpdr).build();
259 Name nameNodeType = new NameBuilder().setValueName("Node Type").setValue(this.ietfNodeType.getName()).build();
260 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
261 .topology.Node dsrNode =
263 Map.of(nameDsr.key(), nameDsr, namePhot.key(), namePhot,nameNodeType.key(), nameNodeType),
265 Set.of(LayerProtocolName.DSR, LayerProtocolName.ODU,
266 LayerProtocolName.DIGITALOTN, LayerProtocolName.PHOTONICMEDIA));
267 LOG.debug("XPDR Node {} should have {} NEPs and SIPs",
268 this.ietfNodeId, this.oorClientPortList.size() + this.oorNetworkPortList.size());
269 LOG.info("XPDR Node {} has {} NEPs and {} SIPs",
271 dsrNode.getOwnedNodeEdgePoint().values().size(),
272 dsrNode.getOwnedNodeEdgePoint().values().stream()
273 .filter(nep -> nep.getMappedServiceInterfacePoint() != null).count());
274 tapiNodes.put(dsrNode.key(), dsrNode);
277 public Map<NodeRuleGroupKey, NodeRuleGroup> createNodeRuleGroupForRdmNode(String topoType, Uuid nodeUuid,
278 String subNodeName, List<OwnedNodeEdgePointKey> onepl, FORWARDINGRULE forwardingRule, int index) {
279 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
280 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
281 nepMap = new HashMap<>();
282 for (OwnedNodeEdgePointKey onepKey : onepl) {
283 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint
284 nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group
285 .NodeEdgePointBuilder()
286 .setTopologyUuid(tapiTopoUuid)
287 .setNodeUuid(nodeUuid)
288 .setNodeEdgePointUuid(onepKey.getUuid())
290 nepMap.put(nep.key(), nep);
292 String nrgNameValue = String.join("-", subNodeName, "node-rule-group-" + index);
293 //Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupMap = new HashMap<>();
294 Set<RuleType> ruleTypes = new HashSet<>(Set.of(RuleType.FORWARDING));
295 Map<RuleKey, Rule> ruleList = new HashMap<>();
296 Rule rule = new RuleBuilder()
297 .setLocalId("forward")
298 .setForwardingRule(forwardingRule)
299 .setRuleType(ruleTypes)
301 ruleList.put(rule.key(), rule);
302 Name nrgName = new NameBuilder()
303 .setValueName("nrg name")
304 .setValue(nrgNameValue)
306 NodeRuleGroup nodeRuleGroup = new NodeRuleGroupBuilder()
307 .setName(Map.of(nrgName.key(), nrgName))
308 .setUuid(new Uuid(UUID.nameUUIDFromBytes((nrgNameValue)
309 .getBytes(Charset.forName("UTF-8"))).toString()))
311 .setNodeEdgePoint(nepMap)
313 return new HashMap<>(Map.of(nodeRuleGroup.key(), nodeRuleGroup));
316 public Map<NodeRuleGroupKey, NodeRuleGroup> createAllNodeRuleGroupForRdmNode(String topoType, Uuid nodeUuid,
317 String orNodeId, Collection<OwnedNodeEdgePoint> onepl) {
318 List<OwnedNodeEdgePoint> otsNepList = new ArrayList<>();
319 LOG.info("Creating NRG for {} {}", topoType, otsNepList.toString());
320 if (topoType.equals("T0ML")) {
321 otsNepList = onepl.stream().collect(Collectors.toList());
323 otsNepList = onepl.stream()
324 .filter(onep -> onep.getName().keySet().contains(new NameKey("PHOTONIC_MEDIA_OTSNodeEdgePoint")))
325 .collect(Collectors.toList());
327 List<OwnedNodeEdgePointKey> degOnepKeyList = new ArrayList<>();
328 List<String> srgNames = new ArrayList<>();
329 Map<OwnedNodeEdgePointKey,String> srgMap = new HashMap<>();
330 for (OwnedNodeEdgePoint onep : otsNepList) {
331 String onepName = onep.getName().get(new NameKey(
332 topoType.equals("T0ML") ? "NodeEdgePoint name"
333 : "PHOTONIC_MEDIA_OTSNodeEdgePoint")).getValue();
334 String subNodeName = topoType.equals("T0ML") ? "ROADMINFRA-SRG-PP"
335 : String.join("-", onepName.split("\\+")[0], onepName.split("\\+")[2]);
336 if (subNodeName.contains("DEG")) {
337 subNodeName = subNodeName.split("\\-TTP")[0];
338 degOnepKeyList.add(onep.key());
339 } else if (subNodeName.contains("SRG")) {
340 subNodeName = subNodeName.split("\\-PP")[0];
341 srgMap.put(onep.key(), subNodeName);
342 if (!srgNames.contains(subNodeName)) {
343 srgNames.add(subNodeName);
348 Map<NodeRuleGroupKey, NodeRuleGroup> globalNrgMap = new HashMap<>();
349 if (topoType.equals("Full")) {
351 createNodeRuleGroupForRdmNode(topoType, nodeUuid, String.join("-", orNodeId, "DEG"), degOnepKeyList,
352 FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE, index));
355 for (String srgName : srgNames) {
356 globalNrgMap.putAll(createNodeRuleGroupForRdmNode(topoType, nodeUuid, srgName,
357 srgMap.entrySet().stream()
358 .filter(item -> item.getValue().equals(srgName))
359 .map(item -> item.getKey())
360 .collect(Collectors.toList()),
361 // For T0ML we consider any port of ROADM INFRA can connect to potentially any other port
362 //topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
363 topoType.equals("T0ML") ? FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE
364 // Whereas for Abstracted or Full Topology we consider any port of the same SRG can not forward to
365 // another port of the same SRG. Connectivity between SRGS will be defined through inter-rule-group
366 : FORWARDINGRULECANNOTFORWARDACROSSGROUP.VALUE, index));
368 LOG.debug("AllNodeRuleGroup : creating a NRG for {}", srgName);
373 public Map<InterRuleGroupKey, InterRuleGroup> createInterRuleGroupForRdmNode(
374 String topoType, Uuid nodeUuid,String orNodeId, List<NodeRuleGroupKey> nrgList) {
375 Map<AssociatedNodeRuleGroupKey, AssociatedNodeRuleGroup> associatedNrgMap = new HashMap<>();
376 for (NodeRuleGroupKey nrgKey : nrgList) {
377 AssociatedNodeRuleGroup associatedNrg = new AssociatedNodeRuleGroupBuilder()
378 .setTopologyUuid(tapiTopoUuid)
379 .setNodeUuid(nodeUuid)
380 .setNodeRuleGroupUuid(nrgKey.getUuid())
382 associatedNrgMap.put(associatedNrg.key(), associatedNrg);
384 String irgNameValue =
385 topoType.equals("Full")
386 ? orNodeId + " inter rule group-"
387 : "rdm infra inter rule group-";
388 Set<RuleType> ruleTypes = new HashSet<>(Set.of(RuleType.FORWARDING));
389 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.RuleKey,
390 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.Rule> ruleMap
392 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.Rule rule
393 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.inter.rule.group.RuleBuilder()
394 .setLocalId("forward")
395 .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
396 .setRuleType(ruleTypes)
398 ruleMap.put(rule.key(), rule);
400 Map<InterRuleGroupKey, InterRuleGroup> interRuleGroupMap = new HashMap<>();
402 Name irgName = new NameBuilder()
403 .setValueName("irg name")
404 .setValue(irgNameValue)
406 InterRuleGroup interRuleGroup = new InterRuleGroupBuilder()
407 .setUuid(new Uuid(UUID.nameUUIDFromBytes((irgNameValue)
408 .getBytes(Charset.forName("UTF-8"))).toString()))
409 .setName(Map.of(irgName.key(), irgName))
411 .setAssociatedNodeRuleGroup(associatedNrgMap)
413 interRuleGroupMap.put(new InterRuleGroupKey(interRuleGroup.getUuid()), interRuleGroup);
414 return interRuleGroupMap;
417 public Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> createMSIP(int nb,
418 LayerProtocolName layerProtocol, String tpId, String nodeid,
419 Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
420 OperationalState operState, AdministrativeState adminState) {
421 // add them to SIP context
422 Map<MappedServiceInterfacePointKey, MappedServiceInterfacePoint> msipl = new HashMap<>();
423 for (int i = 0; i < nb; i++) {
426 ? String.join("+", "SIP", nodeid, tpId)
427 : String.join("+", "SIP", nodeid, tpId, "Nber", String.valueOf(i));
428 LOG.info("SIP = {}", sipName);
429 Uuid sipUuid = new Uuid(UUID.nameUUIDFromBytes(sipName.getBytes(Charset.forName("UTF-8"))).toString());
430 MappedServiceInterfacePoint msip = new MappedServiceInterfacePointBuilder()
431 .setServiceInterfacePointUuid(sipUuid)
433 ServiceInterfacePoint sip =
434 createSIP(sipUuid, layerProtocol, tpId, nodeid, supportedInterfaceCapability, operState, adminState);
435 this.tapiSips.put(sip.key(), sip);
436 msipl.put(msip.key(), msip);
437 LOG.debug("SIP created {}", sip.getUuid());
438 LOG.debug("This SIP corresponds to SIP+nodeId {} + TpId {}", nodeid, tpId);
443 public List<AvailablePayloadStructure> createAvailablePayloadStructureForPhtncMedia(
444 Boolean otsiProvisioned,
445 Collection<SupportedInterfaceCapability> sicList,
446 List<OperationalModeKey> supportedOpModes) {
447 if (supportedOpModes == null || supportedOpModes.isEmpty()) {
451 Integer loopRate = 0;
452 for (OperationalModeKey operationalMode : supportedOpModes) {
453 for (Map.Entry<Integer, String> entry: OPMODE_LOOPRATE_MAP.entrySet()) {
454 if (operationalMode.toString().contains(entry.getValue())) {
455 loopRate = entry.getKey();
459 if (loopRate > nepRate) {
461 if (nepRate >= OPMODE_LOOPRATE_MAX) {
466 List<AvailablePayloadStructure> aps = new ArrayList<>();
467 Integer cepInstanceNber = otsiProvisioned ? 0 : 1;
468 for (SupportedInterfaceCapability sic : sicList) {
469 switch (sic.getIfCapType().toString().split("\\{")[0]) {
470 case "IfOCHOTU4ODU4":
471 case "IfOCHOTU4ODU4Regen":
472 case "IfOCHOTU4ODU4Uniregen":
473 aps.add(new AvailablePayloadStructureBuilder()
474 .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
475 .setNumberOfCepInstances(Uint64.valueOf(cepInstanceNber))
477 new CapacityBuilder()
478 .setUnit(CAPACITYUNITGBPS.VALUE)
479 .setValue(Decimal64.valueOf(100.0 * cepInstanceNber, RoundingMode.DOWN))
483 case "IfOCHOTUCnODUCn":
484 case "IfOtsiOtucnOducn":
485 case "IfOCHOTUCnODUCnRegen":
486 case "IfOCHOTUCnODUCnUniregen":
487 aps.add(new AvailablePayloadStructureBuilder()
488 .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
489 ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
490 .setNumberOfCepInstances(Uint64.valueOf(nepRate * cepInstanceNber))
492 new CapacityBuilder()
493 .setUnit(CAPACITYUNITGBPS.VALUE)
494 .setValue(Decimal64.valueOf(nepRate * 100.0 * cepInstanceNber, RoundingMode.DOWN))
502 return aps.stream().distinct().toList();
505 public List<SupportedPayloadStructure> createSupportedPayloadStructureForPhtncMedia(
506 Collection<SupportedInterfaceCapability> sicList, List<OperationalModeKey> supportedOpModes) {
507 if (supportedOpModes == null || supportedOpModes.isEmpty()) {
511 Integer loopRate = 0;
512 for (OperationalModeKey operationalMode : supportedOpModes) {
513 for (Map.Entry<Integer, String> entry: OPMODE_LOOPRATE_MAP.entrySet()) {
514 if (operationalMode.toString().contains(entry.getValue())) {
515 loopRate = entry.getKey();
519 if (loopRate > nepRate) {
521 if (nepRate >= OPMODE_LOOPRATE_MAX) {
526 List<SupportedPayloadStructure> sps = new ArrayList<>();
527 for (SupportedInterfaceCapability sic : sicList) {
528 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
530 case "IfOCHOTU4ODU4":
531 case "IfOCHOTU4ODU4Regen":
532 case "IfOCHOTU4ODU4Uniregen":
533 sps.add(new SupportedPayloadStructureBuilder()
534 .setMultiplexingSequence(Set.of(PHOTONICLAYERQUALIFIEROTSi.VALUE, ODUTYPEODU4.VALUE))
535 .setNumberOfCepInstances(Uint64.valueOf(1))
537 new CapacityBuilder()
538 .setUnit(CAPACITYUNITGBPS.VALUE)
539 .setValue(Decimal64.valueOf(100.0, RoundingMode.DOWN))
543 case "IfOCHOTUCnODUCn":
544 case "IfOtsiOtucnOducn":
545 case "IfOCHOTUCnODUCnRegen":
546 case "IfOCHOTUCnODUCnUniregen":
547 sps.add(new SupportedPayloadStructureBuilder()
548 .setMultiplexingSequence(Set.of(
549 PHOTONICLAYERQUALIFIEROTSi.VALUE, OTUTYPEOTUCN.VALUE,
550 ODUTYPEODUCN.VALUE, ODUTYPEODU4.VALUE))
551 .setNumberOfCepInstances(Uint64.valueOf(nepRate))
553 new CapacityBuilder()
554 .setUnit(CAPACITYUNITGBPS.VALUE)
555 .setValue(Decimal64.valueOf(nepRate * 100.0, RoundingMode.DOWN))
563 return sps.stream().distinct().toList();
566 public List<SupportedCepLayerProtocolQualifierInstances> createSupportedCepLayerProtocolQualifier(
567 Collection<SupportedInterfaceCapability> sicList, LayerProtocolName lpn) {
568 if (sicList == null) {
569 return new ArrayList<>(List.of(
570 new SupportedCepLayerProtocolQualifierInstancesBuilder()
571 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
572 .setNumberOfCepInstances(Uint64.valueOf(1))
575 LOG.debug("SIC list = {}", sicList);
576 List<SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
577 String lpnName = lpn.getName();
578 for (SupportedInterfaceCapability sic : sicList) {
579 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
580 if (!LPN_MAP.containsKey(lpnName)) {
581 LOG.error("Layer Protocol Name is unknown {}", lpnName);
584 var ifCapTypeMap = LPN_MAP.get(lpnName);
585 if (!ifCapTypeMap.containsKey(ifCapType)) {
586 LOG.error("IfCapability type {} not managed", ifCapType);
589 for (LAYERPROTOCOLQUALIFIER qualifier: ifCapTypeMap.get(ifCapType).keySet()) {
590 sclpqiList.add(new SupportedCepLayerProtocolQualifierInstancesBuilder()
591 .setLayerProtocolQualifier(qualifier)
592 .setNumberOfCepInstances(Uint64.valueOf(1))
596 return sclpqiList.stream().distinct().toList();
599 public Map<Double, Double> getXpdrUsedWavelength(TerminationPoint tp) {
600 var tpAug = tp.augmentation(
601 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
602 if (tpAug == null || tpAug.getXpdrNetworkAttributes() == null) {
605 XpdrNetworkAttributes xnatt = tpAug.getXpdrNetworkAttributes();
606 //Map<Double,Double> freqWidthMap = new HashMap<>();
607 var xnattWvlgth = tpAug.getXpdrNetworkAttributes().getWavelength();
608 return xnattWvlgth == null || xnattWvlgth.getFrequency() == null || xnattWvlgth.getWidth() == null
610 : new HashMap<>(Map.of(
611 (xnatt.getWavelength().getFrequency().getValue().doubleValue()
612 - xnatt.getWavelength().getWidth().getValue().doubleValue() * 0.001 / 2),
613 (xnatt.getWavelength().getFrequency().getValue().doubleValue()
614 - xnatt.getWavelength().getWidth().getValue().doubleValue() * 0.001 / 2)));
617 public Map<Double, Double> getPPUsedWavelength(TerminationPoint tp) {
618 var tpAug = tp.augmentation(
619 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
623 PpAttributes ppAtt = tpAug.getPpAttributes();
627 if (ppAtt != null && ppAtt.getUsedWavelength() != null
628 && ppAtt.getUsedWavelength().entrySet().iterator().next() != null) {
629 Double centFreq = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency()
630 .getValue().doubleValue();
631 Double width = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getWidth()
632 .getValue().doubleValue();
633 return new HashMap<>(Map.of(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2));
638 public Map<Double, Double> getTTPUsedFreqMap(TerminationPoint tp) {
639 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
640 Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE);
641 var termPoint1 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
642 .TerminationPoint1.class);
643 if (termPoint1 == null || termPoint1.getTxTtpAttributes() == null) {
646 TxTtpAttributes txttpAtt = termPoint1.getTxTtpAttributes();
647 Map<Double,Double> freqMap = new HashMap<>();
648 if (txttpAtt.getUsedWavelengths() != null
649 && txttpAtt.getUsedWavelengths().entrySet().iterator().next() != null) {
650 for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas :
651 txttpAtt.getUsedWavelengths().entrySet()) {
652 Double centFreq = usedLambdas.getValue().getFrequency().getValue().doubleValue();
653 Double width = usedLambdas.getValue().getWidth()
654 .getValue().doubleValue();
655 freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
658 } else if (txttpAtt.getAvailFreqMaps() != null
659 && txttpAtt.getAvailFreqMaps().keySet().toString().contains(GridConstant.C_BAND)) {
660 byte[] freqBitSet = new byte[GridConstant.NB_OCTECTS];
661 LOG.debug("Creation of Bitset {}", freqBitSet);
662 freqBitSet = txttpAtt.getAvailFreqMaps().entrySet().stream()
663 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
664 .findFirst().orElseThrow().getValue().getFreqMap();
665 for (int i = 0; i < GridConstant.EFFECTIVE_BITS; i++) {
666 if (freqBitSet[i] == 0) {
672 return getFreqMapFromBitSet(freqBitSet);
678 public Map<Double, Double> getTTPAvailableFreqMap(TerminationPoint tp) {
679 var termPoint1 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526
680 .TerminationPoint1.class);
681 if (termPoint1 == null || termPoint1.getTxTtpAttributes() == null
682 || termPoint1.getTxTtpAttributes().getAvailFreqMaps() == null
683 || !(termPoint1.getTxTtpAttributes().getAvailFreqMaps().keySet().toString()
684 .contains(GridConstant.C_BAND))) {
687 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
688 LOG.debug("Creation of Bitset {}", byteArray);
689 return getFreqMapFromBitSet(
690 termPoint1.getTxTtpAttributes().getAvailFreqMaps().entrySet().stream()
691 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
692 .findFirst().orElseThrow().getValue().getFreqMap());
695 public Map<Double, Double> getTTP11AvailableFreqMap(
696 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
697 if (tp == null || tp.getTxTtpAttributes() == null
698 || tp.getTxTtpAttributes().getAvailFreqMaps() == null
699 || !(tp.getTxTtpAttributes().getAvailFreqMaps().keySet().toString()
700 .contains(GridConstant.C_BAND))) {
703 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
704 LOG.debug("Creation of Bitset {}", byteArray);
705 return getFreqMapFromBitSet(
706 tp.getTxTtpAttributes().getAvailFreqMaps().entrySet().stream()
707 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
708 .findFirst().orElseThrow().getValue().getFreqMap());
711 public Map<Double, Double> getPP11UsedWavelength(
712 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
713 if (tp == null || tp.getPpAttributes() == null
714 || tp.getPpAttributes().getUsedWavelength() == null
715 || tp.getPpAttributes().getUsedWavelength().entrySet().iterator().next() == null) {
718 PpAttributes ppAtt = tp.getPpAttributes();
719 Map<Double,Double> freqMap = new HashMap<>();
720 Double centFreq = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getFrequency()
721 .getValue().doubleValue();
722 Double width = ppAtt.getUsedWavelength().entrySet().iterator().next().getValue().getWidth()
723 .getValue().doubleValue();
724 freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
728 public Map<Double, Double> getTTP11UsedFreqMap(
729 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1 tp) {
730 byte[] byteArray = new byte[GridConstant.NB_OCTECTS];
731 Arrays.fill(byteArray, (byte) GridConstant.AVAILABLE_SLOT_VALUE);
732 if (tp == null || tp.getTxTtpAttributes() == null) {
735 TxTtpAttributes txttpAtt = tp.getTxTtpAttributes();
736 Map<Double,Double> freqMap = new HashMap<>();
737 if (txttpAtt.getUsedWavelengths() != null
738 && txttpAtt.getUsedWavelengths().entrySet().iterator().next() != null) {
739 for (Map.Entry<UsedWavelengthsKey, UsedWavelengths> usedLambdas :
740 txttpAtt.getUsedWavelengths().entrySet()) {
741 Double centFreq = usedLambdas.getValue().getFrequency().getValue().doubleValue();
742 Double width = usedLambdas.getValue().getWidth()
743 .getValue().doubleValue();
744 freqMap.put(centFreq - width * 0.001 / 2, centFreq + width * 0.001 / 2);
747 } else if (txttpAtt.getAvailFreqMaps() != null
748 && txttpAtt.getAvailFreqMaps().keySet().toString().contains(GridConstant.C_BAND)) {
749 byte[] freqBitSet = new byte[GridConstant.NB_OCTECTS];
750 LOG.debug("Creation of Bitset {}", freqBitSet);
751 freqBitSet = txttpAtt.getAvailFreqMaps().entrySet().stream()
752 .filter(afm -> afm.getKey().toString().equals(GridConstant.C_BAND))
753 .findFirst().orElseThrow().getValue().getFreqMap();
754 for (int i = 0; i < GridConstant.EFFECTIVE_BITS; i++) {
755 if (freqBitSet[i] == 0) {
761 return getFreqMapFromBitSet(freqBitSet);
767 public Map<Double, Double> getFreqMapFromBitSet(byte[] byteArray) {
768 // Provides a Map <LowerFreq, HigherFreq> describing start and stop frequencies of all slots that are available
769 // in the ByteArray describing the spectrum : bit sets initially sets to 1/true
770 // In case the byte array has been inverted before calling this method, it provides respectively a map
771 // describing all occupied slots!
772 Map<Double,Double> freqMap = new HashMap<>();
773 Double startFreq = GridConstant.START_EDGE_FREQUENCY;
774 Double stopFreq = 0.0;
775 boolean occupied = false;
776 if (byteArray[0] == 0) {
779 for (int index = 0 ; index < GridConstant.EFFECTIVE_BITS ; index++) {
780 if (byteArray[index] == 1 && occupied) {
781 startFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
782 stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
784 } else if (byteArray[index] == 0 && !occupied) {
785 stopFreq = GridUtils.getStartFrequencyFromIndex(index).doubleValue();
788 if (stopFreq.doubleValue() > startFreq.doubleValue() && occupied) {
789 freqMap.put(startFreq, stopFreq);
790 startFreq = stopFreq;
792 if ((index == GridConstant.EFFECTIVE_BITS - 1) && (startFreq.doubleValue() == stopFreq.doubleValue())
794 stopFreq = GridUtils.getStopFrequencyFromIndex(index).doubleValue();
795 freqMap.put(startFreq, stopFreq);
801 public OwnedNodeEdgePointBuilder addPayloadStructureAndPhotSpecToOnep(String nodeId,
802 Map<Double, Double> freqMap, List<OperationalModeKey> operModeList,
803 Collection<SupportedInterfaceCapability> sicColl, OwnedNodeEdgePointBuilder onepBldr, String keyword) {
804 if (String.join("+", nodeId, TapiStringConstants.OTSI_MC).equals(keyword)
805 || String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)) {
806 LOG.debug("Entering LOOP Step1");
807 // Creating OTS & OTSI_MC NEP specific attributes
808 onepBldr.setSupportedPayloadStructure(createSupportedPayloadStructureForPhtncMedia(
809 sicColl,operModeList));
810 SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
811 OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
812 if (freqMap == null || freqMap.isEmpty()) {
813 // TODO: verify if we need to fill OcupiedSpectrum as follows when no lambda provisioned
815 // .setUpperFrequency(Uint64.valueOf(0))
816 // .setLowerFrequency(Uint64.valueOf(0));
817 onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
818 false, sicColl,operModeList));
820 AvailableSpectrum aspec = new AvailableSpectrumBuilder()
821 .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz)))
822 .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
823 + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz)))
825 Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
826 aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
827 aspec.getUpperFrequency()), aspec);
828 spectrumPac.setAvailableSpectrum(aspecMap);
830 LOG.debug("Entering LOOP Step2");
831 onepBldr.setAvailablePayloadStructure(createAvailablePayloadStructureForPhtncMedia(
832 true, sicColl,operModeList));
833 Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
834 for (Map.Entry<Double, Double> frequency : freqMap.entrySet()) {
836 .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
837 .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
839 OccupiedSpectrum ospec = ospecBd.build();
840 ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(), ospec.getUpperFrequency()), ospec);
841 spectrumPac.setOccupiedSpectrum(ospecMap);
843 LOG.debug("Entering LOOP Step3");
845 SupportableSpectrum sspec = new SupportableSpectrumBuilder()
846 .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + nazz)))
847 .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
848 + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + nazz)))
850 Map<SupportableSpectrumKey, SupportableSpectrum> sspecMap = new HashMap<>();
851 sspecMap.put(new SupportableSpectrumKey(sspec.getLowerFrequency(),
852 sspec.getUpperFrequency()), sspec);
853 spectrumPac.setSupportableSpectrum(sspecMap);
854 LOG.debug("Entering LOOP Step4");
855 PhotonicMediaNodeEdgePointSpec pnepSpec = new PhotonicMediaNodeEdgePointSpecBuilder()
856 .setSpectrumCapabilityPac(spectrumPac.build())
858 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1 onep1 =
859 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
860 .OwnedNodeEdgePoint1Builder()
861 .setPhotonicMediaNodeEdgePointSpec(pnepSpec)
863 LOG.debug("creating Photonic NEP SPEC for node {} and nep {}", nodeId, onep1);
864 onepBldr.addAugmentation(onep1);
865 LOG.debug("Entering LOOP Step5");
871 public OwnedNodeEdgePointBuilder addPhotSpecToRoadmOnep(String nodeId,
872 Map<Double, Double> usedFreqMap, Map<Double, Double> availableFreqMap,
873 OwnedNodeEdgePointBuilder onepBldr, String keyword) {
874 if (String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OTS).equals(keyword)
875 || String.join("+", nodeId, TapiStringConstants.PHTNC_MEDIA_OMS).equals(keyword)) {
876 // Creating OTS/OMS NEP specific attributes
877 SpectrumCapabilityPacBuilder spectrumPac = new SpectrumCapabilityPacBuilder();
878 if ((usedFreqMap == null || usedFreqMap.isEmpty())
879 && (availableFreqMap == null || availableFreqMap.isEmpty())) {
881 AvailableSpectrum aspec = new AvailableSpectrumBuilder()
882 .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + naz)))
883 .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
884 + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + naz)))
886 Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
887 aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
888 aspec.getUpperFrequency()), aspec);
889 spectrumPac.setAvailableSpectrum(aspecMap);
891 if (availableFreqMap != null && !availableFreqMap.isEmpty()) {
892 Map<AvailableSpectrumKey, AvailableSpectrum> aspecMap = new HashMap<>();
893 AvailableSpectrumBuilder aspecBd = new AvailableSpectrumBuilder();
894 for (Map.Entry<Double, Double> frequency : availableFreqMap.entrySet()) {
896 .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
897 .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
898 AvailableSpectrum aspec = aspecBd.build();
899 aspecMap.put(new AvailableSpectrumKey(aspec.getLowerFrequency(),
900 aspec.getUpperFrequency()), aspec);
902 spectrumPac.setAvailableSpectrum(aspecMap);
904 if (usedFreqMap != null && !usedFreqMap.isEmpty()) {
905 Map<OccupiedSpectrumKey, OccupiedSpectrum> ospecMap = new HashMap<>();
906 OccupiedSpectrumBuilder ospecBd = new OccupiedSpectrumBuilder();
907 for (Map.Entry<Double, Double> frequency : usedFreqMap.entrySet()) {
909 .setLowerFrequency(Uint64.valueOf(Math.round(frequency.getKey().doubleValue() * 1E09)))
910 .setUpperFrequency(Uint64.valueOf(Math.round(frequency.getValue().doubleValue() * 1E09)));
911 OccupiedSpectrum ospec = ospecBd.build();
912 ospecMap.put(new OccupiedSpectrumKey(ospec.getLowerFrequency(),
913 ospec.getUpperFrequency()), ospec);
915 spectrumPac.setOccupiedSpectrum(ospecMap);
919 SupportableSpectrum sspec = new SupportableSpectrumBuilder()
920 .setLowerFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09 + nazz)))
921 .setUpperFrequency(Uint64.valueOf(Math.round(GridConstant.START_EDGE_FREQUENCY * 1E09
922 + GridConstant.GRANULARITY * GridConstant.EFFECTIVE_BITS * 1E06 + nazz)))
924 Map<SupportableSpectrumKey, SupportableSpectrum> sspecMap = new HashMap<>();
925 sspecMap.put(new SupportableSpectrumKey(sspec.getLowerFrequency(),
926 sspec.getUpperFrequency()), sspec);
927 spectrumPac.setSupportableSpectrum(sspecMap);
929 PhotonicMediaNodeEdgePointSpec pnepSpec = new PhotonicMediaNodeEdgePointSpecBuilder()
930 .setSpectrumCapabilityPac(spectrumPac.build())
932 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121.OwnedNodeEdgePoint1 onep1 =
933 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.photonic.media.rev221121
934 .OwnedNodeEdgePoint1Builder()
935 .setPhotonicMediaNodeEdgePointSpec(pnepSpec)
937 onepBldr.addAugmentation(onep1);
938 LOG.debug("Add Photonic Node Edge point Spec to {} including available Spectrum {} = ",
940 onep1.getPhotonicMediaNodeEdgePointSpec().getSpectrumCapabilityPac().getAvailableSpectrum());
945 private OduSwitchingPools createOduSwitchingPoolForTp100G() {
946 Map<NonBlockingListKey, NonBlockingList> nblMap = new HashMap<>();
948 for (TerminationPoint tp : this.oorNetworkPortList) {
949 NonBlockingList nbl = new NonBlockingListBuilder()
950 .setNblNumber(Uint16.valueOf(count))
951 .setTpList(new HashSet<>(Set.of(
953 tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev230526
954 .TerminationPoint1.class)
955 .getAssociatedConnectionMapTp().iterator().next())))
957 nblMap.put(nbl.key(), nbl);
960 return new OduSwitchingPoolsBuilder()
961 .setNonBlockingList(nblMap)
962 .setSwitchingPoolNumber(Uint16.valueOf(1))
966 private org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node createTapiNode(
967 Map<NameKey, Name> nodeNames, Set<LayerProtocolName> layerProtocols) {
968 Uuid nodeUuid = null;
969 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl = new HashMap<>();
970 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList = new HashMap<>();
971 if (layerProtocols.contains(LayerProtocolName.DSR)
972 || layerProtocols.contains(LayerProtocolName.PHOTONICMEDIA)) {
973 Rule rule = new RuleBuilder()
974 .setLocalId("forward")
975 .setForwardingRule(FORWARDINGRULEMAYFORWARDACROSSGROUP.VALUE)
976 .setRuleType(new HashSet<>(Set.of(RuleType.FORWARDING)))
978 nodeUuid = getNodeUuid4Dsr(onepl, nodeRuleGroupList, new HashMap<>(Map.of(rule.key(), rule)));
980 LOG.error("Undefined LayerProtocolName for {} node {}",
981 nodeNames.get(nodeNames.keySet().iterator().next()).getValueName(),
982 nodeNames.get(nodeNames.keySet().iterator().next()).getValue());
984 // Empty random creation of mandatory fields for avoiding errors....
985 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
986 .setCostAlgorithm("Restricted Shortest Path - RSP")
987 .setCostName("HOP_COUNT")
988 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
990 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
991 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
992 .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
993 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
994 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
995 .setTrafficPropertyName("FIXED_LATENCY")
997 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
998 .setRiskCharacteristicName("risk characteristic")
999 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1001 return new NodeBuilder()
1004 .setLayerProtocolName(layerProtocols)
1005 .setAdministrativeState(transformAsToTapiAdminState(this.ietfNodeAdminState.getName()))
1006 .setOperationalState(transformOsToTapiOperationalState(this.ietfNodeOperState.getName()))
1007 .setLifecycleState(LifecycleState.INSTALLED)
1008 .setOwnedNodeEdgePoint(onepl)
1009 .setNodeRuleGroup(nodeRuleGroupList)
1010 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1011 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1012 .setRiskParameterPac(
1013 new RiskParameterPacBuilder()
1014 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1016 .setErrorCharacteristic("error")
1017 .setLossCharacteristic("loss")
1018 .setRepeatDeliveryCharacteristic("repeat delivery")
1019 .setDeliveryOrderCharacteristic("delivery order")
1020 .setUnavailableTimeCharacteristic("unavailable time")
1021 .setServerIntegrityProcessCharacteristic("server integrity process")
1025 private Uuid getNodeUuid4Dsr(
1026 Map<OwnedNodeEdgePointKey, OwnedNodeEdgePoint> onepl,
1027 Map<NodeRuleGroupKey, NodeRuleGroup> nodeRuleGroupList,
1028 Map<RuleKey, Rule> ruleList) {
1029 // client NEP DSR creation on DSR/ODU node
1030 for (int i = 0; i < oorClientPortList.size(); i++) {
1031 String nodeIdDsr = String.join("+",
1032 this.ietfNodeId, TapiStringConstants.DSR, oorClientPortList.get(i).getTpId().getValue());
1033 Uuid nepUuid = new Uuid(UUID.nameUUIDFromBytes(nodeIdDsr.getBytes(Charset.forName("UTF-8"))).toString());
1034 LOG.info("NEP = {} has Uuid {} ", nodeIdDsr, nepUuid);
1035 this.uuidMap.put(nodeIdDsr, nepUuid);
1036 Name name = new NameBuilder()
1037 .setValue(nodeIdDsr)
1038 .setValueName(OpenroadmNodeType.TPDR.equals(this.ietfNodeType) ? "100G-tpdr" : "NodeEdgePoint_C")
1040 OwnedNodeEdgePoint onep = createNep(
1041 oorClientPortList.get(i),
1042 Map.of(name.key(), name),
1043 LayerProtocolName.DSR, LayerProtocolName.DSR, true,
1044 String.join("+", this.ietfNodeId, TapiStringConstants.DSR));
1045 onepl.put(onep.key(), onep);
1047 // CLIENT NEP E_ODU creation on DSR/ODU node
1048 for (int i = 0; i < oorClientPortList.size(); i++) {
1049 String nodeIdEodu = String.join("+",
1050 this.ietfNodeId, TapiStringConstants.E_ODU, oorClientPortList.get(i).getTpId().getValue());
1051 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdEodu.getBytes(Charset.forName("UTF-8"))).toString());
1052 LOG.info("NEP = {} has Uuid {} ", nodeIdEodu, nepUuid1);
1053 this.uuidMap.put(nodeIdEodu, nepUuid1);
1054 Name onedName = new NameBuilder()
1055 .setValueName("eNodeEdgePoint_N")
1056 .setValue(nodeIdEodu)
1058 OwnedNodeEdgePoint onep = createNep(
1059 oorClientPortList.get(i),
1060 Map.of(onedName.key(), onedName),
1061 LayerProtocolName.ODU, LayerProtocolName.DSR, false,
1062 String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU));
1063 onepl.put(onep.key(), onep);
1065 // NETWORK NEPs I_ODU creation on DSR/ODU node
1066 for (int i = 0; i < oorNetworkPortList.size(); i++) {
1067 String nodeIdIodu = String.join("+",
1068 this.ietfNodeId, TapiStringConstants.I_ODU, oorNetworkPortList.get(i).getTpId().getValue());
1069 Uuid nepUuid1 = new Uuid(UUID.nameUUIDFromBytes(nodeIdIodu.getBytes(Charset.forName("UTF-8"))).toString());
1070 LOG.info("NEP = {} has Uuid {} ", nodeIdIodu, nepUuid1);
1071 this.uuidMap.put(nodeIdIodu, nepUuid1);
1072 Name onedName = new NameBuilder()
1073 .setValueName("iNodeEdgePoint_N")
1074 .setValue(nodeIdIodu)
1076 OwnedNodeEdgePoint onep = createNep(
1077 oorNetworkPortList.get(i),
1078 Map.of(onedName.key(), onedName),
1079 LayerProtocolName.ODU, LayerProtocolName.DSR, true,
1080 String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU));
1081 onepl.put(onep.key(), onep);
1083 // NETWORK NEP OTS network on DSR/ODU node
1084 for (int i = 0; i < oorNetworkPortList.size(); i++) {
1085 String nodeIdPmOts = String.join("+",
1086 this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS, oorNetworkPortList.get(i).getTpId().getValue());
1087 Uuid nepUuid2 = new Uuid(UUID.nameUUIDFromBytes(nodeIdPmOts.getBytes(Charset.forName("UTF-8"))).toString());
1088 LOG.info("NEP = {} has Uuid {} ", nodeIdPmOts, nepUuid2);
1089 this.uuidMap.put(nodeIdPmOts, nepUuid2);
1090 Name onedName = new NameBuilder()
1091 .setValueName("eNodeEdgePoint")
1092 .setValue(nodeIdPmOts)
1094 OwnedNodeEdgePoint onep = createNep(
1095 oorNetworkPortList.get(i),
1096 Map.of(onedName.key(), onedName),
1097 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
1098 String.join("+", this.ietfNodeId, TapiStringConstants.PHTNC_MEDIA_OTS));
1099 onepl.put(onep.key(), onep);
1101 for (int i = 0; i < oorNetworkPortList.size(); i++) {
1102 String nodeIdOtMc = String.join("+",
1103 this.ietfNodeId, TapiStringConstants.OTSI_MC, oorNetworkPortList.get(i).getTpId().getValue());
1104 Uuid nepUuid3 = new Uuid(UUID.nameUUIDFromBytes(nodeIdOtMc.getBytes(Charset.forName("UTF-8"))).toString());
1105 LOG.info("NEP = {} has Uuid {} ", nodeIdOtMc, nepUuid3);
1106 this.uuidMap.put(nodeIdOtMc, nepUuid3);
1107 Name onedName = new NameBuilder()
1108 .setValueName("PhotMedNodeEdgePoint")
1109 .setValue(nodeIdOtMc)
1111 OwnedNodeEdgePoint onep = createNep(
1112 oorNetworkPortList.get(i),
1113 Map.of(onedName.key(), onedName),
1114 LayerProtocolName.PHOTONICMEDIA, LayerProtocolName.PHOTONICMEDIA, true,
1115 String.join("+", this.ietfNodeId, TapiStringConstants.OTSI_MC));
1116 onepl.put(onep.key(), onep);
1118 // create NodeRuleGroup
1120 LOG.debug("ODU switching pool = {}", this.oorOduSwitchingPool.nonnullNonBlockingList().values());
1121 String ietfXpdr = String.join("+", this.ietfNodeId, TapiStringConstants.XPDR);
1122 for (NonBlockingList nbl : this.oorOduSwitchingPool.nonnullNonBlockingList().values()) {
1123 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
1124 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
1125 nepList = new HashMap<>();
1126 Map<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePointKey,
1127 org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.node.rule.group.NodeEdgePoint>
1128 oduNepList = new HashMap<>();
1129 LOG.debug("UUidMap={}", this.uuidMap.keySet());
1130 LOG.debug("TP list = {}", nbl.getTpList());
1131 for (TpId tp : nbl.getTpList()) {
1132 LOG.debug("TP={}", tp.getValue());
1133 String ietfEoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.E_ODU, tp.getValue());
1134 LOG.debug("UuidKey={}", ietfEoduTp);
1135 String ietfIoduTp = String.join("+", this.ietfNodeId, TapiStringConstants.I_ODU, tp.getValue());
1136 if (this.uuidMap.containsKey(String.join("+", this.ietfNodeId, TapiStringConstants.DSR, tp.getValue()))
1137 || this.uuidMap.containsKey(ietfIoduTp)) {
1138 String qual = tp.getValue().contains("CLIENT")
1139 ? TapiStringConstants.DSR : TapiStringConstants.I_ODU;
1140 var nep = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1141 .node.rule.group.NodeEdgePointBuilder()
1142 .setTopologyUuid(tapiTopoUuid)
1143 .setNodeUuid(this.uuidMap.get(ietfXpdr))
1144 .setNodeEdgePointUuid(this.uuidMap.get(
1145 String.join("+", this.ietfNodeId, qual, tp.getValue())))
1147 nepList.put(nep.key(), nep);
1149 if (this.uuidMap.containsKey(ietfEoduTp)) {
1150 var nep1 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1151 .node.rule.group.NodeEdgePointBuilder()
1152 .setTopologyUuid(tapiTopoUuid)
1153 .setNodeUuid(this.uuidMap.get(ietfXpdr))
1154 .setNodeEdgePointUuid(this.uuidMap.get(ietfEoduTp))
1156 oduNepList.put(nep1.key(), nep1);
1158 if (this.uuidMap.containsKey(ietfIoduTp)) {
1159 // TODO already checked with DSR above -> potential factorization ?
1160 var nep2 = new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121
1161 .node.rule.group.NodeEdgePointBuilder()
1162 .setTopologyUuid(tapiTopoUuid)
1163 .setNodeUuid(this.uuidMap.get(ietfXpdr))
1164 .setNodeEdgePointUuid(this.uuidMap.get(ietfIoduTp))
1166 oduNepList.put(nep2.key(), nep2);
1169 LOG.debug("NEPLIST (DSR/I_ODU) of [dsr node rule group] is {}", nepList);
1170 LOG.debug("NEPLIST (E_ODU/I_ODU) of [odu node rule group] is {}", nepList);
1171 // Empty random creation of mandatory fields for avoiding errors....
1172 CostCharacteristic costCharacteristic = new CostCharacteristicBuilder()
1173 .setCostAlgorithm("Restricted Shortest Path - RSP")
1174 .setCostName("HOP_COUNT")
1175 .setCostValue(TapiStringConstants.COST_HOP_VALUE)
1177 LatencyCharacteristic latencyCharacteristic = new LatencyCharacteristicBuilder()
1178 .setFixedLatencyCharacteristic(TapiStringConstants.FIXED_LATENCY_VALUE)
1179 .setQueuingLatencyCharacteristic(TapiStringConstants.QUEING_LATENCY_VALUE)
1180 .setJitterCharacteristic(TapiStringConstants.JITTER_VALUE)
1181 .setWanderCharacteristic(TapiStringConstants.WANDER_VALUE)
1182 .setTrafficPropertyName("FIXED_LATENCY")
1184 RiskCharacteristic riskCharacteristic = new RiskCharacteristicBuilder()
1185 .setRiskCharacteristicName("risk characteristic")
1186 .setRiskIdentifierList(Set.of("risk identifier1", "risk identifier2"))
1188 Name nrgName = new NameBuilder()
1189 .setValueName("nrg name")
1190 .setValue("odu node rule group " + count)
1192 NodeRuleGroup nodeRuleGroup1 = new NodeRuleGroupBuilder()
1193 .setName(Map.of(nrgName.key(), nrgName))
1194 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("dsr node rule group " + count)
1195 .getBytes(Charset.forName("UTF-8"))).toString()))
1197 .setNodeEdgePoint(nepList)
1198 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1199 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1200 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1202 nodeRuleGroupList.put(nodeRuleGroup1.key(), nodeRuleGroup1);
1203 NodeRuleGroup nodeRuleGroup2 = new NodeRuleGroupBuilder()
1204 .setUuid(new Uuid(UUID.nameUUIDFromBytes(("odu node rule group " + count)
1205 .getBytes(Charset.forName("UTF-8"))).toString()))
1207 .setNodeEdgePoint(oduNepList)
1208 .setRiskCharacteristic(Map.of(riskCharacteristic.key(), riskCharacteristic))
1209 .setCostCharacteristic(Map.of(costCharacteristic.key(), costCharacteristic))
1210 .setLatencyCharacteristic(Map.of(latencyCharacteristic.key(), latencyCharacteristic))
1212 nodeRuleGroupList.put(nodeRuleGroup2.key(), nodeRuleGroup2);
1215 return this.uuidMap.get(ietfXpdr);
1218 private OwnedNodeEdgePoint createNep(TerminationPoint oorTp, Map<NameKey, Name> nepNames,
1219 LayerProtocolName nepProtocol, LayerProtocolName nodeProtocol, boolean withSip, String keyword) {
1220 var tp1 = oorTp.augmentation(
1221 org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev230526.TerminationPoint1.class);
1222 if (tp1.getTpSupportedInterfaces() == null) {
1223 LOG.warn("Tp supported interface doesnt exist on TP {}", oorTp.getTpId().getValue());
1226 AdministrativeState adminState =
1227 oorTp.augmentation(TerminationPoint1.class).getAdministrativeState() == null
1229 : transformAsToTapiAdminState(
1230 oorTp.augmentation(TerminationPoint1.class).getAdministrativeState().getName());
1231 OperationalState operState =
1232 oorTp.augmentation(TerminationPoint1.class).getOperationalState() == null
1234 : transformOsToTapiOperationalState(
1235 oorTp.augmentation(TerminationPoint1.class).getOperationalState().getName());
1236 Collection<SupportedInterfaceCapability> sicColl =
1237 tp1.getTpSupportedInterfaces().getSupportedInterfaceCapability().values();
1238 OwnedNodeEdgePointBuilder onepBldr = new OwnedNodeEdgePointBuilder()
1239 .setUuid(this.uuidMap.get(String.join("+", keyword, oorTp.getTpId().getValue())))
1240 .setLayerProtocolName(nepProtocol)
1242 .setSupportedCepLayerProtocolQualifierInstances(
1243 createSupportedCepLayerProtocolQualifier(sicColl, nepProtocol))
1244 .setDirection(Direction.BIDIRECTIONAL)
1245 .setLinkPortRole(PortRole.SYMMETRIC)
1246 .setAdministrativeState(adminState)
1247 .setOperationalState(operState)
1248 .setLifecycleState(LifecycleState.INSTALLED);
1250 onepBldr.setMappedServiceInterfacePoint(
1251 createMSIP(1, nepProtocol, oorTp.getTpId().getValue(), keyword, sicColl, operState, adminState));
1253 if (oorTp.augmentation(TerminationPoint1.class).getTpType().equals(OpenroadmTpType.XPONDERNETWORK)) {
1254 List<OperationalModeKey> opModeList = new ArrayList<>();
1255 var tp11 = oorTp.augmentation(
1256 org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.rev230526.TerminationPoint1.class);
1257 if (tp11 == null || tp11.getXpdrNetworkAttributes() == null) {
1258 for (SupportedInterfaceCapability sic : sicColl) {
1259 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1260 if (("IfOCHOTUCnODUCn").equals(ifCapType) || ("IfOCHOTUCnODUCnUniregen").equals(ifCapType)
1261 || ("IfOCHOTUCnODUCnRegen").equals(ifCapType)) {
1262 opModeList.add(new OperationalModeKey("400G"));
1263 LOG.warn(TopologyUtils.NOOPMODEDECLARED + "400G rate available", oorTp.getTpId());
1267 opModeList.add(new OperationalModeKey("100G"));
1268 LOG.warn(TopologyUtils.NOOPMODEDECLARED + "100G rate available", oorTp.getTpId());
1270 opModeList = tp11.getXpdrNetworkAttributes().getSupportedOperationalModes().getOperationalMode()
1271 .keySet().stream().toList();
1273 onepBldr = addPayloadStructureAndPhotSpecToOnep(
1274 this.ietfNodeId, getXpdrUsedWavelength(oorTp), opModeList, sicColl, onepBldr, keyword);
1276 LOG.debug("ConvertORToTapiTopology 1360, onep = {}", onepBldr.build());
1277 return onepBldr.build();
1280 private ServiceInterfacePoint createSIP(Uuid sipUuid, LayerProtocolName layerProtocol, String tpId,
1281 String nodeid, Collection<SupportedInterfaceCapability> supportedInterfaceCapability,
1282 OperationalState operState, AdministrativeState adminState) {
1283 // TODO: what value should be set in total capacity and available capacity??
1284 LOG.debug("SIP name = {}", String.join("+", nodeid, tpId));
1285 Name sipName = new NameBuilder()
1286 .setValueName("SIP name")
1287 .setValue(String.join("+", nodeid, tpId))
1289 return new ServiceInterfacePointBuilder()
1291 .setName(Map.of(sipName.key(), sipName))
1292 .setLayerProtocolName(layerProtocol)
1293 .setAdministrativeState(adminState)
1294 .setOperationalState(operState)
1295 .setLifecycleState(LifecycleState.INSTALLED)
1296 .setAvailableCapacity(new AvailableCapacityBuilder().build())
1297 .setTotalPotentialCapacity(new TotalPotentialCapacityBuilder().build())
1298 .setSupportedCepLayerProtocolQualifierInstances(createSipSupportedLayerProtocolQualifier(
1299 supportedInterfaceCapability, layerProtocol))
1303 private List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1304 .service._interface.point.SupportedCepLayerProtocolQualifierInstances>
1305 createSipSupportedLayerProtocolQualifier(
1306 Collection<SupportedInterfaceCapability> supportedInterfaceCapability, LayerProtocolName lpn) {
1307 if (supportedInterfaceCapability == null) {
1308 return new ArrayList<>(List.of(new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1309 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1310 .setLayerProtocolQualifier(PHOTONICLAYERQUALIFIEROTS.VALUE)
1311 .setNumberOfCepInstances(Uint64.valueOf(1))
1314 List<org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1315 .service._interface.point.SupportedCepLayerProtocolQualifierInstances> sclpqiList = new ArrayList<>();
1316 String lpnName = lpn.getName();
1317 for (SupportedInterfaceCapability sic : supportedInterfaceCapability) {
1318 String ifCapType = sic.getIfCapType().toString().split("\\{")[0];
1319 if (!LPN_MAP.containsKey(lpnName)) {
1320 LOG.error("Layer Protocol Name is unknown {}", lpnName);
1323 var ifCapTypeMap = LPN_MAP.get(lpnName);
1324 if (!ifCapTypeMap.containsKey(ifCapType)) {
1325 LOG.error("IfCapability type {} not managed", ifCapType);
1328 for (Map.Entry<LAYERPROTOCOLQUALIFIER, Uint64> entry: ifCapTypeMap.get(ifCapType).entrySet()) {
1330 new org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121
1331 .service._interface.point.SupportedCepLayerProtocolQualifierInstancesBuilder()
1332 .setLayerProtocolQualifier(entry.getKey())
1333 .setNumberOfCepInstances(entry.getValue())
1337 return sclpqiList.stream().distinct().toList();
1340 public Map<NodeKey, org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.topology.Node>
1345 public Map<LinkKey, Link> getTapiLinks() {
1349 public AdministrativeState transformAsToTapiAdminState(String adminState) {
1350 return adminState == null
1352 : adminState.equals(AdminStates.InService.getName())
1353 || adminState.equals(AdministrativeState.UNLOCKED.getName())
1354 ? AdministrativeState.UNLOCKED : AdministrativeState.LOCKED;
1357 public OperationalState transformOsToTapiOperationalState(String operState) {
1358 return operState == null
1360 : operState.equals("inService") || operState.equals(OperationalState.ENABLED.getName())
1361 ? OperationalState.ENABLED : OperationalState.DISABLED;
1364 public Map<ServiceInterfacePointKey, ServiceInterfacePoint> getTapiSips() {
1368 public void setTapiSips(Map<ServiceInterfacePointKey, ServiceInterfacePoint> tapiSip) {
1369 this.tapiSips.putAll(tapiSip);