Introduce cli commands for cluster-admin 34/97434/9
authorDominik Vrbovsky <dominik.vrbovsky@pantheon.tech>
Fri, 10 Sep 2021 09:09:41 +0000 (11:09 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Sep 2021 19:55:33 +0000 (21:55 +0200)
Rework the rpcs needed by csit in cluster-admin to karaf cli commands

JIRA: CONTROLLER-1996
Change-Id: I148c7c9140701ff8ffe81c612999898115f4661d
Signed-off-by: Dominik Vrbovsky <dominik.vrbovsky@pantheon.tech>
19 files changed:
artifacts/pom.xml
features/odl-clustering-test-app/pom.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-cluster-admin-karaf-cli/pom.xml [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AbstractRpcAction.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ActivateEosDatacenterCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AddReplicasForAllShardsCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AddShardReplicaCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/BackupDatastoreCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ChangeMemberVotingStatesForAllShardsCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ChangeMemberVotingStatesForShardCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/DeactivateEosDatacenterCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/FlipMemberVotingStatesForAllShardsCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/GetKnownClientsForAllShardsCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/GetShardRoleCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/LocateShardCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/MakeLeaderLocalCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/RemoveAllShardReplicasCommand.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/RemoveShardReplicaCommand.java [new file with mode: 0644]

index 620476d..c1b6fb2 100644 (file)
                 <artifactId>sal-cluster-admin-impl</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.controller</groupId>
+                <artifactId>sal-cluster-admin-karaf-cli</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>org.opendaylight.controller</groupId>
                 <artifactId>cds-dom-api</artifactId>
index 9e82988..55d7c85 100644 (file)
@@ -43,5 +43,9 @@
             <groupId>org.opendaylight.controller.samples</groupId>
             <artifactId>clustering-it-karaf-cli</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-cluster-admin-karaf-cli</artifactId>
+        </dependency>
     </dependencies>
 </project>
index 6e348f0..c088c93 100644 (file)
@@ -46,6 +46,7 @@
     <module>sal-dummy-distributed-datastore</module>
     <module>sal-cluster-admin-api</module>
     <module>sal-cluster-admin-impl</module>
+    <module>sal-cluster-admin-karaf-cli</module>
 
     <!-- Entity Ownership Service on top of Akka Distributed Data/Singleton -->
     <module>eos-dom-akka</module>
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/pom.xml b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/pom.xml
new file mode 100644 (file)
index 0000000..2b1eca5
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>mdsal-parent</artifactId>
+        <groupId>org.opendaylight.controller</groupId>
+        <version>4.0.4-SNAPSHOT</version>
+        <relativePath>../parent/pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>sal-cluster-admin-karaf-cli</artifactId>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-cluster-admin-impl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>mdsal-binding-api</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+                <version>${karaf.version}</version>
+                <executions>
+                    <execution>
+                        <id>service-metadata-generate</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>service-metadata-generate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AbstractRpcAction.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AbstractRpcAction.java
new file mode 100644 (file)
index 0000000..0a85b56
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.ExecutionException;
+import org.apache.karaf.shell.api.action.Action;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+
+/**
+ * Common base class for all commands which end up invoking an RPC.
+ */
+public abstract class AbstractRpcAction implements Action {
+    @Override
+    @SuppressWarnings("checkstyle:RegexpSinglelineJava")
+    public final Object execute() throws InterruptedException, ExecutionException {
+        final RpcResult<?> result = invokeRpc().get();
+        if (!result.isSuccessful()) {
+            // FIXME: is there a better way to report errors?
+            System.out.println("Invocation failed: " + result.getErrors());
+        }
+        return null;
+    }
+
+    protected abstract ListenableFuture<? extends RpcResult<?>> invokeRpc();
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ActivateEosDatacenterCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ActivateEosDatacenterCommand.java
new file mode 100644 (file)
index 0000000..6f7b8d4
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ActivateEosDatacenterInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "activate-eos-datacenter", description = "Run an activate-eos-datacenter test")
+public class ActivateEosDatacenterCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .activateEosDatacenter(new ActivateEosDatacenterInputBuilder().build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AddReplicasForAllShardsCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AddReplicasForAllShardsCommand.java
new file mode 100644 (file)
index 0000000..5189f08
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddReplicasForAllShardsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "add-replicas-for-all-shards",
+        description = "Run an add-replicas-for-all-shards test")
+public class AddReplicasForAllShardsCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .addReplicasForAllShards(new AddReplicasForAllShardsInputBuilder().build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AddShardReplicaCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/AddShardReplicaCommand.java
new file mode 100644 (file)
index 0000000..77c039e
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.AddShardReplicaInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "add-shard-replica", description = "Run an add-shard-replica test")
+public class AddShardReplicaCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "shard-name", required = true)
+    private String shardName;
+    @Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
+    private String dataStoreType;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .addShardReplica(new AddShardReplicaInputBuilder()
+                        .setShardName(shardName)
+                        .setDataStoreType(DataStoreType.forName(dataStoreType).orElse(null))
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/BackupDatastoreCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/BackupDatastoreCommand.java
new file mode 100644 (file)
index 0000000..9574bc0
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.BackupDatastoreInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
+@Service
+@Command(scope = "cluster-admin", name = "backup-datastore", description = "Run a backup-datastore test")
+public class BackupDatastoreCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "file-path", required = true)
+    private String filePath;
+    @Argument(index = 1, name = "timeout", required = true)
+    private long timeout;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .backupDatastore(new BackupDatastoreInputBuilder()
+                        .setFilePath(filePath)
+                        .setTimeout(Uint32.valueOf(timeout))
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ChangeMemberVotingStatesForAllShardsCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ChangeMemberVotingStatesForAllShardsCommand.java
new file mode 100644 (file)
index 0000000..d8fb0a4
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForAllShardsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingStateBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+
+@Service
+@Command(scope = "cluster-admin", name = "change-member-voting-states-for-all-shards",
+        description = "Run a change-member-voting-states-for-all-shards test")
+public class ChangeMemberVotingStatesForAllShardsCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "member-name", required = true)
+    private String memberName;
+    @Argument(index = 1, name = "voting", required = true)
+    private boolean voting;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        final MemberVotingState memberVotingState = new MemberVotingStateBuilder()
+                .setMemberName(memberName)
+                .setVoting(voting)
+                .build();
+
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .changeMemberVotingStatesForAllShards(new ChangeMemberVotingStatesForAllShardsInputBuilder()
+                        .setMemberVotingState(List.of(memberVotingState))
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ChangeMemberVotingStatesForShardCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/ChangeMemberVotingStatesForShardCommand.java
new file mode 100644 (file)
index 0000000..cbfd570
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.List;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ChangeMemberVotingStatesForShardInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.member.voting.states.input.MemberVotingStateBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "change-member-voting-states-for-shard",
+        description = "Run a change-member-voting-states-for-shard test")
+public class ChangeMemberVotingStatesForShardCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "shard-name", required = true)
+    private String shardName;
+    @Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
+    private String dataStoreType;
+    @Argument(index = 2, name = "member-name", required = true)
+    private String memberName;
+    @Argument(index = 3, name = "voting", required = true)
+    private boolean voting;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        final MemberVotingState memberVotingState = new MemberVotingStateBuilder()
+                .setMemberName(memberName)
+                .setVoting(voting)
+                .build();
+
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .changeMemberVotingStatesForShard(new ChangeMemberVotingStatesForShardInputBuilder()
+                        .setShardName(shardName)
+                        .setDataStoreType(DataStoreType.forName(dataStoreType).orElse(null))
+                        .setMemberVotingState(List.of(memberVotingState))
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/DeactivateEosDatacenterCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/DeactivateEosDatacenterCommand.java
new file mode 100644 (file)
index 0000000..e0fd59d
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DeactivateEosDatacenterInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "deactivate-eos-datacenter",
+        description = "Run a deactivate-eos-datacenter test")
+public class DeactivateEosDatacenterCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .deactivateEosDatacenter(new DeactivateEosDatacenterInputBuilder().build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/FlipMemberVotingStatesForAllShardsCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/FlipMemberVotingStatesForAllShardsCommand.java
new file mode 100644 (file)
index 0000000..ac523ac
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.FlipMemberVotingStatesForAllShardsInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin",name = "flip-member-voting-states-for-all-shards",
+        description = "Run a flip-member-voting-states-for-all-shards test")
+public class FlipMemberVotingStatesForAllShardsCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .flipMemberVotingStatesForAllShards(new FlipMemberVotingStatesForAllShardsInputBuilder().build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/GetKnownClientsForAllShardsCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/GetKnownClientsForAllShardsCommand.java
new file mode 100644 (file)
index 0000000..be55c00
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetKnownClientsForAllShardsInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "get-known-clients-for-all-shards",
+        description = "Run a get-known-clients-for-all-shards test")
+public class GetKnownClientsForAllShardsCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .getKnownClientsForAllShards(new GetKnownClientsForAllShardsInputBuilder().build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/GetShardRoleCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/GetShardRoleCommand.java
new file mode 100644 (file)
index 0000000..8e91427
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.GetShardRoleInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "get-shard-role", description = "Run a get-shard-role test")
+public class GetShardRoleCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "shard-name", required = true)
+    private String shardName;
+    @Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
+    private String dataStoreType;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .getShardRole(new GetShardRoleInputBuilder()
+                        .setShardName(shardName)
+                        .setDataStoreType(DataStoreType.forName(dataStoreType).orElse(null))
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/LocateShardCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/LocateShardCommand.java
new file mode 100644 (file)
index 0000000..13d99a8
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.LocateShardInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "locate-shard", description = "Run a locate-shard test")
+public class LocateShardCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "shard-name", required = true)
+    private String shardName;
+    @Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
+    private String dataStoreType;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .locateShard(new LocateShardInputBuilder()
+                        .setShardName(shardName)
+                        .setDataStoreType(DataStoreType.forName(dataStoreType).orElse(null))
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/MakeLeaderLocalCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/MakeLeaderLocalCommand.java
new file mode 100644 (file)
index 0000000..3b1c145
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.MakeLeaderLocalInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "make-leader-local", description = "Run a make-leader-local test")
+public class MakeLeaderLocalCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "shard-name", required = true)
+    private String shardName;
+    @Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
+    private String dataStoreType;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .makeLeaderLocal(new MakeLeaderLocalInputBuilder()
+                        .setShardName(shardName)
+                        .setDataStoreType(DataStoreType.forName(dataStoreType).orElse(null))
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/RemoveAllShardReplicasCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/RemoveAllShardReplicasCommand.java
new file mode 100644 (file)
index 0000000..97f3a79
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemoveAllShardReplicasInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "remove-all-shard-replicas",
+        description = "Run a remove-all-shard-replicas test")
+public class RemoveAllShardReplicasCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "member-name",required = true)
+    private String memberName;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .removeAllShardReplicas(new RemoveAllShardReplicasInputBuilder()
+                        .setMemberName(memberName)
+                        .build());
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/RemoveShardReplicaCommand.java b/opendaylight/md-sal/sal-cluster-admin-karaf-cli/src/main/java/org/opendaylight/controller/cluster/datastore/admin/command/RemoveShardReplicaCommand.java
new file mode 100644 (file)
index 0000000..e4a7864
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.admin.command;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.DataStoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.RemoveShardReplicaInputBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@Service
+@Command(scope = "cluster-admin", name = "remove-shard-replica", description = "Run a remove-shard-replica")
+public class RemoveShardReplicaCommand extends AbstractRpcAction {
+    @Reference
+    private RpcConsumerRegistry rpcConsumerRegistry;
+    @Argument(index = 0, name = "shard-name", required = true)
+    private String shardName;
+    @Argument(index = 1, name = "data-store-type", required = true, description = "config / operational")
+    private String dataStoreType;
+    @Argument(index = 2, name = "member-name", required = true)
+    private String memberName;
+
+    @Override
+    protected ListenableFuture<? extends RpcResult<?>> invokeRpc() {
+        return rpcConsumerRegistry.getRpcService(ClusterAdminService.class)
+                .removeShardReplica(new RemoveShardReplicaInputBuilder()
+                        .setShardName(shardName)
+                        .setDataStoreType(DataStoreType.forName(dataStoreType).orElse(null))
+                        .setMemberName(memberName)
+                        .build());
+    }
+}