Replace DataStoreCache with DataObjectCache in itm-impl
[genius.git] / itm / itm-impl / src / main / java / org / opendaylight / genius / itm / cli / TepShowState.java
1 /*
2  * Copyright (c) 2016, 2017 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.itm.cli;
9
10 import java.util.Collection;
11 import org.apache.karaf.shell.commands.Command;
12 import org.apache.karaf.shell.console.OsgiCommandSupport;
13 import org.opendaylight.genius.itm.api.IITMProvider;
14 import org.opendaylight.genius.itm.cache.TunnelStateCache;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList;
16
17 @Command(scope = "tep", name = "show-state", description = "Monitors tunnel state")
18
19 public class TepShowState extends OsgiCommandSupport {
20
21     private final IITMProvider itmProvider;
22     private final TunnelStateCache tunnelStateCache;
23
24     public TepShowState(IITMProvider itmProvider, TunnelStateCache tunnelStateCache) {
25         this.itmProvider = itmProvider;
26         this.tunnelStateCache = tunnelStateCache;
27     }
28
29     @Override
30     protected Object doExecute() {
31         Collection<StateTunnelList> tunnels = tunnelStateCache.getAllPresent();
32         if (!tunnels.isEmpty()) {
33             itmProvider.showState(tunnels, session);
34         } else {
35             session.getConsole().println("No Internal Tunnels configured on the switch");
36         }
37         return null;
38     }
39 }