7b3003cb52486aeb6f3a12023bf9703769c3b29e
[unimgr.git] / cli / src / main / java / org / opendaylight / vcpe / cli / UniRemoveShellCommand.java
1 /*
2  * Copyright (c) 2015 CableLabs 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.vcpe.cli;
9
10 import org.apache.karaf.shell.commands.Argument;
11 import org.apache.karaf.shell.commands.Command;
12 import org.apache.karaf.shell.console.OsgiCommandSupport;
13 import org.opendaylight.vcpe.api.IVcpeConsoleProvider;
14
15 @Command(name = "remove", scope = "uni", description = "Removes an Uni from the controller.")
16 public class UniRemoveShellCommand extends OsgiCommandSupport {
17
18     protected IVcpeConsoleProvider provider;
19
20     @Argument(index = 0, name = "id", description = "Uni Id", required = true, multiValued = false)
21     String id;
22
23     public UniRemoveShellCommand(IVcpeConsoleProvider provider) {
24         this.provider = provider;
25     }
26
27     @Override
28     protected Object doExecute() throws Exception {
29         if (provider.removeUni(id)) {
30             return String.format("Uni successfully removed");
31         } else {
32             return String.format("Error removing Uni");
33         }
34     }
35 }