blob: fa8bf0a7402aa854ff54e8502ea787a21b699abf [file] [log] [blame]
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -08001/*
2 * Copyright 2016-present Open Networking Laboratory
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.onosproject.newoptical.cli;
17
18import java.util.Collection;
19import java.util.stream.Collectors;
20
21import org.apache.karaf.shell.commands.Command;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.net.LinkKey;
24import org.onosproject.newoptical.OpticalConnectivity;
25import org.onosproject.newoptical.api.OpticalPathService;
26
27@Command(scope = "onos", name = "list-optical-connectivity",
28 description = "List optical domain connectivity")
29public class ListOpticalConnectivityCommand extends AbstractShellCommand {
30
31 @Override
32 protected void execute() {
33 OpticalPathService opticalPathService = get(OpticalPathService.class);
34
35 Collection<OpticalConnectivity> connectivities = opticalPathService.listConnectivity();
36
37 for (OpticalConnectivity connectivity : connectivities) {
38 print("Optical connectivity ID: %s", connectivity.id().id());
39 print(" links: %s",
40 connectivity.links().stream()
41 .map(LinkKey::linkKey)
42 .map(lk -> lk.src() + "-" + lk.dst())
43 .collect(Collectors.joining(", ")));
44 print(" Bandwidth: %s, Latency: %s", connectivity.bandwidth(), connectivity.latency());
45
46 }
47 }
48}