2 * Copyright (c) 2015 Inocybe and others. All rights reserved.
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
9 package org.opendaylight.vcpe.cli;
11 import java.util.List;
13 import org.apache.karaf.shell.commands.Command;
14 import org.apache.karaf.shell.commands.Option;
15 import org.apache.karaf.shell.console.OsgiCommandSupport;
16 import org.opendaylight.vcpe.api.IVcpeConsoleProvider;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vcpe.rev150622.unis.Uni;
19 @Command(name = "list", scope = "uni", description = "Lists all uni in the controller.")
20 public class UniListShellCommand extends OsgiCommandSupport {
22 protected IVcpeConsoleProvider provider;
25 aliases = { "--config" },
26 description = "List Configuration Data (optional).\n-c / --config <ENTER>",
29 Boolean isConfigurationData = false;
31 public UniListShellCommand(IVcpeConsoleProvider provider) {
32 this.provider = provider;
36 protected Object doExecute() throws Exception {
38 List<Uni> listUnis = provider.listUnis(isConfigurationData);
40 if (listUnis.size() > 0) {
41 StringBuilder sb = new StringBuilder();
43 for (Uni uni : listUnis) {
44 sb.append(String.format("#%d - id: %s\n", counter, uni.getId()));
49 return String.format("No uni found. Check the logs for more details.");