445e3f2e36a71045b8c8d5037e8aabb8459d2531
[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                     && (StringConstants.SERVICE_TYPE_ODU4.equals(this.otnServiceType)
133                         || StringConstants.SERVICE_TYPE_ODUC4.equals(this.otnServiceType))) {
134                 TerminationPoint1 ontTp1;
135                 if (tp.augmentation(TerminationPoint1.class) != null) {
136                     ontTp1 = tp.augmentation(TerminationPoint1.class);
137                 } else {
138                     continue;
139                 }
140                 if (checkTpForOdtuTermination(ontTp1)) {
141                     LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
142                     this.availableXpdrNWTps.add(tp.getTpId());
143                 } else {
144                     LOG.error("TP {} of {} does not allow ODU4 termination creation", tp.getTpId().getValue(),
145                         node.getNodeId().getValue());
146                 }
147             } else if (OpenroadmTpType.XPONDERNETWORK.equals(ocnTp1.getTpType())
148                 && (StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
149                         || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType)
150                         || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType))) {
151                 TerminationPoint1 ontTp1;
152                 if (tp.augmentation(TerminationPoint1.class) != null) {
153                     ontTp1 = tp.augmentation(TerminationPoint1.class);
154                 } else {
155                     continue;
156                 }
157                 if ((StringConstants.SERVICE_TYPE_10GE.equals(otnServiceType)
158                         && checkOdtuTTPforLoOduCreation(ontTp1, 10))
159                     || (StringConstants.SERVICE_TYPE_1GE.equals(otnServiceType)
160                         && checkOdtuTTPforLoOduCreation(ontTp1, 1))
161                     || (StringConstants.SERVICE_TYPE_100GE_M.equals(otnServiceType)
162                         && checkOdtuTTPforLoOduCreation(ontTp1, 20))) {
163                     LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
164                     this.availableXpdrNWTps.add(tp.getTpId());
165                 } else {
166                     if (StringConstants.SERVICE_TYPE_10GE.equals(otnServiceType)) {
167                         LOG.error("TP {} of {} does not allow OD2e termination creation", tp.getTpId().getValue(),
168                             node.getNodeId().getValue());
169                     } else if (StringConstants.SERVICE_TYPE_1GE.equals(otnServiceType)) {
170                         LOG.error("TP {} of {} does not allow ODU0 termination creation", tp.getTpId().getValue(),
171                             node.getNodeId().getValue());
172                     } else if (StringConstants.SERVICE_TYPE_100GE_M.equals(otnServiceType)) {
173                         LOG.error("TP {} of {} does not allow ODU4 termination creation", tp.getTpId().getValue(),
174                             node.getNodeId().getValue());
175                     } else {
176                         LOG.error("TP {} of {} does not allow any termination creation", tp.getTpId().getValue(),
177                             node.getNodeId().getValue());
178                     }
179                 }
180             } else if (OpenroadmTpType.XPONDERCLIENT.equals(ocnTp1.getTpType())
181                 && (StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
182                     || StringConstants.SERVICE_TYPE_100GE_M.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             this.valid = true;
209         } else {
210             this.valid = false;
211         }
212     }
213
214     private boolean checkSwPool(List<TpId> clientTps, List<TpId> netwTps, int nbClient, int nbNetw) {
215         if (clientTps != null && netwTps != null && nbClient == 1 && nbNetw == 1) {
216             clientTps.sort(Comparator.comparing(TpId::getValue));
217             netwTps.sort(Comparator.comparing(TpId::getValue));
218             for (TpId nwTp : netwTps) {
219                 for (TpId clTp : clientTps) {
220                     @Nullable
221                     List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
222                         .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
223                     for (NonBlockingList nbl : nblList) {
224                         if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) {
225                             usableXpdrClientTps.add(clTp);
226                             usableXpdrNWTps.add(nwTp);
227                         }
228                         if (usableXpdrClientTps.size() >= nbClient && usableXpdrNWTps.size() >= nbNetw) {
229                             clientPerNwTp.put(nwTp.getValue(), clTp.getValue());
230                             return true;
231                         }
232                     }
233                 }
234             }
235
236         }
237         if (clientTps == null && netwTps != null && nbClient == 0 && nbNetw == 2) {
238             netwTps.sort(Comparator.comparing(TpId::getValue));
239             @Nullable
240             List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
241                 .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
242             for (NonBlockingList nbl : nblList) {
243                 for (TpId nwTp : netwTps) {
244                     if (nbl.getTpList().contains(nwTp)) {
245                         usableXpdrNWTps.add(nwTp);
246                     }
247                     if (usableXpdrNWTps.size() >= nbNetw) {
248                         return true;
249                     }
250                 }
251             }
252         }
253         return false;
254     }
255
256     private boolean checkTpForOdtuTermination(TerminationPoint1 ontTp1) {
257         for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
258                 .values()) {
259             LOG.info("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
260             if ((sic.getIfCapType().equals(IfOCHOTU4ODU4.class) || sic.getIfCapType().equals(IfOtsiOtsigroup.class))
261                 && (ontTp1.getXpdrTpPortConnectionAttributes() == null
262                     || ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() == null)) {
263                 return true;
264             }
265         }
266         return false;
267     }
268
269     private boolean checkOdtuTTPforLoOduCreation(TerminationPoint1 ontTp1, int tsNb) {
270         if (ontTp1.getXpdrTpPortConnectionAttributes() != null
271             && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() != null
272             && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
273             && (ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
274                 .stream().findFirst().get().getOdtuType()
275                 .equals(ODTU4TsAllocated.class)
276                 ||
277                 ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
278                 .stream().findFirst().get().getOdtuType()
279                 .equals(ODTUCnTs.class))
280             && !ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
281                 .stream().findFirst().get().getTpnPool().isEmpty()
282             && (ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb)) {
283             return true;
284         }
285         return false;
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                     if (sic.getIfCapType().equals(If100GEODU4.class)) {
307                         return true;
308                     }
309                     break;
310                 default:
311                     break;
312             }
313         }
314         return false;
315     }
316
317     public void validateXponder(String anodeId, String znodeId) {
318         if (!isValid()) {
319             return;
320         }
321         if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) {
322             initXndrTps("intermediate");
323         }
324         if (this.nodeId.getValue().equals(anodeId) || (this.nodeId.getValue().equals(znodeId))) {
325             initXndrTps("AZ");
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         if ((pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_10GE)
467                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_1GE))
468                 && (isAz(pceOtnNode) || isIntermediate(pceOtnNode))) {
469             return true;
470         }
471
472         return false;
473     }
474
475     private boolean isIntermediate(PceOtnNode pceOtnNode) {
476         return pceOtnNode.modeType.equals("intermediate")
477                 && checkSwPool(null, pceOtnNode.availableXpdrNWTps, 0, 2);
478     }
479
480     private boolean isAz(PceOtnNode pceOtnNode) {
481         return pceOtnNode.modeType.equals("AZ")
482                 && checkSwPool(pceOtnNode.availableXpdrClientTps, pceOtnNode.availableXpdrNWTps, 1, 1);
483     }
484
485     private boolean isNodeTypeValid(final PceOtnNode pceOtnNode) {
486         return (pceOtnNode.nodeType == OpenroadmNodeType.MUXPDR)
487                 || (pceOtnNode.nodeType  == OpenroadmNodeType.SWITCH)
488                 || (pceOtnNode.nodeType  == OpenroadmNodeType.TPDR);
489     }
490
491     @Override
492     public void addOutgoingLink(PceLink outLink) {
493         this.outgoingLinks.add(outLink);
494     }
495
496     @Override
497     public List<PceLink> getOutgoingLinks() {
498         return outgoingLinks;
499     }
500
501     @Override
502     public AdminStates getAdminStates() {
503         return adminStates;
504     }
505
506     @Override
507     public State getState() {
508         return state;
509     }
510
511     @Override
512     public String getXpdrClient(String tp) {
513         return this.clientPerNwTp.get(tp);
514     }
515
516     @Override
517     public String toString() {
518         return "PceNode type=" + nodeType + " ID=" + nodeId.getValue() + " CLLI=" + this.getSupClliNodeId();
519     }
520
521     public void printLinksOfNode() {
522         LOG.info(" outgoing links of node {} : {} ", nodeId.getValue(), this.getOutgoingLinks());
523     }
524
525     @Override
526     public Map<String, List<Uint16>> getAvailableTribPorts() {
527         return tpAvailableTribPort;
528     }
529
530     @Override
531     public Map<String, List<Uint16>> getAvailableTribSlots() {
532         return tpAvailableTribSlot;
533     }
534
535     public List<TpId> getUsableXpdrNWTps() {
536         return usableXpdrNWTps;
537     }
538
539     public List<TpId> getUsableXpdrClientTps() {
540         return usableXpdrClientTps;
541     }
542
543     @Override
544     public String getPceNodeType() {
545         return this.pceNodeType;
546     }
547
548     @Override
549     public String getSupNetworkNodeId() {
550         return MapUtils.getSupNetworkNode(this.node);
551     }
552
553     @Override
554     public String getSupClliNodeId() {
555         return MapUtils.getSupClliNode(this.node);
556     }
557
558     @Override
559     public String getRdmSrgClient(String tp) {
560         return null;
561     }
562
563     @Override
564     public NodeId getNodeId() {
565         return nodeId;
566     }
567
568     @Override
569     public boolean checkTP(String tp) {
570         return false;
571     }
572
573     /*
574     * (non-Javadoc)
575     *
576     * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getVersion()
577     */
578     @Override
579     public String getVersion() {
580         // TODO Auto-generated method stub
581         return null;
582     }
583
584     @Override
585     public BitSet getBitSetData() {
586         // TODO Auto-generated method stub
587         return null;
588     }
589
590     /*
591     * (non-Javadoc)
592     *
593     * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getSlotWidthGranularity()
594     */
595     @Override
596     public BigDecimal getSlotWidthGranularity() {
597         return null;
598     }
599 }