blob: 77ad95da25fc1aac5407f55044e29624e589671f [file] [log] [blame]
Akihiro Yamanouchi8d3a9d32016-07-12 11:41:44 +09001/*
Ray Milkey85267002016-11-16 11:06:35 -08002 * Copyright 2016-present Open Networking Laboratory
Akihiro Yamanouchi8d3a9d32016-07-12 11:41:44 +09003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.drivers.fujitsu.cli;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.net.DeviceId;
22import org.onosproject.drivers.fujitsu.behaviour.VoltOnuConfig;
23import org.onosproject.net.driver.DriverHandler;
24import org.onosproject.net.driver.DriverService;
25
26/**
27 * Gets ONU statistics in vOLT.
28 */
29@Command(scope = "onos", name = "volt-onustats",
30 description = "Gets ONU statistics in vOLT")
31public class VoltGetOnuStatsCommand extends AbstractShellCommand {
32
33 @Argument(index = 0, name = "uri", description = "Device ID",
34 required = true, multiValued = false)
35 String uri = null;
36
37 @Argument(index = 1, name = "target", description = "PON link ID-ONU ID",
38 required = false, multiValued = false)
39 String target = null;
40
41 private DeviceId deviceId;
42
43 @Override
44 protected void execute() {
45 DriverService service = get(DriverService.class);
46 deviceId = DeviceId.deviceId(uri);
47 DriverHandler h = service.createHandler(deviceId);
48 VoltOnuConfig volt = h.behaviour(VoltOnuConfig.class);
49 String reply = volt.getOnuStatistics(target);
50 if (reply != null) {
51 print("%s", reply);
52 } else {
53 print("No reply from %s", deviceId.toString());
54 }
55 }
56
57}