]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
add a control to shutdown/kill a node
authorRonnie Sahlberg <sahlberg@ronnie>
Thu, 17 May 2007 00:45:31 +0000 (10:45 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Thu, 17 May 2007 00:45:31 +0000 (10:45 +1000)
(This used to be ctdb commit 3802f7304fd59d56062c855987e2561753e85a69)

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 d31ddd5861ecd29e9cb1a5de7d9351062189ca01..cde9584fb76ee9f962d5c3b4eaefcc8549fcd002 100644 (file)
@@ -839,6 +839,27 @@ int ctdb_ctrl_status(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_s
        return 0;
 }
 
+/*
+  shutdown a remote ctdb node
+ */
+int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
+{
+       int ret;
+       TDB_DATA data;
+       int32_t res;
+
+       ZERO_STRUCT(data);
+       ret = ctdb_control(ctdb, destnode, 0, 
+                          CTDB_CONTROL_SHUTDOWN, CTDB_CTRL_FLAG_NOREPLY, data, 
+                          ctdb, &data, &res, &timeout, NULL);
+       if (ret != 0) {
+               DEBUG(0,(__location__ " ctdb_control for shutdown failed\n"));
+               return -1;
+       }
+
+       return 0;
+}
+
 /*
   get vnn map from a remote node
  */
index 79e0eb64dc697d7365d146fae32242550ef2148c..119ca858ea03439076d91271545e41e5fdee4d84 100644 (file)
@@ -240,6 +240,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));              
                return ctdb_control_set_recmode(ctdb, indata, errormsg);
 
+       case CTDB_CONTROL_SHUTDOWN:
+               exit(10);
+
        default:
                DEBUG(0,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index 9292fd6e53265c59e26a9716c8aa07814c36c293..59bfbdea115fa2125494924fffb40f4f371de66a 100644 (file)
@@ -203,6 +203,8 @@ struct ctdb_context *ctdb_cmdline_client(struct event_context *ev);
 struct ctdb_status;
 int ctdb_ctrl_status(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_status *status);
 
+int ctdb_ctrl_shutdown(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
+
 struct ctdb_vnn_map;
 int ctdb_ctrl_getvnnmap(struct ctdb_context *ctdb, 
                struct timeval timeout, uint32_t destnode, 
index ca045c18d1a17525516567d655e955508fb9ee80..79be2e489c0b9944303214ffd66a10e0333cb00b 100644 (file)
@@ -353,6 +353,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
                    CTDB_CONTROL_FREEZE,
                    CTDB_CONTROL_THAW,
                    CTDB_CONTROL_GET_VNN,
+                   CTDB_CONTROL_SHUTDOWN,
 };
 
 
index 1c3e047033af3c26274d6e89b7272e0063d7947a..f8691fe5fdc3fc764d1c9b6e16e1b9fd5f6a57bd 100644 (file)
@@ -57,6 +57,7 @@ static void usage(void)
                "  setrecmaster <vnn> <master_vnn>    set recovery master\n"
                "  attach <dbname>                    attach a database\n"
                "  getpid <vnn>                       get the pid of a ctdb daemon\n"
+               "  shutdown <vnn>                     shutdown a remote ctdb\n"
                "  freeze <vnn|all>                   freeze a node\n"
                "  thaw <vnn|all>                     thaw a node\n"
        );
@@ -343,6 +344,30 @@ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv
        return 0;
 }
 
+/*
+  shutdown a daemon
+ */
+static int control_shutdown(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+       uint32_t vnn;
+       int ret;
+
+
+       if (argc < 1) {
+               usage();
+       }
+
+       vnn     = strtoul(argv[0], NULL, 0);
+
+       ret = ctdb_ctrl_shutdown(ctdb, timeval_current_ofs(1, 0), vnn);
+       if (ret != 0) {
+               printf("Unable to shutdown node %u\n", vnn);
+               return ret;
+       }
+
+       return 0;
+}
+
 /*
   display recovery mode of a remote node
  */
@@ -973,6 +998,7 @@ int main(int argc, const char *argv[])
                { "attach", control_attach },
                { "dumpmemory", control_dumpmemory },
                { "getpid", control_getpid },
+               { "shutdown", control_shutdown },
                { "freeze", control_freeze },
                { "thaw", control_thaw },
        };