9f7d85fde1ba39aa2dd19f37a1470d49874b858f
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / networkanalyzer / PceOtnNode.java
1 /*
2  * Copyright © 2019 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.pce.networkanalyzer;
10
11 import java.math.BigDecimal;
12 import java.util.ArrayList;
13 import java.util.BitSet;
14 import java.util.Comparator;
15 import java.util.HashMap;
16 import java.util.List;
17 import java.util.Map;
18 import java.util.TreeMap;
19 import java.util.stream.Collectors;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.opendaylight.transportpce.common.StringConstants;
22 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State;
23 import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates;
24 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.OduSwitchingPools;
25 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.topology.types.rev200327.xpdr.odu.switching.pools.odu.switching.pools.NonBlockingList;
26 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmNodeType;
27 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.OpenroadmTpType;
28 import org.opendaylight.yang.gen.v1.http.org.openroadm.network.types.rev200529.xpdr.tp.supported.interfaces.SupportedInterfaceCapability;
29 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODTU4TsAllocated;
30 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev200327.ODTUCnTs;
31 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1;
32 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.TerminationPoint1;
33 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.networks.network.node.SwitchingPools;
34 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If100GEODU4;
35 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If10GEODU2e;
36 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.If1GEODU0;
37 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOCHOTU4ODU4;
38 import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev200327.IfOtsiOtsigroup;
39 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.networks.network.Node;
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.TpId;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.node.TerminationPoint;
43 import org.opendaylight.yangtools.yang.common.Uint16;
44 import org.slf4j.Logger;
45 import org.slf4j.LoggerFactory;
46
47 public class PceOtnNode implements PceNode {
48     /* Logging. */
49     private static final Logger LOG = LoggerFactory.getLogger(PceOtnNode.class);
50     ////////////////////////// OTN NODES ///////////////////////////
51     /*
52      * For This Class the node passed shall be at the otn-openroadm Layer
53      */
54
55     private boolean valid = true;
56
57     private final Node node;
58     private final NodeId nodeId;
59     private final OpenroadmNodeType nodeType;
60     private final String pceNodeType;
61     private final String otnServiceType;
62     private String modeType;
63     // TODO: not adding state check in this class as otn topology has not been modified
64     private final AdminStates adminStates;
65     private final State state;
66
67     private Map<String, List<Uint16>> tpAvailableTribPort = new TreeMap<>();
68     private Map<String, List<Uint16>> tpAvailableTribSlot = new TreeMap<>();
69     private Map<String, OpenroadmTpType> availableXponderTp = new TreeMap<>();
70     private List<String> usedXpdrNWTps = new ArrayList<>();
71     private List<TpId> availableXpdrNWTps;
72     private List<TpId> usableXpdrNWTps;
73     private List<String> usedXpdrClientTps = new ArrayList<>();
74     private List<TpId> availableXpdrClientTps;
75     private List<TpId> usableXpdrClientTps;
76
77     private List<PceLink> outgoingLinks = new ArrayList<>();
78     private Map<String, String> clientPerNwTp = new HashMap<>();
79
80     public PceOtnNode(Node node, OpenroadmNodeType nodeType, NodeId nodeId, String pceNodeType, String serviceType) {
81         this.node = node;
82         this.nodeId = nodeId;
83         this.nodeType = nodeType;
84         this.pceNodeType = pceNodeType;
85         this.otnServiceType = serviceType;
86         this.tpAvailableTribSlot.clear();
87         this.usedXpdrNWTps.clear();
88         this.availableXpdrNWTps = new ArrayList<>();
89         this.usableXpdrNWTps = new ArrayList<>();
90         this.usedXpdrClientTps.clear();
91         this.availableXpdrClientTps = new ArrayList<>();
92         this.usableXpdrClientTps = new ArrayList<>();
93         this.adminStates = node.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
94                 .Node1.class).getAdministrativeState();
95         this.state = node.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
96                 .Node1.class).getOperationalState();
97         this.tpAvailableTribPort.clear();
98         checkAvailableTribPort();
99         this.tpAvailableTribSlot.clear();
100         checkAvailableTribSlot();
101         if ((node == null) || (nodeId == null) || (nodeType != OpenroadmNodeType.MUXPDR)
102             && (nodeType != OpenroadmNodeType.SWITCH) && (nodeType != OpenroadmNodeType.TPDR)) {
103             LOG.error("PceOtnNode: one of parameters is not populated : nodeId, node type");
104             this.valid = false;
105         }
106     }
107
108     public void initXndrTps(String mode) {
109         LOG.info("PceOtnNode: initXndrTps for node {}", this.nodeId.getValue());
110         this.availableXponderTp.clear();
111
112         this.modeType = mode;
113
114         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1 nodeTp
115             = this.node.augmentation(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
116                 .ietf.network.topology.rev180226.Node1.class);
117         List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
118                 .node.TerminationPoint> allTps = new ArrayList<>(nodeTp.nonnullTerminationPoint().values());
119         this.valid = false;
120         if (allTps.isEmpty()) {
121             LOG.error("PceOtnNode: initXndrTps: XPONDER TerminationPoint list is empty for node {}", this);
122             return;
123         }
124
125         for (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network
126                 .node.TerminationPoint tp : allTps) {
127             org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.@Nullable TerminationPoint1 ocnTp1
128                 = tp.augmentation(org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529
129                 .TerminationPoint1.class);
130             //TODO many nested if-structures below, this needs to be reworked
131             if (OpenroadmTpType.XPONDERNETWORK.equals(ocnTp1.getTpType())) {
132                 TerminationPoint1 ontTp1;
133                 if (tp.augmentation(TerminationPoint1.class) != null) {
134                     ontTp1 = tp.augmentation(TerminationPoint1.class);
135                 } else {
136                     continue;
137                 }
138                 switch (this.otnServiceType) {
139                     case StringConstants.SERVICE_TYPE_100GE_S:
140                         // TODO verify the capability of network port to support ODU4 CTP interface creation
141                     case StringConstants.SERVICE_TYPE_ODU4:
142                     case StringConstants.SERVICE_TYPE_ODUC4:
143                         if (!checkTpForOdtuTermination(ontTp1)) {
144                             LOG.error("TP {} of {} does not allow ODU4 termination creation",
145                                 tp.getTpId().getValue(), node.getNodeId().getValue());
146                             continue;
147                         }
148                         break;
149
150                     case StringConstants.SERVICE_TYPE_10GE:
151                         if (!checkOdtuTTPforLoOduCreation(ontTp1, 10)) {
152                             LOG.error("TP {} of {} does not allow OD2e termination creation",
153                                 tp.getTpId().getValue(), node.getNodeId().getValue());
154                             continue;
155                         }
156                         break;
157                     case StringConstants.SERVICE_TYPE_100GE_M:
158                         if (!checkOdtuTTPforLoOduCreation(ontTp1, 20)) {
159                             LOG.error("TP {} of {} does not allow ODU4 termination creation",
160                                 tp.getTpId().getValue(), node.getNodeId().getValue());
161                             continue;
162                         }
163                         break;
164                     case StringConstants.SERVICE_TYPE_1GE:
165                         if (!checkOdtuTTPforLoOduCreation(ontTp1, 1)) {
166                             LOG.error("TP {} of {} does not allow ODU0 termination creation",
167                                 tp.getTpId().getValue(), node.getNodeId().getValue());
168                             continue;
169                         }
170                         break;
171
172                     default:
173                         LOG.error("TP {} of {} does not allow any termination creation",
174                             tp.getTpId().getValue(), node.getNodeId().getValue());
175                         continue;
176                 }
177                 LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
178                 this.availableXpdrNWTps.add(tp.getTpId());
179             } else if (OpenroadmTpType.XPONDERCLIENT.equals(ocnTp1.getTpType())
180                 && (StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
181                     || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType)
182                     || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
183                     || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType))) {
184                 TerminationPoint1 ontTp1;
185                 if (tp.augmentation(TerminationPoint1.class) != null) {
186                     ontTp1 = tp.augmentation(TerminationPoint1.class);
187                 } else {
188                     continue;
189                 }
190                 if (checkClientTp(ontTp1)) {
191                     LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
192                     this.availableXpdrClientTps.add(tp.getTpId());
193                 } else {
194                     LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation",
195                         tp.getTpId().getValue(), node.getNodeId().getValue());
196                 }
197             }
198         }
199
200         if (((StringConstants.SERVICE_TYPE_ODU4.equals(this.otnServiceType)
201                 || StringConstants.SERVICE_TYPE_ODUC4.equals(this.otnServiceType)) && mode.equals("AZ"))
202             || ((StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
203                     || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType)
204                     || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType))
205                 && ((mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1))
206                      || (mode.equals("intermediate") && checkSwPool(null, availableXpdrNWTps, 0, 2)))
207                )
208             || (StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
209                 && (mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1)))
210             ) {
211             this.valid = true;
212         } else {
213             this.valid = false;
214         }
215     }
216
217     private boolean checkSwPool(List<TpId> clientTps, List<TpId> netwTps, int nbClient, int nbNetw) {
218         if (clientTps != null && netwTps != null && nbClient == 1 && nbNetw == 1) {
219             clientTps.sort(Comparator.comparing(TpId::getValue));
220             netwTps.sort(Comparator.comparing(TpId::getValue));
221             for (TpId nwTp : netwTps) {
222                 for (TpId clTp : clientTps) {
223                     @Nullable
224                     List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
225                         .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
226                     for (NonBlockingList nbl : nblList) {
227                         if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) {
228                             usableXpdrClientTps.add(clTp);
229                             usableXpdrNWTps.add(nwTp);
230                         }
231                         if (usableXpdrClientTps.size() >= nbClient && usableXpdrNWTps.size() >= nbNetw) {
232                             clientPerNwTp.put(nwTp.getValue(), clTp.getValue());
233                             return true;
234                         }
235                     }
236                 }
237             }
238
239         }
240         if (clientTps == null && netwTps != null && nbClient == 0 && nbNetw == 2) {
241             netwTps.sort(Comparator.comparing(TpId::getValue));
242             @Nullable
243             List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
244                 .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
245             for (NonBlockingList nbl : nblList) {
246                 for (TpId nwTp : netwTps) {
247                     if (nbl.getTpList().contains(nwTp)) {
248                         usableXpdrNWTps.add(nwTp);
249                     }
250                     if (usableXpdrNWTps.size() >= nbNetw) {
251                         return true;
252                     }
253                 }
254             }
255         }
256         return false;
257     }
258
259     private boolean checkTpForOdtuTermination(TerminationPoint1 ontTp1) {
260         for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
261                 .values()) {
262             LOG.info("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
263             if ((sic.getIfCapType().equals(IfOCHOTU4ODU4.class) || sic.getIfCapType().equals(IfOtsiOtsigroup.class))
264                 && (ontTp1.getXpdrTpPortConnectionAttributes() == null
265                     || ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() == null)) {
266                 return true;
267             }
268         }
269         return false;
270     }
271
272     private boolean checkOdtuTTPforLoOduCreation(TerminationPoint1 ontTp1, int tsNb) {
273         return (ontTp1.getXpdrTpPortConnectionAttributes() != null
274             && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() != null
275             && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
276             && (ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
277                 .stream().findFirst().get().getOdtuType()
278                 .equals(ODTU4TsAllocated.class)
279                 ||
280                 ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
281                 .stream().findFirst().get().getOdtuType()
282                 .equals(ODTUCnTs.class))
283             && !ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
284                 .stream().findFirst().get().getTpnPool().isEmpty()
285             && (ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb));
286     }
287
288     private boolean checkClientTp(TerminationPoint1 ontTp1) {
289         for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
290                 .values()) {
291             LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
292             switch (otnServiceType) {
293                 case StringConstants.SERVICE_TYPE_1GE:
294                 // we could also check the administrative status of the tp
295                     if (sic.getIfCapType().equals(If1GEODU0.class)) {
296                         return true;
297                     }
298                     break;
299                 case StringConstants.SERVICE_TYPE_10GE:
300                     if (sic.getIfCapType().equals(If10GEODU2e.class)) {
301                         return true;
302                     }
303                     break;
304                 case StringConstants.SERVICE_TYPE_100GE_T:
305                 case StringConstants.SERVICE_TYPE_100GE_M:
306                 case StringConstants.SERVICE_TYPE_100GE_S:
307                     if (sic.getIfCapType().equals(If100GEODU4.class)) {
308                         return true;
309                     }
310                     break;
311                 default:
312                     break;
313             }
314         }
315         return false;
316     }
317
318     public void validateXponder(String anodeId, String znodeId) {
319         if (!isValid()) {
320             return;
321         }
322         if (this.nodeId.getValue().equals(anodeId) || (this.nodeId.getValue().equals(znodeId))) {
323             initXndrTps("AZ");
324         } else if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) {
325             initXndrTps("intermediate");
326         } else {
327             LOG.info("validateAZxponder: XPONDER is ignored == {}", nodeId.getValue());
328             valid = false;
329         }
330     }
331
332     public boolean validateSwitchingPoolBandwidth(
333             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
334                     .ietf.network.topology.rev180226.networks.network.node.TerminationPoint tp1,
335             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
336                     .ietf.network.topology.rev180226.networks.network.node.TerminationPoint tp2,
337             Long neededBW) {
338         if (this.nodeType != OpenroadmNodeType.TPDR) {
339             return true;
340         }
341         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1 node1 =
342             node.augmentation(
343                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class);
344         SwitchingPools sp = node1.getSwitchingPools();
345         List<OduSwitchingPools> osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
346         for (OduSwitchingPools ospx : osp) {
347             List<NonBlockingList> nbl = new ArrayList<>(ospx.nonnullNonBlockingList().values());
348             for (NonBlockingList nbll : nbl) {
349                 if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW && nbll.getTpList() != null
350                         && nbll.getTpList().contains(tp1.getTpId()) && nbll.getTpList().contains(tp2.getTpId())) {
351                     LOG.debug("validateSwitchingPoolBandwidth: couple  of tp {} x {} valid for crossconnection",
352                         tp1.getTpId(), tp2.getTpId());
353                     return true;
354                 }
355             }
356         }
357
358         LOG.debug("validateSwitchingPoolBandwidth: No valid Switching pool for crossconnecting tp {} and {}",
359             tp1.getTpId(), tp2.getTpId());
360         return false;
361
362     }
363
364     public void validateIntermediateSwitch() {
365         if (!isValid()) {
366             return;
367         }
368         if (this.nodeType != OpenroadmNodeType.SWITCH) {
369             return;
370         }
371         // Validate switch for use as an intermediate XPONDER on the path
372         initXndrTps("intermediate");
373         if (!this.valid) {
374             LOG.debug("validateIntermediateSwitch: Switch unusable for transit == {}", nodeId.getValue());
375         } else {
376             LOG.info("validateIntermediateSwitch: Switch usable for transit == {}", nodeId.getValue());
377         }
378     }
379
380     public void checkAvailableTribPort() {
381         List<TerminationPoint> networkTpList = node.augmentation(
382             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
383             .getTerminationPoint().values().stream()
384             .filter(type -> type
385                 .augmentation(
386                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
387                 .getTpType().equals(OpenroadmTpType.XPONDERNETWORK))
388             .collect(Collectors.toList());
389
390         for (TerminationPoint tp : networkTpList) {
391             if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() != null
392                 && tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
393                 && (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool()
394                     .values().stream().findFirst().get().getOdtuType().equals(ODTU4TsAllocated.class)
395                     || tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool()
396                     .values().stream().findFirst().get().getOdtuType().equals(ODTUCnTs.class))) {
397                 @Nullable
398                 List<Uint16> tpnPool = tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes()
399                     .getOdtuTpnPool().values().stream().findFirst().get().getTpnPool();
400                 if (tpnPool != null) {
401                     tpAvailableTribPort.put(tp.getTpId().getValue(), tpnPool);
402                 }
403             }
404         }
405     }
406
407     public void checkAvailableTribSlot() {
408         List<TerminationPoint> networkTpList = node.augmentation(
409             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
410             .getTerminationPoint().values().stream()
411             .filter(type -> type
412                 .augmentation(
413                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
414                 .getTpType().equals(OpenroadmTpType.XPONDERNETWORK))
415             .collect(Collectors.toList());
416
417         for (TerminationPoint tp : networkTpList) {
418             if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() != null
419                 && tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getTsPool() != null) {
420                 @Nullable
421                 List<Uint16> tsPool = tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes()
422                     .getTsPool();
423                 tpAvailableTribSlot.put(tp.getTpId().getValue(), tsPool);
424             }
425         }
426     }
427
428     public boolean isValid() {
429         if ((node == null) || (nodeId == null) || (nodeType == null) || (this.getSupNetworkNodeId() == null)
430             || (this.getSupClliNodeId() == null)) {
431             LOG.error("PceNode: one of parameters is not populated : nodeId, node type, supporting nodeId");
432             valid = false;
433         }
434         return valid;
435     }
436
437     public boolean isPceOtnNodeValid(final PceOtnNode pceOtnNode) {
438         if (pceOtnNode == null || pceOtnNode.node == null
439             || pceOtnNode.getNodeId() == null || pceOtnNode.nodeType == null || pceOtnNode.getSupNetworkNodeId() == null
440             || pceOtnNode.getSupClliNodeId() == null || pceOtnNode.otnServiceType == null) {
441             LOG.error(
442                 "PceOtnNode: one of parameters is not populated : nodeId, node type, supporting nodeId, otnServiceType"
443             );
444             return false;
445         }
446
447         if (!isNodeTypeValid(pceOtnNode)) {
448             LOG.error("PceOtnNode node type: node type isn't one of MUXPDR or SWITCH or TPDR");
449             return false;
450         }
451
452         return isOtnServiceTypeValid(pceOtnNode);
453     }
454
455     private boolean isOtnServiceTypeValid(PceOtnNode pceOtnNode) {
456         if (pceOtnNode.modeType == null) {
457             return false;
458         }
459
460         //Todo refactor Strings (mode and otnServiceType ) to enums
461         if ((pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_ODU4)
462                 && pceOtnNode.modeType.equals("AZ"))) {
463             return true;
464         }
465
466         return ((pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_10GE)
467                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_1GE)
468                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_100GE_S))
469                 && (isAz(pceOtnNode) || isIntermediate(pceOtnNode)));
470     }
471
472     private boolean isIntermediate(PceOtnNode pceOtnNode) {
473         return pceOtnNode.modeType.equals("intermediate")
474                 && checkSwPool(null, pceOtnNode.availableXpdrNWTps, 0, 2);
475     }
476
477     private boolean isAz(PceOtnNode pceOtnNode) {
478         return pceOtnNode.modeType.equals("AZ")
479                 && checkSwPool(pceOtnNode.availableXpdrClientTps, pceOtnNode.availableXpdrNWTps, 1, 1);
480     }
481
482     private boolean isNodeTypeValid(final PceOtnNode pceOtnNode) {
483         return (pceOtnNode.nodeType == OpenroadmNodeType.MUXPDR)
484                 || (pceOtnNode.nodeType  == OpenroadmNodeType.SWITCH)
485                 || (pceOtnNode.nodeType  == OpenroadmNodeType.TPDR);
486     }
487
488     @Override
489     public void addOutgoingLink(PceLink outLink) {
490         this.outgoingLinks.add(outLink);
491     }
492
493     @Override
494     public List<PceLink> getOutgoingLinks() {
495         return outgoingLinks;
496     }
497
498     @Override
499     public AdminStates getAdminStates() {
500         return adminStates;
501     }
502
503     @Override
504     public State getState() {
505         return state;
506     }
507
508     @Override
509     public String getXpdrClient(String tp) {
510         return this.clientPerNwTp.get(tp);
511     }
512
513     @Override
514     public String toString() {
515         return "PceNode type=" + nodeType + " ID=" + nodeId.getValue() + " CLLI=" + this.getSupClliNodeId();
516     }
517
518     public void printLinksOfNode() {
519         LOG.info(" outgoing links of node {} : {} ", nodeId.getValue(), this.getOutgoingLinks());
520     }
521
522     @Override
523     public Map<String, List<Uint16>> getAvailableTribPorts() {
524         return tpAvailableTribPort;
525     }
526
527     @Override
528     public Map<String, List<Uint16>> getAvailableTribSlots() {
529         return tpAvailableTribSlot;
530     }
531
532     public List<TpId> getUsableXpdrNWTps() {
533         return usableXpdrNWTps;
534     }
535
536     public List<TpId> getUsableXpdrClientTps() {
537         return usableXpdrClientTps;
538     }
539
540     @Override
541     public String getPceNodeType() {
542         return this.pceNodeType;
543     }
544
545     @Override
546     public String getSupNetworkNodeId() {
547         return MapUtils.getSupNetworkNode(this.node);
548     }
549
550     @Override
551     public String getSupClliNodeId() {
552         return MapUtils.getSupClliNode(this.node);
553     }
554
555     @Override
556     public String getRdmSrgClient(String tp) {
557         return null;
558     }
559
560     @Override
561     public NodeId getNodeId() {
562         return nodeId;
563     }
564
565     @Override
566     public boolean checkTP(String tp) {
567         return false;
568     }
569
570     /*
571     * (non-Javadoc)
572     *
573     * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getVersion()
574     */
575     @Override
576     public String getVersion() {
577         // TODO Auto-generated method stub
578         return null;
579     }
580
581     @Override
582     public BitSet getBitSetData() {
583         // TODO Auto-generated method stub
584         return null;
585     }
586
587     /*
588     * (non-Javadoc)
589     *
590     * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getSlotWidthGranularity()
591     */
592     @Override
593     public BigDecimal getSlotWidthGranularity() {
594         return null;
595     }
596
597     /*
598      * (non-Javadoc)
599      *
600      * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getCentralFreqGranularity()
601      */
602     @Override
603     public BigDecimal getCentralFreqGranularity() {
604         return null;
605     }
606 }