2 * Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
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
8 package org.opendaylight.protocol.bgp.cli.utils;
10 import static org.opendaylight.protocol.bgp.cli.utils.NeighborStateCliUtils.addHeader;
12 import java.io.PrintStream;
13 import java.util.Collection;
14 import org.apache.karaf.shell.support.table.ShellTable;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State;
17 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.PeerGroupStateAugmentation;
20 // PeerGroupStateCliUtils sends Peer Group Operational State to PrintStream
21 final class PeerGroupStateCliUtils {
22 private PeerGroupStateCliUtils() {
26 static void displayPeerOperationalState(@NonNull final Collection<PeerGroup> peerGroupList,
27 @NonNull final PrintStream stream) {
28 final ShellTable table = new ShellTable();
29 table.column("Attribute").alignLeft();
30 table.column("Value").alignLeft();
32 peerGroupList.forEach(group -> displayState(group, table));
36 private static void displayState(final PeerGroup group, final ShellTable table) {
37 addHeader(table, "Peer Group state");
38 table.addRow().addContent("Peer Group Name", group.getPeerGroupName());
39 final State state = group.getState();
43 final PeerGroupStateAugmentation aug = state.augmentation(PeerGroupStateAugmentation.class);
44 table.addRow().addContent("Total Prefixes", aug.getTotalPrefixes());