blob: ebd949c6652797093b97d11628a00020a6d14c43 [file] [log] [blame]
daniel parkb5817102018-02-15 00:18:51 +09001/*
2 * Copyright 2018-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.onosproject.openstacknetworking.cli;
17
18import com.google.common.collect.Lists;
19import org.apache.karaf.shell.commands.Command;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.openstacknetworking.api.ExternalPeerRouter;
22import org.onosproject.openstacknetworking.api.OpenstackNetworkService;
23
24import java.util.List;
25
26/**
27 * Lists external peer router lists.
28 */
29@Command(scope = "onos", name = "openstack-peer-routers",
30 description = "Lists external peer router lists")
31public class ExternalPeerRouterListCommand extends AbstractShellCommand {
32
33 private static final String FORMAT = "%-20s%-20s%-20s";
34
35 @Override
36 protected void execute() {
37 OpenstackNetworkService service = AbstractShellCommand.get(OpenstackNetworkService.class);
38
39 print(FORMAT, "Router IP", "Mac Address", "VLAN ID");
40 List<ExternalPeerRouter> routers = Lists.newArrayList(service.externalPeerRouters());
41
42 for (ExternalPeerRouter router: routers) {
43 print(FORMAT, router.externalPeerRouterIp(),
44 router.externalPeerRouterMac().toString(),
45 router.externalPeerRouterVlanId());
46 }
47 }
48}