blob: d8ad1ca1ec8d28f4ccc2b2c815feca770b121738 [file] [log] [blame]
Annce John0b4057a2017-11-21 01:46:41 -05001/*
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 */
16
17package org.onosproject.ra.cli;
18
19import java.util.List;
20
Ray Milkey7a2dee52018-09-28 10:58:28 -070021import org.apache.karaf.shell.api.action.lifecycle.Service;
Annce John0b4057a2017-11-21 01:46:41 -050022import org.onosproject.net.DeviceId;
23import org.onosproject.net.host.InterfaceIpAddress;
24import org.onosproject.ra.RoutingAdvertisementService;
25import org.onosproject.cli.AbstractShellCommand;
26
Ray Milkey86ad7bb2018-09-27 12:32:28 -070027import org.apache.karaf.shell.api.action.Command;
Annce John0b4057a2017-11-21 01:46:41 -050028
29import com.google.common.collect.ImmutableMap;
30
31/**
32 * Command to list global-prefixes in Routing Advertisement.
33 */
Ray Milkey7a2dee52018-09-28 10:58:28 -070034@Service
Annce John0b4057a2017-11-21 01:46:41 -050035@Command(scope = "onos", name = "ra-global-prefixes",
36 description = "List Routing Advertisement global prefixes")
37public class GlobalPrefixesListCommand extends AbstractShellCommand {
38
39 @Override
Ray Milkey86ad7bb2018-09-27 12:32:28 -070040 protected void doExecute() {
Annce John0b4057a2017-11-21 01:46:41 -050041 RoutingAdvertisementService raService =
42 AbstractShellCommand.get(RoutingAdvertisementService.class);
43 printGlobalPrefixes(raService.getGlobalPrefixes());
44 }
45
46 private void printGlobalPrefixes(ImmutableMap<DeviceId, List<InterfaceIpAddress>> globalPrefixes) {
47 globalPrefixes.forEach(((deviceId, interfaceIpAddresses) -> {
48 print("%s", deviceId);
49 interfaceIpAddresses.forEach(interfaceIpAddress -> print(" %s", interfaceIpAddress));
50 }));
51 }
52}
53