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