2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.lisp.translate.read;
20 import io.fd.honeycomb.translate.read.ReadContext;
21 import io.fd.honeycomb.translate.read.ReadFailedException;
22 import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
23 import io.fd.honeycomb.translate.vpp.util.ByteDataTranslator;
24 import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
25 import io.fd.honeycomb.translate.vpp.util.JvppReplyConsumer;
26 import java.util.concurrent.TimeoutException;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.lisp.feature.data.grouping.LispFeatureDataBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
30 import org.opendaylight.yangtools.concepts.Builder;
31 import org.opendaylight.yangtools.yang.binding.DataObject;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
33 import io.fd.vpp.jvpp.VppBaseCallException;
34 import io.fd.vpp.jvpp.core.dto.ShowLispPitr;
35 import io.fd.vpp.jvpp.core.dto.ShowLispPitrReply;
36 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
42 * Customizer for reading {@link PitrCfg}<br> Currently unsupported in jvpp
44 public class PitrCfgCustomizer extends FutureJVppCustomizer
45 implements ReaderCustomizer<PitrCfg, PitrCfgBuilder>, ByteDataTranslator, JvppReplyConsumer {
47 private static final Logger LOG = LoggerFactory.getLogger(PitrCfgCustomizer.class);
49 public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
54 public PitrCfgBuilder getBuilder(InstanceIdentifier<PitrCfg> id) {
55 return new PitrCfgBuilder();
59 public void readCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfgBuilder builder, ReadContext ctx)
60 throws ReadFailedException {
61 LOG.debug("Reading status for Lisp Pitr node {}", id);
63 ShowLispPitrReply reply;
66 reply = getPitrStatus();
67 } catch (TimeoutException | VppBaseCallException e) {
68 throw new ReadFailedException(id, e);
71 builder.setLocatorSet(toString(reply.locatorSetName));
72 LOG.debug("Reading status for Lisp Pitr node {} successfull", id);
76 public void merge(Builder<? extends DataObject> parentBuilder, PitrCfg readValue) {
77 ((LispFeatureDataBuilder) parentBuilder).setPitrCfg(readValue);
80 public ShowLispPitrReply getPitrStatus() throws TimeoutException, VppBaseCallException {
81 return getReply(getFutureJVpp().showLispPitr(new ShowLispPitr()).toCompletableFuture());