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