2 * Copyright (c) 2015 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.write;
19 import io.fd.honeycomb.lisp.translate.write.trait.SubtableWriter;
20 import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
21 import io.fd.honeycomb.translate.vpp.util.FutureJVppCustomizer;
22 import io.fd.honeycomb.translate.write.WriteContext;
23 import io.fd.honeycomb.translate.write.WriteFailedException;
24 import java.util.concurrent.TimeoutException;
25 import javax.annotation.Nonnull;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.VrfSubtable;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import io.fd.vpp.jvpp.VppBaseCallException;
29 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
33 public class VrfSubtableCustomizer extends FutureJVppCustomizer
34 implements WriterCustomizer<VrfSubtable>, SubtableWriter {
36 private static final Logger LOG = LoggerFactory.getLogger(VrfSubtableCustomizer.class);
38 public VrfSubtableCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
43 public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<VrfSubtable> id,
44 @Nonnull final VrfSubtable dataAfter, @Nonnull final WriteContext writeContext)
45 throws WriteFailedException {
47 LOG.debug("Writing Id[{}]/Data[{}]", id, dataAfter);
50 addDelSubtableMapping(getFutureJVpp(), true, extractVni(id), dataAfter.getTableId().intValue(), false, LOG);
51 } catch (TimeoutException | VppBaseCallException e) {
52 throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
55 LOG.debug("{} successfully written", id);
59 public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<VrfSubtable> id,
60 @Nonnull final VrfSubtable dataBefore, @Nonnull final VrfSubtable dataAfter,
61 @Nonnull final WriteContext writeContext) throws WriteFailedException {
62 throw new UnsupportedOperationException("Operation not supported");
66 public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<VrfSubtable> id,
67 @Nonnull final VrfSubtable dataBefore, @Nonnull final WriteContext writeContext)
68 throws WriteFailedException {
70 LOG.debug("Removing Id[{}]/Data[{}]", id, dataBefore);
73 addDelSubtableMapping(getFutureJVpp(), false, extractVni(id), dataBefore.getTableId().intValue(), false,
75 } catch (TimeoutException | VppBaseCallException e) {
76 throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
79 LOG.debug("{} successfully removed", id);