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.unimgr.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.unimgr.api.IUnimgrConsoleProvider;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
17 @Command(name = "uni-show", scope = "uni", description = "Shows detailed information about an uni.")
18 public class UniShowShellCommand extends OsgiCommandSupport {
20 protected IUnimgrConsoleProvider provider;
22 @Argument(index = 0, name = "ip", description = "Uni ipAddress", required = true, multiValued = false)
25 public UniShowShellCommand(IUnimgrConsoleProvider provider) {
26 this.provider = provider;
30 protected Object doExecute() throws Exception {
31 StringBuilder sb = new StringBuilder();
32 IpAddress ipAddre = new IpAddress(ipAddress.toCharArray());
33 UniAugmentation uni = provider.getUni(ipAddre);
36 sb.append(String.format("Ip Address: <%s>\n", uni.getIpAddress().getIpv4Address().getValue()));
37 sb.append(String.format("Mac address: <%s>\n", uni.getMacAddress()));
38 sb.append(String.format("Physical medium: <%s>\n", uni.getPhysicalMedium()));
39 sb.append(String.format("Speed: " + uni.getSpeed() + "\n"));
40 sb.append(String.format("Mode: <%s>\n", uni.getMode()));
41 sb.append(String.format("Mac layer: <%s>\n", uni.getMacLayer()));
42 sb.append(String.format("Type: <%s>\n", uni.getType()));
43 sb.append(String.format("Mtu size: <%s>\n", uni.getMtuSize()));
46 return String.format("No uni found. Check the logs for more details.");