ba15a73366669d18d9daf0a6a0b66e0f4c19660f
[bgpcep.git] / pcep / topology-provider / src / main / java / org / opendaylight / bgpcep / pcep / topology / provider / Stateful07TopologySessionListener.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, 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 package org.opendaylight.bgpcep.pcep.topology.provider;
9
10 import com.google.common.base.Charsets;
11 import com.google.common.base.Function;
12 import com.google.common.base.Optional;
13 import com.google.common.base.Preconditions;
14 import com.google.common.util.concurrent.AsyncFunction;
15 import com.google.common.util.concurrent.Futures;
16 import com.google.common.util.concurrent.ListenableFuture;
17 import java.net.InetAddress;
18 import java.nio.ByteBuffer;
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22 import java.util.concurrent.atomic.AtomicLong;
23 import org.opendaylight.protocol.pcep.PCEPSession;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.PcinitiateBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Srp1;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Srp1Builder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.PcinitiateMessageBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.Requests;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.pcinitiate.message.pcinitiate.message.RequestsBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Arguments1;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Arguments2;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Arguments3;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.OperationalStatus;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Path1;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Path1Builder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PcrptMessage;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PcupdBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.PlspId;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SrpIdNumber;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.StatefulTlv1;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.StatefulTlv1Builder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SymbolicPathName;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.LspBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.TlvsBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcerr.pcerr.message.error.type.StatefulCase;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcerr.pcerr.message.error.type.stateful._case.stateful.Srps;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.pcrpt.message.Reports;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.PcupdMessageBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.UpdatesBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcupd.message.pcupd.message.updates.PathBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.Srp;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.srp.object.SrpBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.Stateful;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.symbolic.path.name.tlv.SymbolicPathNameBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.AddLspArgs;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.EnsureLspOperationalInput;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.LspId;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.OperationResult;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.PccSyncState;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.RemoveLspArgs;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.UpdateLspArgs;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PathComputationClientBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.ReportedLsp;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.ReportedLspBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.StatefulTlvBuilder;
71 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
72 import org.slf4j.Logger;
73 import org.slf4j.LoggerFactory;
74
75 final class Stateful07TopologySessionListener extends AbstractTopologySessionListener<SrpIdNumber, PlspId> {
76     private static final Logger LOG = LoggerFactory.getLogger(Stateful07TopologySessionListener.class);
77
78     private final AtomicLong requestId = new AtomicLong(1L);
79
80     /**
81      * @param serverSessionManager
82      */
83     Stateful07TopologySessionListener(final ServerSessionManager serverSessionManager) {
84         super(serverSessionManager);
85     }
86
87     @Override
88     protected void onSessionUp(final PCEPSession session, final PathComputationClientBuilder pccBuilder) {
89         final InetAddress peerAddress = session.getRemoteAddress();
90
91         final Tlvs tlvs = session.getRemoteTlvs();
92         if (tlvs != null && tlvs.getAugmentation(Tlvs1.class) != null) {
93             final Stateful stateful = tlvs.getAugmentation(Tlvs1.class).getStateful();
94             if (stateful != null) {
95                 pccBuilder.setReportedLsp(Collections.<ReportedLsp> emptyList());
96                 pccBuilder.setStateSync(PccSyncState.InitialResync);
97                 pccBuilder.setStatefulTlv(new StatefulTlvBuilder().addAugmentation(StatefulTlv1.class,
98                     new StatefulTlv1Builder(tlvs.getAugmentation(Tlvs1.class)).build()).build());
99             } else {
100                 LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
101             }
102         } else {
103             LOG.debug("Peer {} does not advertise stateful TLV", peerAddress);
104         }
105     }
106
107     private boolean handleErrorMessage(final PcerrMessage message) {
108         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessage errMsg = message.getPcerrMessage();
109         if (errMsg.getErrorType() instanceof StatefulCase) {
110             final StatefulCase stat = (StatefulCase)errMsg.getErrorType();
111             for (final Srps srps : stat.getStateful().getSrps()) {
112                 final SrpIdNumber id = srps.getSrp().getOperationId();
113                 if (id.getValue() != 0) {
114                     final PCEPRequest req = removeRequest(id);
115                     if (req != null) {
116                         req.done(OperationResults.createFailed(errMsg.getErrors()));
117                     } else {
118                         LOG.warn("Request ID {} not found in outstanding DB", id);
119                     }
120                 }
121             }
122         } else {
123             LOG.warn("Unhandled PCErr message {}.", errMsg);
124             return true;
125         }
126         return false;
127     }
128
129     @Override
130     protected boolean onMessage(final MessageContext ctx, final Message message) {
131         if (message instanceof PcerrMessage) {
132             return handleErrorMessage((PcerrMessage) message);
133         }
134         if (!(message instanceof PcrptMessage)) {
135             return true;
136         }
137         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.pcrpt.message.PcrptMessage rpt = ((PcrptMessage) message).getPcrptMessage();
138         for (final Reports report : rpt.getReports()) {
139             final Lsp lsp = report.getLsp();
140             final PlspId plspid = lsp.getPlspId();
141             if (!lsp.isSync() && (lsp.getPlspId() == null || plspid.getValue() == 0)) {
142                 stateSynchronizationAchieved(ctx);
143                 continue;
144             }
145             final ReportedLspBuilder rlb = new ReportedLspBuilder();
146             boolean solicited = false;
147             final Srp srp = report.getSrp();
148             if (srp != null) {
149                 final SrpIdNumber id = srp.getOperationId();
150                 if (id.getValue() != 0) {
151                     solicited = true;
152
153                     switch (lsp.getOperational()) {
154                     case Active:
155                     case Down:
156                     case Up:
157                         final PCEPRequest req = removeRequest(id);
158                         if (req != null) {
159                             LOG.debug("Request {} resulted in LSP operational state {}", id, lsp.getOperational());
160                             rlb.setMetadata(req.getMetadata());
161                             ctx.resolveRequest(req);
162                         } else {
163                             LOG.warn("Request ID {} not found in outstanding DB", id);
164                         }
165                         break;
166                     case GoingDown:
167                     case GoingUp:
168                         // These are transitive states, so we don't have to do anything, as they will be followed
169                         // up...
170                         break;
171                     }
172                     // if remove flag is set in SRP object, remove the tunnel immediately
173                     if (srp.getAugmentation(Srp1.class) != null) {
174                         final Srp1 initiatedSrp = srp.getAugmentation(Srp1.class);
175                         if (initiatedSrp.isRemove()) {
176                             super.removeLsp(ctx, plspid);
177                             return false;
178                         }
179                     }
180                 }
181             }
182             final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.PathBuilder();
183             if (report.getPath() != null) {
184                 pb.fieldsFrom(report.getPath());
185             }
186             // LSP is mandatory (if there is none, parser will throw an exception)
187             // this is to ensure a path will be created at any rate
188             pb.addAugmentation(Path1.class, new Path1Builder().setLsp(report.getLsp()).build());
189             String name = lookupLspName(plspid);
190             final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs tlvs = report.getLsp().getTlvs();
191             if (tlvs != null) {
192                 if (tlvs.getLspIdentifiers() != null) {
193                     pb.setLspId(tlvs.getLspIdentifiers().getLspId());
194                 }
195                 if (tlvs.getSymbolicPathName() != null) {
196                     name = Charsets.UTF_8.decode(ByteBuffer.wrap(tlvs.getSymbolicPathName().getPathName().getValue())).toString();
197                 }
198             }
199             rlb.setPath(Collections.singletonList(pb.build()));
200             updateLsp(ctx, plspid, name, rlb, solicited, lsp.isRemove());
201             LOG.debug("LSP {} updated", lsp);
202         }
203         return false;
204     }
205
206     private SrpIdNumber nextRequest() {
207         return new SrpIdNumber(this.requestId.getAndIncrement());
208     }
209
210     @Override
211     public synchronized ListenableFuture<OperationResult> addLsp(final AddLspArgs input) {
212         Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, MISSING_XML_TAG);
213         LOG.trace("AddLspArgs {}", input);
214         // Make sure there is no such LSP
215         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
216         final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
217
218         return Futures.transform(f, new AsyncFunction<Optional<ReportedLsp>, OperationResult>() {
219             @Override
220             public ListenableFuture<OperationResult> apply(final Optional<ReportedLsp> rep) {
221                 if (rep.isPresent()) {
222                     LOG.debug("Node {} already contains lsp {} at {}", input.getNode(), input.getName(), lsp);
223                     return OperationResults.UNSENT.future();
224                 }
225
226                 // Build the request
227                 final RequestsBuilder rb = new RequestsBuilder();
228                 final Arguments2 args = input.getArguments().getAugmentation(Arguments2.class);
229                 Preconditions.checkArgument(args != null, "Input is missing operational tag.");
230                 final Lsp inputLsp = args.getLsp();
231                 Preconditions.checkArgument(inputLsp != null, "Reported LSP does not contain LSP object.");
232
233                 rb.fieldsFrom(input.getArguments());
234
235                 final TlvsBuilder tlvsBuilder = new TlvsBuilder();
236                 tlvsBuilder.setSymbolicPathName(
237                     new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(input.getName().getBytes(Charsets.UTF_8))).build());
238                 if (inputLsp.getTlvs() != null) {
239                     tlvsBuilder.setVsTlv(inputLsp.getTlvs().getVsTlv());
240                 }
241
242                 rb.setSrp(new SrpBuilder().setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build());
243                 rb.setLsp(new LspBuilder().setAdministrative(inputLsp.isAdministrative()).setDelegate(inputLsp.isDelegate()).setPlspId(
244                     new PlspId(0L)).setTlvs(tlvsBuilder.build()).build());
245
246                 final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
247                 ib.setRequests(Collections.singletonList(rb.build()));
248
249                 // Send the message
250                 return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(),
251                     input.getArguments().getMetadata());
252             }
253         });
254     }
255
256     @Override
257     public synchronized ListenableFuture<OperationResult> removeLsp(final RemoveLspArgs input) {
258         Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null, MISSING_XML_TAG);
259         LOG.trace("RemoveLspArgs {}", input);
260         // Make sure the LSP exists, we need it for PLSP-ID
261         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
262         final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
263
264         return Futures.transform(f, new AsyncFunction<Optional<ReportedLsp>, OperationResult>() {
265             @Override
266             public ListenableFuture<OperationResult> apply(final Optional<ReportedLsp> rep) {
267                 final Lsp reportedLsp = validateReportedLsp(rep, input);
268                 if (reportedLsp == null) {
269                     return OperationResults.UNSENT.future();
270                 }
271                 // Build the request and send it
272                 final RequestsBuilder rb = new RequestsBuilder();
273                 rb.setSrp(new SrpBuilder().addAugmentation(Srp1.class, new Srp1Builder().setRemove(Boolean.TRUE).build()).setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build());
274                 rb.setLsp(new LspBuilder().setRemove(Boolean.FALSE).setPlspId(reportedLsp.getPlspId()).setDelegate(reportedLsp.isDelegate()).build());
275
276                 final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
277                 ib.setRequests(Collections.singletonList(rb.build()));
278                 return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(), rb.getSrp().getOperationId(), null);
279             }
280         });
281     }
282
283     @Override
284     public synchronized ListenableFuture<OperationResult> updateLsp(final UpdateLspArgs input) {
285         Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, MISSING_XML_TAG);
286         LOG.trace("UpdateLspArgs {}", input);
287         // Make sure the LSP exists
288         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
289         final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
290
291         return Futures.transform(f, new AsyncFunction<Optional<ReportedLsp>, OperationResult>() {
292             @Override
293             public ListenableFuture<OperationResult> apply(final Optional<ReportedLsp> rep) {
294                 final Lsp reportedLsp = validateReportedLsp(rep, input);
295                 if (reportedLsp == null) {
296                     return OperationResults.UNSENT.future();
297                 }
298                 // create mandatory objects
299                 final Srp srp = new SrpBuilder().setOperationId(nextRequest()).setProcessingRule(Boolean.TRUE).build();
300
301                 final Lsp inputLsp = input.getArguments().getAugmentation(Arguments3.class).getLsp();
302                 final Lsp lsp = (inputLsp != null) ?
303                     new LspBuilder().setPlspId(reportedLsp.getPlspId()).setDelegate((inputLsp.isDelegate() != null) ? inputLsp.isDelegate() : false).setTlvs(inputLsp.getTlvs()).setAdministrative((inputLsp.isAdministrative() != null) ? inputLsp.isAdministrative() : false).build()
304                     : new LspBuilder().setPlspId(reportedLsp.getPlspId()).build();
305                 Message msg = null;
306                 // the D bit that was reported decides the type of PCE message sent
307                 Preconditions.checkNotNull(reportedLsp.isDelegate());
308                 if (reportedLsp.isDelegate()) {
309                     // we already have delegation, send update
310                     final UpdatesBuilder rb = new UpdatesBuilder();
311                     rb.setSrp(srp);
312                     rb.setLsp(lsp);
313                     final PathBuilder pb = new PathBuilder();
314                     pb.fieldsFrom(input.getArguments());
315                     rb.setPath(pb.build());
316                     final PcupdMessageBuilder ub = new PcupdMessageBuilder(MESSAGE_HEADER);
317                     ub.setUpdates(Collections.singletonList(rb.build()));
318                     msg = new PcupdBuilder().setPcupdMessage(ub.build()).build();
319                 } else {
320                     // we want to revoke delegation, different type of message
321                     // is sent because of specification by Siva
322                     // this message is also sent, when input delegate bit is set to 0
323                     // generating an error in PCC
324                     final List<Requests> reqs = new ArrayList<>();
325                     reqs.add(new RequestsBuilder().setSrp(srp).setLsp(lsp).build());
326                     final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder();
327                     ib.setRequests(reqs);
328                     msg = new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build();
329                 }
330                 return sendMessage(msg, srp.getOperationId(), input.getArguments().getMetadata());
331             }
332         });
333     }
334
335     @Override
336     public synchronized ListenableFuture<OperationResult> ensureLspOperational(final EnsureLspOperationalInput input) {
337         Preconditions.checkArgument(input != null && input.getName() != null && input.getNode() != null && input.getArguments() != null, MISSING_XML_TAG);
338         final OperationalStatus op;
339         final Arguments1 aa = input.getArguments().getAugmentation(Arguments1.class);
340         if (aa != null) {
341             op = aa.getOperational();
342         } else {
343             op = null;
344         }
345
346         // Make sure the LSP exists
347         final InstanceIdentifier<ReportedLsp> lsp = lspIdentifier(input.getName());
348         LOG.debug("Checking if LSP {} has operational state {}", lsp, op);
349         final ListenableFuture<Optional<ReportedLsp>> f = readOperationalData(lsp);
350
351         return Futures.transform(f, new Function<Optional<ReportedLsp>, OperationResult>() {
352             @Override
353             public OperationResult apply(final Optional<ReportedLsp> rep) {
354                 if (!rep.isPresent()) {
355                     LOG.debug("Node {} does not contain LSP {}", input.getNode(), input.getName());
356                     return OperationResults.UNSENT;
357                 }
358
359                 // check if at least one of the paths has the same status as requested
360                 boolean operational = false;
361                 for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.reported.lsp.Path p : rep.get().getPath()) {
362                     final Path1 p1 = p.getAugmentation(Path1.class);
363                     if (p1 == null) {
364                         LOG.warn("Node {} LSP {} does not contain data", input.getNode(), input.getName());
365                         return OperationResults.UNSENT;
366                     }
367                     final Lsp l = p1.getLsp();
368                     if (l.getOperational().equals(op)) {
369                         operational = true;
370                     }
371                 }
372
373                 return operational ? OperationResults.SUCCESS : OperationResults.UNSENT;
374             }
375         });
376     }
377
378     @Override
379     protected Lsp validateReportedLsp(final Optional<ReportedLsp> rep, final LspId input) {
380         if (!rep.isPresent()) {
381             LOG.debug("Node {} does not contain LSP {}", input.getNode(), input.getName());
382             return null;
383         }
384         // it doesn't matter how many lsps there are in the path list, we only need data that is the same in each path
385         final Path1 ra = rep.get().getPath().get(0).getAugmentation(Path1.class);
386         Preconditions.checkState(ra != null, "Reported LSP reported null from data-store.");
387         final Lsp reportedLsp = ra.getLsp();
388         Preconditions.checkState(reportedLsp != null, "Reported LSP does not contain LSP object.");
389         return reportedLsp;
390     }
391 }