Yuta HIGUCHI | f167bf9 | 2017-03-08 13:19:04 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Yuta HIGUCHI | f167bf9 | 2017-03-08 13:19:04 -0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.newoptical.cli; |
| 17 | |
| 18 | import java.util.Collection; |
| 19 | import java.util.stream.Collectors; |
| 20 | |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 21 | import org.apache.karaf.shell.api.action.Command; |
Ray Milkey | 7a2dee5 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 22 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
Yuta HIGUCHI | f167bf9 | 2017-03-08 13:19:04 -0800 | [diff] [blame] | 23 | import org.onosproject.cli.AbstractShellCommand; |
| 24 | import org.onosproject.net.LinkKey; |
| 25 | import org.onosproject.newoptical.OpticalConnectivity; |
| 26 | import org.onosproject.newoptical.api.OpticalPathService; |
| 27 | |
Ray Milkey | 7a2dee5 | 2018-09-28 10:58:28 -0700 | [diff] [blame] | 28 | @Service |
Yuta HIGUCHI | f167bf9 | 2017-03-08 13:19:04 -0800 | [diff] [blame] | 29 | @Command(scope = "onos", name = "list-optical-connectivity", |
| 30 | description = "List optical domain connectivity") |
| 31 | public class ListOpticalConnectivityCommand extends AbstractShellCommand { |
| 32 | |
| 33 | @Override |
Ray Milkey | 86ad7bb | 2018-09-27 12:32:28 -0700 | [diff] [blame] | 34 | protected void doExecute() { |
Yuta HIGUCHI | f167bf9 | 2017-03-08 13:19:04 -0800 | [diff] [blame] | 35 | OpticalPathService opticalPathService = get(OpticalPathService.class); |
| 36 | |
| 37 | Collection<OpticalConnectivity> connectivities = opticalPathService.listConnectivity(); |
| 38 | |
| 39 | for (OpticalConnectivity connectivity : connectivities) { |
| 40 | print("Optical connectivity ID: %s", connectivity.id().id()); |
| 41 | print(" links: %s", |
| 42 | connectivity.links().stream() |
| 43 | .map(LinkKey::linkKey) |
| 44 | .map(lk -> lk.src() + "-" + lk.dst()) |
| 45 | .collect(Collectors.joining(", "))); |
| 46 | print(" Bandwidth: %s, Latency: %s", connectivity.bandwidth(), connectivity.latency()); |
Yuta HIGUCHI | 8ac0509 | 2017-03-15 00:41:22 -0700 | [diff] [blame] | 47 | print(" Intent Keys: %s", |
| 48 | opticalPathService.listIntents(connectivity.id())); |
Yuta HIGUCHI | f167bf9 | 2017-03-08 13:19:04 -0800 | [diff] [blame] | 49 | |
| 50 | } |
| 51 | } |
| 52 | } |