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.samples.interfaces.mapping;
19 import com.google.common.collect.Lists;
20 import com.google.inject.Inject;
21 import io.fd.honeycomb.samples.interfaces.mapping.cfgattrs.InterfacesPluginConfiguration;
22 import io.fd.honeycomb.translate.write.WriteContext;
23 import java.util.ArrayList;
24 import javax.annotation.Nonnull;
25 import org.opendaylight.yang.gen.v1.io.fd.honeycomb.samples.interfaces.rev160810.interfaces.Interface;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * This is a sample class representing common resource for readers and writers to access the lower layer
33 public final class LowerLayerAccess {
35 private static final Logger LOG = LoggerFactory.getLogger(LowerLayerAccess.class);
38 public LowerLayerAccess(@Nonnull final InterfacesPluginConfiguration configuration) {
39 LOG.info("Creating lower layer access with configuration: {}", configuration);
42 public void writeInterface(final InstanceIdentifier<Interface> id, final Interface dataAfter,
43 final WriteContext writeContext) {
44 LOG.info("Writing interface: {}. to {}", dataAfter, id);
45 // This is where actual write/propagation happens
49 public void deleteInterface(final InstanceIdentifier<Interface> id, final Interface dataBefore,
50 final WriteContext writeContext) {
51 LOG.info("Deleting interface: {}. to {}", dataBefore, id);
52 final String ifcToBeDeleted = id.firstKeyOf(Interface.class).getInterfaceId().getValue();
53 // This is where actual write/propagation happens
56 public long getTotalPacketsForInterface(final String ifcName) {
60 public long getDroppedPacketsForIfc(final String ifcName) {
64 public ArrayList<String> getAllInterfaceNames() {
65 return Lists.newArrayList("ifc1", "ifc2");
68 public int getMtuForInterface(final String ifcName) {