2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.interfacemanager.shell;
11 import java.util.Map.Entry;
12 import org.apache.karaf.shell.commands.Command;
13 import org.apache.karaf.shell.console.OsgiCommandSupport;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 @Command(scope = "ifm-cache", name = "show", description = "view the ifm caches")
21 public class DumpIfmCache extends OsgiCommandSupport {
22 private static final Logger LOG = LoggerFactory.getLogger(DumpIfmCache.class);
23 private IInterfaceManager interfaceManager;
24 private DataBroker dataBroker;
26 public void setInterfaceManager(IInterfaceManager interfaceManager) {
27 this.interfaceManager = interfaceManager;
30 public void setDataBroker(DataBroker dataBroker) {
31 this.dataBroker = dataBroker;
35 protected Object doExecute() {
36 LOG.debug("Executing show ifm-cache command");
37 Map<String, OvsdbTerminationPointAugmentation> tpMap = interfaceManager.getTerminationPointCache();
39 if (tpMap.isEmpty()) {
40 IfmCLIUtil.showInterfaceToTpHeader(session);
42 for (Entry<String, OvsdbTerminationPointAugmentation> tpEntry: tpMap.entrySet()) {
43 IfmCLIUtil.showInterfaceToTpOutput(tpEntry.getKey(), tpEntry.getValue(), session);