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 javax.annotation.Nonnull;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
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.ShowLispStatus;
35 import io.fd.vpp.jvpp.core.dto.ShowLispStatusReply;
36 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
42 * Customizer that handles reads of {@code LispState}
44 public class LispStateCustomizer extends FutureJVppCustomizer
45 implements ReaderCustomizer<LispState, LispStateBuilder>, JvppReplyConsumer, ByteDataTranslator {
47 private static final Logger LOG = LoggerFactory.getLogger(LispStateCustomizer.class);
49 public LispStateCustomizer(FutureJVppCore futureJvpp) {
54 public LispStateBuilder getBuilder(InstanceIdentifier<LispState> id) {
55 return new LispStateBuilder();
59 public void readCurrentAttributes(InstanceIdentifier<LispState> id, LispStateBuilder builder, ReadContext ctx)
60 throws ReadFailedException {
62 ShowLispStatusReply reply;
64 reply = getReply(getFutureJVpp().showLispStatus(new ShowLispStatus()).toCompletableFuture());
65 } catch (TimeoutException | VppBaseCallException e) {
66 throw new ReadFailedException(id, e);
69 builder.setEnable(byteToBoolean(reply.featureStatus));
73 public void merge(@Nonnull final Builder<? extends DataObject> parentBuilder, @Nonnull final LispState readValue) {
74 LOG.warn("Merge is unsupported for data roots");