]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
added reset status control
authorAndrew Tridgell <tridge@samba.org>
Sat, 28 Apr 2007 17:13:36 +0000 (19:13 +0200)
committerAndrew Tridgell <tridge@samba.org>
Sat, 28 Apr 2007 17:13:36 +0000 (19:13 +0200)
(This used to be ctdb commit ec342b667a085a5c740fbeec8882070571071862)

ctdb/common/ctdb_client.c
ctdb/common/ctdb_control.c
ctdb/include/ctdb.h
ctdb/include/ctdb_private.h
ctdb/tools/ctdb_control.c

index 3e3827ce69fd92a12da3fddab6d1d76b3a621d0a..075f8553ae421aa83669236dc64d2472b643273b 100644 (file)
@@ -1054,3 +1054,24 @@ uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, TALLOC_CTX *mem_ct
        talloc_free(map);
        return nodes;
 }
+
+
+/*
+  reset remote status
+ */
+int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode)
+{
+       int ret;
+       TDB_DATA data;
+       int32_t res;
+
+       ZERO_STRUCT(data);
+       ret = ctdb_control(ctdb, destnode, 0, 
+                          CTDB_CONTROL_STATUS_RESET, data, 
+                          NULL, NULL, &res);
+       if (ret != 0 || res != 0) {
+               DEBUG(0,(__location__ " ctdb_control for reset status failed\n"));
+               return -1;
+       }
+       return 0;
+}
index 731aadd5eac9bec913e653acebf6a4ba0272b56c..306323cceb8bd30bd08fae09e287cc52fc311536 100644 (file)
@@ -80,6 +80,12 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                return 0;
        }
 
+       case CTDB_CONTROL_STATUS_RESET: {
+               CHECK_CONTROL_DATA_SIZE(0);
+               ZERO_STRUCT(ctdb->status);
+               return 0;
+       }
+
        case CTDB_CONTROL_GETVNNMAP: {
                uint32_t i, len;
                CHECK_CONTROL_DATA_SIZE(0);
index d512fc0e1a6944f1964afccee11ee376726bfe8e..d9e53d30a94113b4361980ce7128d309045a6325 100644 (file)
@@ -256,4 +256,6 @@ int ctdb_set_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, uint32_t l
 uint32_t *ctdb_get_connected_nodes(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
                                   uint32_t *num_nodes);
 
+int ctdb_status_reset(struct ctdb_context *ctdb, uint32_t destnode);
+
 #endif
index 52a7d66f05fbcecfdd314fee908fe1057df264ba..f9b869c4b20d0e55f5a3c72a72a37c67ed284a66 100644 (file)
@@ -251,7 +251,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
                    CTDB_CONTROL_GET_DEBUG,
                    CTDB_CONTROL_SET_DEBUG,
                    CTDB_CONTROL_GET_DBMAP,
-                   CTDB_CONTROL_GET_NODEMAP};
+                   CTDB_CONTROL_GET_NODEMAP,
+                   CTDB_CONTROL_STATUS_RESET};
 
 enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};
 
index 100215e5e5c922b1272efdae38cca0a275b9c9e2..2cb9fa5142a88538aa7556083acf030a4cd6ea87 100644 (file)
@@ -36,6 +36,7 @@ static void usage(void)
        printf("  ping\n");
        printf("  process-exists <vnn:pid>           see if a process exists\n");
        printf("  status <vnn|all>                   show ctdb status on a node\n");
+       printf("  statusreset <vnn|all>              reset status on a node\n");
        printf("  debug <vnn|all> <level>            set ctdb debug level on a node\n");
        printf("  debuglevel                         display ctdb debug levels\n");
        printf("  getvnnmap <vnn>                    display ctdb vnnmap\n");
@@ -170,6 +171,56 @@ static int control_status(struct ctdb_context *ctdb, int argc, const char **argv
        return 0;
 }
 
+
+/*
+  reset status on all nodes
+ */
+static int control_status_reset_all(struct ctdb_context *ctdb)
+{
+       int ret, i;
+       uint32_t *nodes;
+       uint32_t num_nodes;
+
+       nodes = ctdb_get_connected_nodes(ctdb, ctdb, &num_nodes);
+       CTDB_NO_MEMORY(ctdb, nodes);
+       
+       for (i=0;i<num_nodes;i++) {
+               ret = ctdb_status_reset(ctdb, nodes[i]);
+               if (ret != 0) {
+                       printf("Unable to reset status on node %u\n", nodes[i]);
+                       return ret;
+               }
+       }
+       talloc_free(nodes);
+       return 0;
+}
+
+
+/*
+  reset remote ctdb status
+ */
+static int control_status_reset(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       uint32_t vnn;
+       int ret;
+       if (argc < 1) {
+               usage();
+       }
+
+       if (strcmp(argv[0], "all") == 0) {
+               return control_status_reset_all(ctdb);
+       }
+
+       vnn = strtoul(argv[0], NULL, 0);
+
+       ret = ctdb_status_reset(ctdb, vnn);
+       if (ret != 0) {
+               printf("Unable to reset status on node %u\n", vnn);
+               return ret;
+       }
+       return 0;
+}
+
 /*
   display remote ctdb vnn map
  */
@@ -441,6 +492,8 @@ int main(int argc, const char *argv[])
                ret = control_process_exists(ctdb, extra_argc-1, extra_argv+1);
        } else if (strcmp(control, "status") == 0) {
                ret = control_status(ctdb, extra_argc-1, extra_argv+1);
+       } else if (strcmp(control, "statusreset") == 0) {
+               ret = control_status_reset(ctdb, extra_argc-1, extra_argv+1);
        } else if (strcmp(control, "getvnnmap") == 0) {
                ret = control_getvnnmap(ctdb, extra_argc-1, extra_argv+1);
        } else if (strcmp(control, "getdbmap") == 0) {