2 * Copyright (c) 2020 Ericsson India Global Services Pvt Ltd. and others. 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.openflowplugin.applications.southboundcli.cli;
10 import static org.opendaylight.openflowplugin.applications.southboundcli.util.ShellUtil.LINE_SEPARATOR;
12 import java.util.ArrayList;
13 import org.apache.karaf.shell.api.action.Action;
14 import org.apache.karaf.shell.api.action.Command;
15 import org.apache.karaf.shell.api.action.lifecycle.Reference;
16 import org.apache.karaf.shell.api.action.lifecycle.Service;
17 import org.apache.karaf.shell.api.console.Session;
18 import org.opendaylight.openflowplugin.applications.frm.ReconciliationJMXServiceMBean;
21 @Command(scope = "openflow", name = "getreconciliationstate",
22 description = "Print reconciliation state for all devices")
23 public final class GetReconciliationStateCommand implements Action {
27 ReconciliationJMXServiceMBean reconciliationJMXServiceMBean;
30 public Object execute() {
31 if (reconciliationJMXServiceMBean == null) {
36 final var reconciliationStates = reconciliationJMXServiceMBean.acquireReconciliationStates();
37 if (!reconciliationStates.isEmpty()) {
38 final var result = new ArrayList<String>();
39 reconciliationStates.forEach((datapathId, reconciliationState) -> {
40 String status = String.format("%-17s %-50s", datapathId, reconciliationState);
43 session.getConsole().println(getHeaderOutput());
44 session.getConsole().println(LINE_SEPARATOR);
45 result.stream().forEach(p -> session.getConsole().println(p));
47 session.getConsole().println("Reconciliation data not available");
52 private static String getHeaderOutput() {
53 return String.format("%-17s %-25s %-25s", "DatapathId", "Reconciliation Status", "Reconciliation Time");