Charles Chan | 7f987c5 | 2018-07-31 18:22:46 -0700 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.l2lb.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.api.action.Command; |
| 19 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
| 20 | import org.onosproject.cli.AbstractShellCommand; |
| 21 | import org.onosproject.l2lb.api.L2Lb; |
| 22 | import org.onosproject.l2lb.api.L2LbId; |
| 23 | import org.onosproject.l2lb.api.L2LbService; |
| 24 | |
| 25 | import java.util.Map; |
| 26 | |
| 27 | /** |
| 28 | * Command to show all L2 load balancers. |
| 29 | */ |
| 30 | @Service |
| 31 | @Command(scope = "onos", name = "l2lbs", description = "Lists L2 load balancers") |
| 32 | public class L2LbListCommand extends AbstractShellCommand { |
| 33 | @Override |
| 34 | public void doExecute() { |
| 35 | L2LbService service = get(L2LbService.class); |
| 36 | Map<L2LbId, L2Lb> l2LbStore = service.getL2Lbs(); |
| 37 | |
| 38 | l2LbStore.forEach((l2LbId, l2Lb) -> print("%s -> %s, %s", l2LbId, l2Lb.ports(), l2Lb.mode())); |
| 39 | } |
| 40 | } |