cd3af2cf1add615a8b8dfa6a6b9140d0e6019d91
[genius.git] / interfacemanager / interfacemanager-shell / src / main / java / org / opendaylight / genius / interfacemanager / shell / ShowVlan.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.interfacemanager.shell;
9
10 import java.util.List;
11
12 import org.apache.karaf.shell.commands.Command;
13 import org.apache.karaf.shell.console.OsgiCommandSupport;
14 import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
15 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 @Command(scope = "vlan", name = "show", description = "view the configured vlan ports")
21 public class ShowVlan extends OsgiCommandSupport {
22     private static final Logger LOG = LoggerFactory.getLogger(ShowVlan.class);
23     private IInterfaceManager interfaceManager;
24
25     public void setInterfaceManager(IInterfaceManager interfaceManager) {
26         this.interfaceManager = interfaceManager;
27     }
28
29     @Override
30     protected Object doExecute() {
31         LOG.debug("Executing show VLAN command");
32         List<Interface> vlanList = interfaceManager.getVlanInterfaces();
33         if (!vlanList.isEmpty()) {
34             IfmCLIUtil.showVlanHeaderOutput(session);
35         }
36         for (Interface iface : vlanList) {
37             InterfaceInfo ifaceState = interfaceManager.getInterfaceInfoFromOperationalDSCache(iface.getName());
38             IfmCLIUtil.showVlanOutput(ifaceState, iface, session);
39         }
40         return null;
41     }
42 }