blob: 7acbac816c0446ff2bf049b81b4d35d48896ce0e [file] [log] [blame]
amit.ghosh6104cf52021-01-07 16:53:28 +01001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
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.opencord.olttopology.cli;
17
18import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.lifecycle.Service;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.net.ConnectPoint;
22import org.opencord.olttopology.OltNeighborInfo;
23import org.opencord.olttopology.OltTopologyInformationService;
24
25import java.util.Map;
26
27/**
28 * OLT Topology CLI Command.
29 * <p>
30 * Shows the current topology in the CLI.
31 */
32@Service
33@Command(scope = "onos", name = "olt-topology", description = "OLT Topology CLI command")
34public class OltTopologyGetCommand extends AbstractShellCommand {
35
36 private static final String FORMAT = "%s";
37
38 private OltTopologyInformationService oltTopoSer = get(OltTopologyInformationService.class);
39
40 @Override
41 protected void doExecute() {
42 oltTopoSer.getNeighbours().entrySet().forEach(this::display);
43 }
44
45 private void display(Map.Entry<ConnectPoint, OltNeighborInfo> neighbor) {
46 print(FORMAT, neighbor.getValue());
47 }
48}