2 * Copyright (c) 2015 CableLabs 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
8 package org.opendaylight.vcpe.cli;
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 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vcpe.rev150622.unis.Uni;
16 @Command(name = "show", scope = "uni", description = "Shows detailed information about an uni.")
17 public class UniShowShellCommand extends OsgiCommandSupport {
19 protected IVcpeConsoleProvider provider;
21 @Argument(index = 0, name = "id", description = "Uni Id", required = true, multiValued = false)
24 public UniShowShellCommand(IVcpeConsoleProvider provider) {
25 this.provider = provider;
29 protected Object doExecute() throws Exception {
30 StringBuilder sb = new StringBuilder();
31 Uni uni = provider.getUni(id);
34 sb.append(String.format("Uni Id: <%s>\n", uni.getId()));
35 sb.append(String.format("Physical medium: <%s>\n", uni.getPhysicalMedium()));
36 sb.append(String.format("Mac address: <%s>\n", uni.getMacAddress()));
37 sb.append(String.format("Speed: " + uni.getSpeed() + "\n"));
38 sb.append(String.format("Mode: <%s>\n", uni.getMode()));
39 sb.append(String.format("Mac layer: <%s>\n", uni.getMacLayer()));
40 sb.append(String.format("Type: <%s>\n", uni.getType()));
41 sb.append(String.format("Mtu size: <%s>\n", uni.getMtuSize()));
44 return String.format("No uni found. Check the logs for more details.");