ctdb-client: Add sync api for DB_ATTACH_REPLICATED control
authorAmitay Isaacs <amitay@gmail.com>
Mon, 26 Jun 2017 05:55:15 +0000 (15:55 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 29 Jun 2017 08:34:27 +0000 (10:34 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/client/client_control_sync.c
ctdb/client/client_sync.h

index db2d7be15bee25f5e5f6d1950d908a92580b8fea..43a941d79dba302832e159424a8f75ba24f350f2 100644 (file)
@@ -2728,3 +2728,33 @@ int ctdb_ctrl_db_open_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 
        return 0;
 }
+
+int ctdb_ctrl_db_attach_replicated(TALLOC_CTX *mem_ctx,
+                                  struct tevent_context *ev,
+                                  struct ctdb_client_context *client,
+                                  int destnode, struct timeval timeout,
+                                  const char *db_name, uint32_t *db_id)
+{
+       struct ctdb_req_control request;
+       struct ctdb_reply_control *reply;
+       int ret;
+
+       ctdb_req_control_db_attach_replicated(&request, db_name);
+       ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
+                                 &request, &reply);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,
+                     ("Control DB_ATTACH_REPLICATED failed to node %u,"
+                      " ret=%d\n", destnode, ret));
+               return ret;
+       }
+
+       ret = ctdb_reply_control_db_attach_replicated(reply, db_id);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,
+                     ("Control DB_ATTACH_REPLICATED failed, ret=%d\n", ret));
+               return ret;
+       }
+
+       return 0;
+}
index 7bf58e6e2dc8e7a32e67baf07c7977358444fec3..a4b5c49ab0b717946c6a1494ce05b9b0dd802030 100644 (file)
@@ -488,6 +488,12 @@ int ctdb_ctrl_db_open_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                            int destnode, struct timeval timeout,
                            uint32_t db_id, int *tdb_flags);
 
+int ctdb_ctrl_db_attach_replicated(TALLOC_CTX *mem_ctx,
+                                  struct tevent_context *ev,
+                                  struct ctdb_client_context *client,
+                                  int destnode, struct timeval timeout,
+                                  const char *db_name, uint32_t *db_id);
+
 /* from client/client_message_sync.c */
 
 int ctdb_message_recd_update_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,