Fix 2 Checkstyle problems (red in Eclipse, missed in build)
[genius.git] / interfacemanager / interfacemanager-shell / src / main / java / org / opendaylight / genius / interfacemanager / shell / DumpIfmCache.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.genius.interfacemanager.shell;
9
10 import java.util.Map;
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;
19
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;
25
26     public void setInterfaceManager(IInterfaceManager interfaceManager) {
27         this.interfaceManager = interfaceManager;
28     }
29
30     public void setDataBroker(DataBroker dataBroker) {
31         this.dataBroker = dataBroker;
32     }
33
34     @Override
35     protected Object doExecute() {
36         LOG.debug("Executing show ifm-cache command");
37         Map<String, OvsdbTerminationPointAugmentation> tpMap = interfaceManager.getTerminationPointCache();
38
39         if (tpMap.isEmpty()) {
40             IfmCLIUtil.showInterfaceToTpHeader(session);
41         }
42         for (Entry<String, OvsdbTerminationPointAugmentation> tpEntry: tpMap.entrySet()) {
43             IfmCLIUtil.showInterfaceToTpOutput(tpEntry.getKey(), tpEntry.getValue(), session);
44         }
45         return null;
46     }
47 }