Modified scm section.
[unimgr.git] / cli / src / main / java / org / opendaylight / vcpe / cli / UniShowShellCommand.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 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vcpe.rev150622.unis.Uni;
15
16 @Command(name = "show", scope = "uni", description = "Shows detailed information about an uni.")
17 public class UniShowShellCommand extends OsgiCommandSupport {
18
19     protected IVcpeConsoleProvider provider;
20
21     @Argument(index = 0, name = "id", description = "Uni Id", required = true, multiValued = false)
22     String id;
23
24     public UniShowShellCommand(IVcpeConsoleProvider provider) {
25         this.provider = provider;
26     }
27
28     @Override
29     protected Object doExecute() throws Exception {
30         StringBuilder sb = new StringBuilder();
31         Uni uni = provider.getUni(id);
32
33         if (uni != null) {
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()));
42             return sb.toString();
43         } else {
44             return String.format("No uni found. Check the logs for more details.");
45         }
46     }
47 }