delete uni command
[unimgr.git] / cli / src / main / java / org / opendaylight / unimgr / 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.unimgr.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.unimgr.api.IUnimgrConsoleProvider;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
15
16 @Command(name = "uni-remove", scope = "uni", description = "Removes an Uni from the controller.")
17 public class UniRemoveShellCommand extends OsgiCommandSupport {
18
19     protected IUnimgrConsoleProvider provider;
20
21     @Argument(index = 0, name = "ip", description = "Uni ipAddress", required = true, multiValued = false)
22     String ipAddress;
23
24     public UniRemoveShellCommand(IUnimgrConsoleProvider provider) {
25         this.provider = provider;
26     }
27
28     @Override
29     protected Object doExecute() throws Exception {
30         IpAddress ipAddre = new IpAddress(ipAddress.toCharArray());
31         if (provider.removeUni(ipAddre)) {
32             return String.format("Uni successfully removed");
33         } else {
34             return String.format("Error removing Uni");
35         }
36     }
37 }