2 * Copyright (c) 2016, 2017 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.itm.cli;
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;
17 @Command(scope = "tep", name = "show-state", description = "Monitors tunnel state")
19 public class TepShowState extends OsgiCommandSupport {
21 private final IITMProvider itmProvider;
22 private final TunnelStateCache tunnelStateCache;
24 public TepShowState(IITMProvider itmProvider, TunnelStateCache tunnelStateCache) {
25 this.itmProvider = itmProvider;
26 this.tunnelStateCache = tunnelStateCache;
30 protected Object doExecute() {
31 Collection<StateTunnelList> tunnels = tunnelStateCache.getAllPresent();
32 if (!tunnels.isEmpty()) {
33 itmProvider.showState(tunnels, session);
35 session.getConsole().println("No Internal Tunnels configured on the switch");