blob: e1504f583599c1a9be908586bf933d6d4f9f66ef [file] [log] [blame]
Charles Chan7f987c52018-07-31 18:22:46 -07001/*
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.l2lb.cli;
17
18import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.lifecycle.Service;
20import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.l2lb.api.L2Lb;
22import org.onosproject.l2lb.api.L2LbId;
23import org.onosproject.l2lb.api.L2LbService;
24
25import 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")
32public 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}