blob: 0fa466d83686d69a001926f7773fba5d282c2305 [file] [log] [blame]
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -08003 *
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
Ray Milkey86ad7bb2018-09-27 12:32:28 -070021import org.apache.karaf.shell.api.action.Command;
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -080022import 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
Ray Milkey86ad7bb2018-09-27 12:32:28 -070032 protected void doExecute() {
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -080033 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());
Yuta HIGUCHI8ac05092017-03-15 00:41:22 -070045 print(" Intent Keys: %s",
46 opticalPathService.listIntents(connectivity.id()));
Yuta HIGUCHIf167bf92017-03-08 13:19:04 -080047
48 }
49 }
50}