Magnesium platform upgrade
[lispflowmapping.git] / mappingservice / shell / src / main / java / org / opendaylight / lispflowmapping / shell / LispKeys.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc.  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.lispflowmapping.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.lispflowmapping.interfaces.mappingservice.IMappingServiceShell;
15
16 /**
17  * This class implements the "mappingservice:keys" Karaf shell command.
18  *
19  * @author Lorand Jakab
20  *
21  */
22 @Command(scope = "mappingservice", name = "keys", description = "Print LISP authentication keys")
23 public class LispKeys  extends OsgiCommandSupport {
24     @Option(name = "-d", aliases = "--debug", description = "Debug output", required = false, multiValued = false)
25     private boolean debug;
26
27     private IMappingServiceShell mappingServiceShell;
28
29     /*
30      * TODO  Eventually it would be best to merge the addkey command into this one, using optional arguments.
31      */
32
33     @Override
34     @SuppressWarnings("checkstyle:RegexpSinglelineJava")
35     protected Object doExecute() throws Exception {
36         if (mappingServiceShell != null) {
37             if (debug) {
38                 System.out.print(mappingServiceShell.printKeys());
39             } else {
40                 System.out.print(mappingServiceShell.prettyPrintKeys());
41             }
42         }
43         return null;
44     }
45
46     public void setMappingServiceShell(IMappingServiceShell mappingServiceShell) {
47         this.mappingServiceShell = mappingServiceShell;
48     }
49 }