a038d47dc09403be07e9347df9ef9cd73a62c8c8
[netvirt.git] / vpnservice / neutronvpn / neutronvpn-shell / src / main / java / org / opendaylight / netvirt / neutronvpn / shell / ShowVpnConfigCommand.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
9 package org.opendaylight.netvirt.neutronvpn.shell;
10
11 import org.apache.karaf.shell.commands.Command;
12 import org.apache.karaf.shell.commands.Option;
13 import org.apache.karaf.shell.console.OsgiCommandSupport;
14 import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
16
17 @Command(scope = "vpnservice", name = "l3vpn-config-show", description = "Displays Neutron L3VPN configuration")
18 public class ShowVpnConfigCommand extends OsgiCommandSupport {
19
20     @Option(name = "-vid", aliases = {"--vpnid"}, description = "VPN ID", required = false, multiValued = false)
21     String vid;
22
23     private INeutronVpnManager neutronVpnManager;
24
25     public void setNeutronVpnManager(INeutronVpnManager neutronVpnManager) {
26         this.neutronVpnManager = neutronVpnManager;
27     }
28
29     @Override
30     protected Object doExecute() throws Exception {
31         Uuid vuuid = null;
32         if (vid != null) {
33             vuuid = new Uuid(vid);
34         }
35
36         for (String p : neutronVpnManager.showVpnConfigCLI(vuuid)) {
37             session.getConsole().println(p);
38         }
39         return null;
40     }
41 }