s3-rpcclient: add clusapi_pause_node command.
authorGünther Deschner <gd@samba.org>
Mon, 9 May 2016 10:07:47 +0000 (12:07 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 8 Jan 2020 23:51:31 +0000 (23:51 +0000)
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpcclient/cmd_clusapi.c

index 04cb1be6251810d33c0b9763301c7614caab2721..9776a8dde65f68ad37abb9ca6a9ceeac7bfa1c89 100644 (file)
@@ -501,6 +501,61 @@ static WERROR cmd_clusapi_get_cluster_version2(struct rpc_pipe_client *cli,
        return WERR_OK;
 }
 
+static WERROR cmd_clusapi_pause_node(struct rpc_pipe_client *cli,
+                                    TALLOC_CTX *mem_ctx,
+                                    int argc,
+                                    const char **argv)
+{
+       struct dcerpc_binding_handle *b = cli->binding_handle;
+       NTSTATUS status;
+       const char *lpszNodeName = "CTDB_NODE_0";
+       WERROR Status;
+       struct policy_handle hNode;
+       WERROR rpc_status;
+       WERROR result, ignore;
+
+       if (argc >= 2) {
+               lpszNodeName = argv[1];
+       }
+
+       status = dcerpc_clusapi_OpenNode(b, mem_ctx,
+                                        lpszNodeName,
+                                        &Status,
+                                        &rpc_status,
+                                        &hNode);
+       if (!NT_STATUS_IS_OK(status)) {
+               return ntstatus_to_werror(status);
+       }
+
+       if (!W_ERROR_IS_OK(Status)) {
+               printf("Failed to open node %s\n", lpszNodeName);
+               printf("Status: %s\n", win_errstr(Status));
+               return Status;
+       }
+
+       status = dcerpc_clusapi_PauseNode(b, mem_ctx,
+                                         hNode,
+                                         &rpc_status,
+                                         &result);
+       if (!NT_STATUS_IS_OK(status)) {
+               return ntstatus_to_werror(status);
+       }
+       if (!W_ERROR_IS_OK(result)) {
+               printf("Failed to pause node %s\n", lpszNodeName);
+               printf("Status: %s\n", win_errstr(result));
+               return result;
+       }
+
+       dcerpc_clusapi_CloseNode(b, mem_ctx,
+                                &hNode,
+                                &ignore);
+
+       printf("Cluster node %s has been paused\n", lpszNodeName);
+       printf("rpc_status: %s\n", win_errstr(rpc_status));
+
+       return WERR_OK;
+}
+
 
 struct cmd_set clusapi_commands[] = {
 
@@ -617,6 +672,16 @@ struct cmd_set clusapi_commands[] = {
                .description        = "Get cluster version2",
                .usage              = "",
        },
+       {
+               .name               = "clusapi_pause_node",
+               .returntype         = RPC_RTYPE_WERROR,
+               .ntfn               = NULL,
+               .wfn                = cmd_clusapi_pause_node,
+               .table              = &ndr_table_clusapi,
+               .rpc_pipe           = NULL,
+               .description        = "Pause cluster node",
+               .usage              = "",
+       },
        {
                .name = NULL,
        },