Cleanup cluster-admin.yang 33/85033/6
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 10 Oct 2019 11:08:00 +0000 (13:08 +0200)
committerStephen Kitt <skitt@redhat.com>
Mon, 21 Oct 2019 07:30:18 +0000 (07:30 +0000)
We are redefining the same leaves over and over, make sure we
define them in a grouping for common definition. Also ensure
shard name requires at least one character -- just as we expect
it to happen in the implementation.

Change-Id: I917d8a7767467dceb4f3e076ffca4b5aa4b048a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-cluster-admin-api/src/main/yang/cluster-admin.yang

index a6ee3dd8043a611955988ca598457df6c86c6568..3acd0794e4280bf8c37ad0e7ed0367dcf5c08d78 100644 (file)
@@ -21,14 +21,29 @@ module cluster-admin {
         }
     }
 
-    grouping shard-operation-result {
+    grouping datastore-shard-id {
+        description "Grouping holding combined identifiers of a shard -- its name and datastore type";
+
         leaf shard-name {
-            type string;
+            description "The name of the shard.";
+            mandatory true;
+            type string {
+                length "1..max" {
+                    error-app-tag "odl-named-shards";
+                    error-message "Shard name must not be empty";
+                }
+            }
         }
 
         leaf data-store-type {
+            mandatory true;
             type data-store-type;
+            description "The type of the data store to which the shard belongs";
         }
+    }
+
+    grouping shard-operation-result {
+        uses datastore-shard-id;
 
         leaf succeeded {
             type boolean;
@@ -64,72 +79,42 @@ module cluster-admin {
 
     rpc add-shard-replica {
         input {
-            leaf shard-name {
-                mandatory true;
-                type string;
-                description "The name of the shard for which to create a replica.";
-            }
-
-            leaf data-store-type {
-                mandatory true;
-                type data-store-type;
-                description "The type of the data store to which the replica belongs";
-            }
+            uses datastore-shard-id;
         }
 
         description "Adds a replica of a shard to this node and joins it to an existing cluster. The shard must
-            already have a module configuration defined for it and there must already be a shard existing on
-            another node with a leader. This RPC first contacts peer member seed nodes searching for a shard.
-            When found, an AddServer message is sent to the shard leader and applied as described in the Raft
-            paper.";
+                     already have a module configuration defined for it and there must already be a shard existing on
+                     another node with a leader. This RPC first contacts peer member seed nodes searching for a shard.
+                     When found, an AddServer message is sent to the shard leader and applied as described in the Raft
+                     paper.";
     }
 
     rpc remove-shard-replica {
         input {
-            leaf shard-name {
-                mandatory true;
-                type string;
-                description "The name of the shard for which to remove the replica.";
-            }
+            uses datastore-shard-id;
 
             leaf member-name {
                 mandatory true;
                 type string;
                 description "The cluster member from which the shard replica should be removed";
             }
-
-            leaf data-store-type {
-                mandatory true;
-                type data-store-type;
-                description "The type of the data store to which the replica belongs";
-            }
         }
 
         description "Removes an existing replica of a shard from this node via the RemoveServer mechanism as
-            described in the Raft paper.";
+                     described in the Raft paper.";
     }
 
     rpc make-leader-local {
         input {
-            leaf shard-name {
-                mandatory true;
-                type string;
-                description "The name of the shard for which to move the leader to the local node";
-            }
-
-            leaf data-store-type {
-                mandatory true;
-                type data-store-type;
-                description "The type of the data store to which the shard belongs";
-            }
+            uses datastore-shard-id;
         }
 
         description "Attempts to move the shard leader of the given module based shard to the local node.
-                The rpc returns a response after handling of the underlying MakeLeaderLocal message completes.
-                This operation fails if there is no current shard leader due to lack of network connectivity or
-                a cluster majority. In addition, if the local node is not up to date with the current leader,
-                an attempt is made to first sync the local node with the leader. If this cannot be achieved
-                within two election timeout periods the operation fails.";
+                     The rpc returns a response after handling of the underlying MakeLeaderLocal message completes.
+                     This operation fails if there is no current shard leader due to lack of network connectivity or
+                     a cluster majority. In addition, if the local node is not up to date with the current leader,
+                     an attempt is made to first sync the local node with the leader. If this cannot be achieved
+                     within two election timeout periods the operation fails.";
     }
 
     rpc add-prefix-shard-replica {
@@ -147,9 +132,9 @@ module cluster-admin {
         }
 
         description "Adds a replica of a shard to this node and joins it to an existing cluster. There must already be
-                    a shard existing on another node with a leader. This RPC first contacts peer member seed nodes
-                    searching for a shard. When found, an AddServer message is sent to the shard leader and applied as
-                    described in the Raft paper.";
+                     a shard existing on another node with a leader. This RPC first contacts peer member seed nodes
+                     searching for a shard. When found, an AddServer message is sent to the shard leader and applied as
+                     described in the Raft paper.";
     }
 
     rpc remove-prefix-shard-replica {
@@ -172,7 +157,7 @@ module cluster-admin {
         }
 
         description "Removes an existing replica of a prefix shard from this node via the RemoveServer mechanism as
-                    described in the Raft paper.";
+                     described in the Raft paper.";
     }
 
     rpc add-replicas-for-all-shards {
@@ -181,7 +166,7 @@ module cluster-admin {
         }
 
         description "Adds replicas on this node for all currently defined shards. This is equivalent to issuing
-            an add-shard-replica RPC for all shards.";
+                     an add-shard-replica RPC for all shards.";
     }
 
     rpc remove-all-shard-replicas {
@@ -198,31 +183,20 @@ module cluster-admin {
         }
 
         description "Removes replicas for all shards on this node. This is equivalent to issuing
-            a remove-shard-replica for all shards and essentially removes this node from a cluster.";
+                     a remove-shard-replica for all shards and essentially removes this node from a cluster.";
     }
 
     rpc change-member-voting-states-for-shard {
         input {
-            leaf shard-name {
-                mandatory true;
-                type string;
-                description "The name of the shard for which to change voting state.";
-            }
-
-            leaf data-store-type {
-                mandatory true;
-                type data-store-type;
-                description "The type of the data store to which the shard belongs";
-            }
-
+            uses datastore-shard-id;
             uses member-voting-states-input;
         }
 
         description "Changes the voting states, either voting or non-voting, of cluster members for a shard.
-            Non-voting members will no longer participate in leader elections and consensus but will be
-            replicated. This is useful for having a set of members serve as a backup cluster in case the
-            primary voting cluster suffers catastrophic failure. This RPC can be issued to any cluster member
-            and will be forwarded to the leader.";
+                     Non-voting members will no longer participate in leader elections and consensus but will be
+                     replicated. This is useful for having a set of members serve as a backup cluster in case the
+                     primary voting cluster suffers catastrophic failure. This RPC can be issued to any cluster member
+                     and will be forwarded to the leader.";
     }
 
     rpc change-member-voting-states-for-all-shards {
@@ -235,10 +209,10 @@ module cluster-admin {
         }
 
         description "Changes the voting states, either voting or non-voting, of cluster members for all shards.
-            Non-voting members will no longer participate in leader elections and consensus but will be
-            replicated. This is useful for having a set of members serve as a backup cluster in case the
-            primary voting cluster suffers catastrophic failure. This RPC can be issued to any cluster member
-            and will be forwarded to the leader.";
+                     Non-voting members will no longer participate in leader elections and consensus but will be
+                     replicated. This is useful for having a set of members serve as a backup cluster in case the
+                     primary voting cluster suffers catastrophic failure. This RPC can be issued to any cluster member
+                     and will be forwarded to the leader.";
     }
 
     rpc flip-member-voting-states-for-all-shards {
@@ -247,7 +221,7 @@ module cluster-admin {
         }
 
         description "Flips the voting states of all cluster members for all shards, such that if a member
-            was voting it becomes non-voting and vice versa.";
+                     was voting it becomes non-voting and vice versa.";
     }
 
     rpc backup-datastore {
@@ -263,23 +237,13 @@ module cluster-admin {
 
     rpc get-shard-role {
         input {
-            leaf shard-name {
-                mandatory true;
-                type string;
-                description "The name of the shard for which to create a replica.";
-            }
-
-            leaf data-store-type {
-                mandatory true;
-                type data-store-type;
-                description "The type of the data store to which the replica belongs";
-            }
+            uses datastore-shard-id;
         }
 
         output {
             leaf role {
                 type string;
-                description "Current role for the given shard, if not present the shard currently doesn't have a role";
+                description "Current role for the given shard, if not present the shard currently does not have a role";
             }
         }
 
@@ -303,10 +267,10 @@ module cluster-admin {
         output {
             leaf role {
                 type string;
-                description "Current role for the given shard, if not present the shard currently doesn't have a role";
+                description "Current role for the given shard, if not present the shard currently does not have a role";
             }
         }
 
         description "Returns the current role for the requested module shard.";
     }
-}
\ No newline at end of file
+}