Merge "Fix func. tests utils base URL generation issue"
[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_ODUC2:
143                     case StringConstants.SERVICE_TYPE_ODUC3:
144                     case StringConstants.SERVICE_TYPE_ODUC4:
145                         if (!checkTpForOdtuTermination(ontTp1)) {
146                             LOG.error("TP {} of {} does not allow ODU4 termination creation",
147                                 tp.getTpId().getValue(), node.getNodeId().getValue());
148                             continue;
149                         }
150                         break;
151
152                     case StringConstants.SERVICE_TYPE_10GE:
153                         if (!checkOdtuTTPforLoOduCreation(ontTp1, 10)) {
154                             LOG.error("TP {} of {} does not allow OD2e termination creation",
155                                 tp.getTpId().getValue(), node.getNodeId().getValue());
156                             continue;
157                         }
158                         break;
159                     case StringConstants.SERVICE_TYPE_100GE_M:
160                         if (!checkOdtuTTPforLoOduCreation(ontTp1, 20)) {
161                             LOG.error("TP {} of {} does not allow ODU4 termination creation",
162                                 tp.getTpId().getValue(), node.getNodeId().getValue());
163                             continue;
164                         }
165                         break;
166                     case StringConstants.SERVICE_TYPE_1GE:
167                         if (!checkOdtuTTPforLoOduCreation(ontTp1, 1)) {
168                             LOG.error("TP {} of {} does not allow ODU0 termination creation",
169                                 tp.getTpId().getValue(), node.getNodeId().getValue());
170                             continue;
171                         }
172                         break;
173
174                     default:
175                         LOG.error("TP {} of {} does not allow any termination creation",
176                             tp.getTpId().getValue(), node.getNodeId().getValue());
177                         continue;
178                 }
179                 LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
180                 this.availableXpdrNWTps.add(tp.getTpId());
181             } else if (OpenroadmTpType.XPONDERCLIENT.equals(ocnTp1.getTpType())
182                 && (StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
183                     || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType)
184                     || StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
185                     || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType))) {
186                 TerminationPoint1 ontTp1;
187                 if (tp.augmentation(TerminationPoint1.class) != null) {
188                     ontTp1 = tp.augmentation(TerminationPoint1.class);
189                 } else {
190                     continue;
191                 }
192                 if (checkClientTp(ontTp1)) {
193                     LOG.info("TP {} of XPONDER {} is validated", tp.getTpId(), node.getNodeId().getValue());
194                     this.availableXpdrClientTps.add(tp.getTpId());
195                 } else {
196                     LOG.error("TP {} of {} does not allow lo-ODU (ODU2e or ODU0) termination creation",
197                         tp.getTpId().getValue(), node.getNodeId().getValue());
198                 }
199             }
200         }
201
202         if ((StringConstants.SERVICE_TYPE_ODU4.equals(this.otnServiceType)
203                 || StringConstants.SERVICE_TYPE_ODUC4.equals(this.otnServiceType)
204                 || StringConstants.SERVICE_TYPE_ODUC3.equals(this.otnServiceType)
205                 || StringConstants.SERVICE_TYPE_ODUC2.equals(this.otnServiceType))
206             || ((StringConstants.SERVICE_TYPE_10GE.equals(this.otnServiceType)
207                     || StringConstants.SERVICE_TYPE_100GE_M.equals(this.otnServiceType)
208                     || StringConstants.SERVICE_TYPE_1GE.equals(this.otnServiceType))
209                 && ((mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1))
210                      || (mode.equals("intermediate") && checkSwPool(null, availableXpdrNWTps, 0, 2)))
211                )
212             || (StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
213                 && (mode.equals("AZ") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 1, 1)))
214             || (StringConstants.SERVICE_TYPE_100GE_S.equals(this.otnServiceType)
215                 && (mode.equals("intermediate") && checkSwPool(availableXpdrClientTps, availableXpdrNWTps, 0, 2)))
216             ) {
217             this.valid = true;
218         } else {
219             this.valid = false;
220         }
221     }
222
223     private boolean checkSwPool(List<TpId> clientTps, List<TpId> netwTps, int nbClient, int nbNetw) {
224         if (clientTps != null && netwTps != null && nbClient == 1 && nbNetw == 1) {
225             clientTps.sort(Comparator.comparing(TpId::getValue));
226             netwTps.sort(Comparator.comparing(TpId::getValue));
227             for (TpId nwTp : netwTps) {
228                 for (TpId clTp : clientTps) {
229                     @Nullable
230                     List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
231                         .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
232                     for (NonBlockingList nbl : nblList) {
233                         if (nbl.getTpList().contains(clTp) && nbl.getTpList().contains(nwTp)) {
234                             usableXpdrClientTps.add(clTp);
235                             usableXpdrNWTps.add(nwTp);
236                         }
237                         if (usableXpdrClientTps.size() >= nbClient && usableXpdrNWTps.size() >= nbNetw) {
238                             clientPerNwTp.put(nwTp.getValue(), clTp.getValue());
239                             return true;
240                         }
241                     }
242                 }
243             }
244
245         }
246         if (netwTps != null && nbClient == 0 && nbNetw == 2) {
247             netwTps.sort(Comparator.comparing(TpId::getValue));
248             @Nullable
249             List<NonBlockingList> nblList = new ArrayList<>(node.augmentation(Node1.class).getSwitchingPools()
250                 .nonnullOduSwitchingPools().values().stream().findFirst().get().getNonBlockingList().values());
251             for (NonBlockingList nbl : nblList) {
252                 for (TpId nwTp : netwTps) {
253                     if (nbl.getTpList().contains(nwTp)) {
254                         usableXpdrNWTps.add(nwTp);
255                     }
256                     if (usableXpdrNWTps.size() >= nbNetw) {
257                         return true;
258                     }
259                 }
260             }
261         }
262         return false;
263     }
264
265     private boolean checkTpForOdtuTermination(TerminationPoint1 ontTp1) {
266         for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
267                 .values()) {
268             LOG.info("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
269             if ((sic.getIfCapType().equals(IfOCHOTU4ODU4.class) || sic.getIfCapType().equals(IfOtsiOtsigroup.class))
270                 && (ontTp1.getXpdrTpPortConnectionAttributes() == null
271                     || ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() == null)) {
272                 return true;
273             }
274         }
275         return false;
276     }
277
278     private boolean checkOdtuTTPforLoOduCreation(TerminationPoint1 ontTp1, int tsNb) {
279         return (ontTp1.getXpdrTpPortConnectionAttributes() != null
280             && ontTp1.getXpdrTpPortConnectionAttributes().getTsPool() != null
281             && ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
282             && (ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
283                 .stream().findFirst().get().getOdtuType()
284                 .equals(ODTU4TsAllocated.class)
285                 ||
286                 ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
287                 .stream().findFirst().get().getOdtuType()
288                 .equals(ODTUCnTs.class))
289             && !ontTp1.getXpdrTpPortConnectionAttributes().getOdtuTpnPool().values()
290                 .stream().findFirst().get().getTpnPool().isEmpty()
291             && (ontTp1.getXpdrTpPortConnectionAttributes().getTsPool().size() >= tsNb));
292     }
293
294     private boolean checkClientTp(TerminationPoint1 ontTp1) {
295         for (SupportedInterfaceCapability sic : ontTp1.getTpSupportedInterfaces().getSupportedInterfaceCapability()
296                 .values()) {
297             LOG.debug("in checkTpForOduTermination - sic = {}", sic.getIfCapType());
298             switch (otnServiceType) {
299                 case StringConstants.SERVICE_TYPE_1GE:
300                 // we could also check the administrative status of the tp
301                     if (sic.getIfCapType().equals(If1GEODU0.class)) {
302                         return true;
303                     }
304                     break;
305                 case StringConstants.SERVICE_TYPE_10GE:
306                     if (sic.getIfCapType().equals(If10GEODU2e.class)) {
307                         return true;
308                     }
309                     break;
310                 case StringConstants.SERVICE_TYPE_100GE_T:
311                 case StringConstants.SERVICE_TYPE_100GE_M:
312                 case StringConstants.SERVICE_TYPE_100GE_S:
313                     if (sic.getIfCapType().equals(If100GEODU4.class)) {
314                         return true;
315                     }
316                     break;
317                 default:
318                     break;
319             }
320         }
321         return false;
322     }
323
324     public void validateXponder(String anodeId, String znodeId) {
325         if (!isValid()) {
326             return;
327         }
328         if (this.nodeId.getValue().equals(anodeId) || (this.nodeId.getValue().equals(znodeId))) {
329             initXndrTps("AZ");
330         } else if (OpenroadmNodeType.SWITCH.equals(this.nodeType)) {
331             initXndrTps("intermediate");
332         } else {
333             LOG.info("validateAZxponder: XPONDER is ignored == {}", nodeId.getValue());
334             valid = false;
335         }
336     }
337
338     public boolean validateSwitchingPoolBandwidth(
339             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
340                     .ietf.network.topology.rev180226.networks.network.node.TerminationPoint tp1,
341             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
342                     .ietf.network.topology.rev180226.networks.network.node.TerminationPoint tp2,
343             Long neededBW) {
344         if (this.nodeType != OpenroadmNodeType.TPDR) {
345             return true;
346         }
347         org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1 node1 =
348             node.augmentation(
349                     org.opendaylight.yang.gen.v1.http.org.openroadm.otn.network.topology.rev200529.Node1.class);
350         SwitchingPools sp = node1.getSwitchingPools();
351         List<OduSwitchingPools> osp = new ArrayList<>(sp.nonnullOduSwitchingPools().values());
352         for (OduSwitchingPools ospx : osp) {
353             List<NonBlockingList> nbl = new ArrayList<>(ospx.nonnullNonBlockingList().values());
354             for (NonBlockingList nbll : nbl) {
355                 if (nbll.getAvailableInterconnectBandwidth().toJava() >= neededBW && nbll.getTpList() != null
356                         && nbll.getTpList().contains(tp1.getTpId()) && nbll.getTpList().contains(tp2.getTpId())) {
357                     LOG.debug("validateSwitchingPoolBandwidth: couple  of tp {} x {} valid for crossconnection",
358                         tp1.getTpId(), tp2.getTpId());
359                     return true;
360                 }
361             }
362         }
363
364         LOG.debug("validateSwitchingPoolBandwidth: No valid Switching pool for crossconnecting tp {} and {}",
365             tp1.getTpId(), tp2.getTpId());
366         return false;
367
368     }
369
370     public void validateIntermediateSwitch() {
371         if (!isValid()) {
372             return;
373         }
374         if (this.nodeType != OpenroadmNodeType.SWITCH) {
375             return;
376         }
377         // Validate switch for use as an intermediate XPONDER on the path
378         initXndrTps("intermediate");
379         if (!this.valid) {
380             LOG.debug("validateIntermediateSwitch: Switch unusable for transit == {}", nodeId.getValue());
381         } else {
382             LOG.info("validateIntermediateSwitch: Switch usable for transit == {}", nodeId.getValue());
383         }
384     }
385
386     public void checkAvailableTribPort() {
387         List<TerminationPoint> networkTpList = node.augmentation(
388             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
389             .getTerminationPoint().values().stream()
390             .filter(type -> type
391                 .augmentation(
392                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
393                 .getTpType().equals(OpenroadmTpType.XPONDERNETWORK))
394             .collect(Collectors.toList());
395
396         for (TerminationPoint tp : networkTpList) {
397             if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() != null
398                 && tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool() != null
399                 && (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool()
400                     .values().stream().findFirst().get().getOdtuType().equals(ODTU4TsAllocated.class)
401                     || tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getOdtuTpnPool()
402                     .values().stream().findFirst().get().getOdtuType().equals(ODTUCnTs.class))) {
403                 @Nullable
404                 List<Uint16> tpnPool = tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes()
405                     .getOdtuTpnPool().values().stream().findFirst().get().getTpnPool();
406                 if (tpnPool != null) {
407                     tpAvailableTribPort.put(tp.getTpId().getValue(), tpnPool);
408                 }
409             }
410         }
411     }
412
413     public void checkAvailableTribSlot() {
414         List<TerminationPoint> networkTpList = node.augmentation(
415             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.Node1.class)
416             .getTerminationPoint().values().stream()
417             .filter(type -> type
418                 .augmentation(
419                     org.opendaylight.yang.gen.v1.http.org.openroadm.common.network.rev200529.TerminationPoint1.class)
420                 .getTpType().equals(OpenroadmTpType.XPONDERNETWORK))
421             .collect(Collectors.toList());
422
423         for (TerminationPoint tp : networkTpList) {
424             if (tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes() != null
425                 && tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes().getTsPool() != null) {
426                 @Nullable
427                 List<Uint16> tsPool = tp.augmentation(TerminationPoint1.class).getXpdrTpPortConnectionAttributes()
428                     .getTsPool();
429                 tpAvailableTribSlot.put(tp.getTpId().getValue(), tsPool);
430             }
431         }
432     }
433
434     public boolean isValid() {
435         if ((node == null) || (nodeId == null) || (nodeType == null) || (this.getSupNetworkNodeId() == null)
436             || (this.getSupClliNodeId() == null)) {
437             LOG.error("PceNode: one of parameters is not populated : nodeId, node type, supporting nodeId");
438             valid = false;
439         }
440         return valid;
441     }
442
443     public boolean isPceOtnNodeValid(final PceOtnNode pceOtnNode) {
444         if (pceOtnNode == null || pceOtnNode.node == null
445             || pceOtnNode.getNodeId() == null || pceOtnNode.nodeType == null || pceOtnNode.getSupNetworkNodeId() == null
446             || pceOtnNode.getSupClliNodeId() == null || pceOtnNode.otnServiceType == null) {
447             LOG.error(
448                 "PceOtnNode: one of parameters is not populated : nodeId, node type, supporting nodeId, otnServiceType"
449             );
450             return false;
451         }
452
453         if (!isNodeTypeValid(pceOtnNode)) {
454             LOG.error("PceOtnNode node type: node type isn't one of MUXPDR or SWITCH or TPDR");
455             return false;
456         }
457
458         return isOtnServiceTypeValid(pceOtnNode);
459     }
460
461     private boolean isOtnServiceTypeValid(PceOtnNode pceOtnNode) {
462         if (pceOtnNode.modeType == null) {
463             return false;
464         }
465
466         //Todo refactor Strings (mode and otnServiceType ) to enums
467         if ((pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_ODU4)
468                 && pceOtnNode.modeType.equals("AZ"))) {
469             return true;
470         }
471
472         return ((pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_10GE)
473                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_1GE)
474                 || pceOtnNode.otnServiceType.equals(StringConstants.SERVICE_TYPE_100GE_S))
475                 && (isAz(pceOtnNode) || isIntermediate(pceOtnNode)));
476     }
477
478     private boolean isIntermediate(PceOtnNode pceOtnNode) {
479         return pceOtnNode.modeType.equals("intermediate")
480                 && checkSwPool(null, pceOtnNode.availableXpdrNWTps, 0, 2);
481     }
482
483     private boolean isAz(PceOtnNode pceOtnNode) {
484         return pceOtnNode.modeType.equals("AZ")
485                 && checkSwPool(pceOtnNode.availableXpdrClientTps, pceOtnNode.availableXpdrNWTps, 1, 1);
486     }
487
488     private boolean isNodeTypeValid(final PceOtnNode pceOtnNode) {
489         return (pceOtnNode.nodeType == OpenroadmNodeType.MUXPDR)
490                 || (pceOtnNode.nodeType  == OpenroadmNodeType.SWITCH)
491                 || (pceOtnNode.nodeType  == OpenroadmNodeType.TPDR);
492     }
493
494     @Override
495     public void addOutgoingLink(PceLink outLink) {
496         this.outgoingLinks.add(outLink);
497     }
498
499     @Override
500     public List<PceLink> getOutgoingLinks() {
501         return outgoingLinks;
502     }
503
504     @Override
505     public AdminStates getAdminStates() {
506         return adminStates;
507     }
508
509     @Override
510     public State getState() {
511         return state;
512     }
513
514     @Override
515     public String getXpdrClient(String tp) {
516         return this.clientPerNwTp.get(tp);
517     }
518
519     @Override
520     public String toString() {
521         return "PceNode type=" + nodeType + " ID=" + nodeId.getValue() + " CLLI=" + this.getSupClliNodeId();
522     }
523
524     public void printLinksOfNode() {
525         LOG.info(" outgoing links of node {} : {} ", nodeId.getValue(), this.getOutgoingLinks());
526     }
527
528     @Override
529     public Map<String, List<Uint16>> getAvailableTribPorts() {
530         return tpAvailableTribPort;
531     }
532
533     @Override
534     public Map<String, List<Uint16>> getAvailableTribSlots() {
535         return tpAvailableTribSlot;
536     }
537
538     public List<TpId> getUsableXpdrNWTps() {
539         return usableXpdrNWTps;
540     }
541
542     public List<TpId> getUsableXpdrClientTps() {
543         return usableXpdrClientTps;
544     }
545
546     @Override
547     public String getPceNodeType() {
548         return this.pceNodeType;
549     }
550
551     @Override
552     public String getSupNetworkNodeId() {
553         return MapUtils.getSupNetworkNode(this.node);
554     }
555
556     @Override
557     public String getSupClliNodeId() {
558         return MapUtils.getSupClliNode(this.node);
559     }
560
561     @Override
562     public String getRdmSrgClient(String tp) {
563         return null;
564     }
565
566     @Override
567     public NodeId getNodeId() {
568         return nodeId;
569     }
570
571     @Override
572     public boolean checkTP(String tp) {
573         return false;
574     }
575
576     /*
577     * (non-Javadoc)
578     *
579     * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getVersion()
580     */
581     @Override
582     public String getVersion() {
583         // TODO Auto-generated method stub
584         return null;
585     }
586
587     @Override
588     public BitSet getBitSetData() {
589         // TODO Auto-generated method stub
590         return null;
591     }
592
593     /*
594     * (non-Javadoc)
595     *
596     * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getSlotWidthGranularity()
597     */
598     @Override
599     public BigDecimal getSlotWidthGranularity() {
600         return null;
601     }
602
603     /*
604      * (non-Javadoc)
605      *
606      * @see org.opendaylight.transportpce.pce.networkanalyzer.PceNode#getCentralFreqGranularity()
607      */
608     @Override
609     public BigDecimal getCentralFreqGranularity() {
610         return null;
611     }
612 }