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 / ShowVxlan.java
1 /*
2  * Copyright (c) 2016 - 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.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
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 = "vxlan", name = "show", description = "view the configured vxlan ports")
24 public class ShowVxlan extends OsgiCommandSupport {
25     private static final Logger logger = LoggerFactory.getLogger(ShowVxlan.class);
26     private IInterfaceManager interfaceManager;
27     private DataBroker dataBroker;
28
29     public void setInterfaceManager(IInterfaceManager interfaceManager) {
30         this.interfaceManager = interfaceManager;
31     }
32
33     public void setDataBroker(DataBroker dataBroker){
34         this.dataBroker = dataBroker;
35     }
36
37     @Override
38     protected Object doExecute() throws Exception {
39         logger.debug("Executing show Vxlan command");
40         List<Interface> vxlanList = interfaceManager.getVxlanInterfaces();
41         if (!vxlanList.isEmpty()) {
42             IfmCLIUtil.showVxlanHeaderOutput();
43         }
44         for (Interface iface : vxlanList) {
45             InterfaceInfo ifaceState = interfaceManager.getInterfaceInfoFromOperationalDataStore(iface.getName());
46             IfmCLIUtil.showVxlanOutput(iface, ifaceState);
47         }
48         return null;
49     }
50 }