Migrate to MD-SAL APIs
[bgpcep.git] / bgp / cli / src / main / java / org / opendaylight / protocol / bgp / cli / OperationalStateCommandProvider.java
1 /*
2  * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.bgp.cli;
9
10 import org.apache.karaf.shell.api.action.Action;
11 import org.apache.karaf.shell.api.action.Command;
12 import org.apache.karaf.shell.api.action.Option;
13 import org.apache.karaf.shell.api.action.lifecycle.Reference;
14 import org.apache.karaf.shell.api.action.lifecycle.Service;
15 import org.apache.karaf.shell.api.console.Session;
16 import org.opendaylight.mdsal.binding.api.DataBroker;
17 import org.opendaylight.protocol.bgp.cli.utils.BGPOperationalStateUtils;
18
19 @Service
20 @Command(scope = "bgp", name = "operational-state", description = "Shows BGP Operational State.")
21 public final class OperationalStateCommandProvider implements Action {
22     @Reference
23     private Session session;
24     @Reference
25     private DataBroker dataBroker;
26     @Option(name = "-neighbor", aliases = {"--neighbor"}, description = "Neighbor address")
27     private String peer;
28     @Option(name = "-rib", aliases = {"--rib"}, description = "Name of RIB", required = true)
29     private String ribId;
30     @Option(name = "-peer-group", aliases = {"--peer-group"}, description = "Name of Peer Group")
31     private String group;
32
33     @Override
34     public Object execute() {
35         BGPOperationalStateUtils.displayBgpOperationalState(this.dataBroker, this.session.getConsole(),
36                 this.ribId, this.group, this.peer);
37         return null;
38     }
39 }