2 * Copyright (c) 2020 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.OfTepStateCache;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.of.teps.state.OfTep;
17 @Command(scope = "tep", name = "show-ofports", description = "Monitors of ports")
19 public class TepShowOfPorts extends OsgiCommandSupport {
21 private final IITMProvider itmProvider;
22 private final OfTepStateCache ofTepStateCache;
24 public TepShowOfPorts(IITMProvider itmProvider, OfTepStateCache ofTepStateCache) {
25 this.itmProvider = itmProvider;
26 this.ofTepStateCache = ofTepStateCache;
30 @SuppressWarnings("checkstyle:RegexpSinglelineJava")
31 protected Object doExecute() {
32 Collection<OfTep> ofPorts = ofTepStateCache.getAllPresent();
33 if (!ofPorts.isEmpty()) {
34 itmProvider.showOfPorts(ofPorts);
36 System.out.println("No OF ports configured on the switch");