2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. 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.clustering.it.karaf.cli;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.concurrent.ExecutionException;
12 import org.apache.karaf.shell.api.action.Action;
13 import org.opendaylight.mdsal.dom.api.DOMRpcResult;
15 public abstract class AbstractDOMRpcAction implements Action {
17 @SuppressWarnings("checkstyle:RegexpSinglelineJava")
18 public final Object execute() throws InterruptedException, ExecutionException {
19 final DOMRpcResult result = invokeRpc().get();
20 if (!result.getErrors().isEmpty()) {
21 // FIXME: is there a better way to report errors?
22 System.out.println("Invocation failed: " + result.getErrors());
25 return result.getResult().prettyTree().get();
29 protected abstract ListenableFuture<? extends DOMRpcResult> invokeRpc();