2 * Copyright (c) 2017 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.hc2vpp.v3po.interfacesstate.span;
19 import io.fd.hc2vpp.common.translate.util.NamingContext;
20 import io.fd.hc2vpp.v3po.interfacesstate.InterfaceCustomizer;
21 import io.fd.honeycomb.translate.read.ReadContext;
22 import io.fd.honeycomb.translate.spi.read.Initialized;
23 import io.fd.honeycomb.translate.util.RWUtils;
24 import io.fd.vpp.jvpp.core.future.FutureJVppCore;
25 import javax.annotation.Nonnull;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.VppInterfaceAugmentation;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.interfaces.state._interface.SpanBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.span.attributes.MirroredInterfaces;
30 import org.opendaylight.yangtools.concepts.Builder;
31 import org.opendaylight.yangtools.yang.binding.DataObject;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
35 * Provides interface-specific logic to read/init port mirroring configuration
37 public class InterfaceMirroredInterfacesCustomizer extends AbstractMirroredInterfacesCustomizer {
39 public InterfaceMirroredInterfacesCustomizer(@Nonnull final FutureJVppCore futureJVppCore,
40 @Nonnull final NamingContext ifcContext) {
41 super(futureJVppCore, ifcContext, id -> id.firstKeyOf(Interface.class).getName());
46 public Initialized<? extends DataObject> init(@Nonnull final InstanceIdentifier<MirroredInterfaces> id,
47 @Nonnull final MirroredInterfaces readValue,
48 @Nonnull final ReadContext ctx) {
49 final InstanceIdentifier<MirroredInterfaces> cfgId =
50 InterfaceCustomizer.getCfgId(RWUtils.cutId(id, Interface.class))
51 .augmentation(VppInterfaceAugmentation.class)
52 .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev170315.interfaces._interface.Span.class)
53 .child(MirroredInterfaces.class);
54 return Initialized.create(cfgId, readValue);
58 public void merge(@Nonnull Builder<? extends DataObject> builder, @Nonnull MirroredInterfaces mirroredInterfaces) {
59 ((SpanBuilder) builder).setMirroredInterfaces(mirroredInterfaces);