]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
merged admin enable/disable change from ronnie
authorAndrew Tridgell <tridge@samba.org>
Thu, 7 Jun 2007 01:15:22 +0000 (11:15 +1000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 7 Jun 2007 01:15:22 +0000 (11:15 +1000)
(This used to be ctdb commit df17b69dfd83a98f9c711994c7dd51ad2cc0ab8a)

1  2 
ctdb/common/ctdb_control.c
ctdb/common/ctdb_monitor.c
ctdb/include/ctdb_private.h
ctdb/tools/ctdb_control.c

index ac2522131f67b52f0e83a6e75181742d4a4fa95c,83a4ee33a6472df8c302688b642e23a3e33a6ddc..e22cc7f07325e5c7b902b0e7018c08632e64c702
@@@ -288,6 -288,15 +288,10 @@@ static int32_t ctdb_control_dispatch(st
        case CTDB_CONTROL_LIST_TUNABLES:
                return ctdb_control_list_tunables(ctdb, outdata);
  
 -              if ( *(uint32_t *)indata.dptr ){
 -                      ctdb->nodes[ctdb->vnn]->flags |= NODE_FLAGS_PERMANENTLY_DISABLED;
 -              } else {
 -                      ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_PERMANENTLY_DISABLED;
 -              }
 -              return 0;
+       case CTDB_CONTROL_PERMANENTLY_DISABLE:
+               CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
++              return ctdb_control_permdisable(ctdb, indata);
        default:
                DEBUG(0,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index 166ee65df963e40d320c41d58a284b1e3b07c0ad,8461dca242c385be72388728a6ea62852ef3e2d6..3b838e6e047437c22275d0f56a4778e54b7549d9
@@@ -104,12 -104,17 +104,12 @@@ static void ctdb_health_callback(struc
                        timeval_current_ofs(ctdb->tunable.monitor_interval, 0), 
                        ctdb_check_health, ctdb);
  
-       if (status != 0 && !(node->flags & NODE_FLAGS_DISABLED)) {
 -      if (node->flags & NODE_FLAGS_PERMANENTLY_DISABLED) {
 -              if ( !(node->flags & NODE_FLAGS_DISABLED) ) {
 -                      DEBUG(0,("monitoring - node is permanently disabled\n"));
 -                      node->flags |= NODE_FLAGS_DISABLED;
 -              }
 -      } else if (status != 0 && !(node->flags & NODE_FLAGS_DISABLED)) {
++      if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) {
                DEBUG(0,("monitor event failed - disabling node\n"));
--              node->flags |= NODE_FLAGS_DISABLED;
--      } else if (status == 0 && (node->flags & NODE_FLAGS_DISABLED)) {
++              node->flags |= NODE_FLAGS_UNHEALTHY;
++      } else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) {
                DEBUG(0,("monitor event OK - node re-enabled\n"));
--              ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_DISABLED;
++              ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_UNHEALTHY;
        } else {
                /* no change */
                return;
        /* tell the other nodes that something has changed */
        ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP,
                                 CTDB_SRVID_NODE_FLAGS_CHANGED, data);
++
  }
  
  
@@@ -181,3 -186,3 +182,33 @@@ void ctdb_start_monitoring(struct ctdb_
                             ctdb_check_health, ctdb);
        CTDB_NO_MEMORY_FATAL(ctdb, te);
  }
++
++
++/*
++  administratively disable/enable a node 
++ */
++int32_t ctdb_control_permdisable(struct ctdb_context *ctdb, TDB_DATA indata)
++{
++      uint32_t set = *(uint32_t *)indata.dptr;
++      TDB_DATA data;
++      struct ctdb_node_flag_change c;
++      struct ctdb_node *node = ctdb->nodes[ctdb->vnn];
++
++      if (set) {
++              node->flags |= NODE_FLAGS_PERMANENTLY_DISABLED;
++      } else {
++              node->flags &= ~NODE_FLAGS_PERMANENTLY_DISABLED;
++      }
++
++      c.vnn = ctdb->vnn;
++      c.flags = node->flags;
++
++      data.dptr = (uint8_t *)&c;
++      data.dsize = sizeof(c);
++
++      /* tell the other nodes that something has changed */
++      ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP,
++                               CTDB_SRVID_NODE_FLAGS_CHANGED, data);
++      
++      return 0;
++}
index 0e5e361d70ccbc04299d2dbfab15a97ef14df109,c22c8a6d99665bac6e5288ad39a36eedda7e0c9e..2ec30817620ae50d26fa3a4f3d86a9e7ee78a0a8
@@@ -111,8 -111,9 +111,10 @@@ struct ctdb_node 
        const char *name; /* for debug messages */
        void *private_data; /* private to transport */
        uint32_t vnn;
- #define NODE_FLAGS_CONNECTED 0x00000001
- #define NODE_FLAGS_DISABLED  0x00000002
+ #define NODE_FLAGS_CONNECTED          0x00000001
 -#define NODE_FLAGS_DISABLED           0x00000002
++#define NODE_FLAGS_UNHEALTHY                  0x00000002
+ #define NODE_FLAGS_PERMANENTLY_DISABLED       0x00000004
++#define NODE_FLAGS_DISABLED           (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
        uint32_t flags;
  
        /* used by the dead node monitoring */
@@@ -1007,4 -1009,4 +1010,6 @@@ int32_t ctdb_control_list_tunables(stru
  
  void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
  
++int32_t ctdb_control_permdisable(struct ctdb_context *ctdb, TDB_DATA indata);
++
  #endif
index d5ffbd96be1e57aeb88c4a7a9c9693ded9385a06,94c5be3b41d712267c4f2f3f9b20254b5d72f3f7..3525fd672c5052723511167343ea7ff605f63686
@@@ -285,11 -285,13 +285,13 @@@ static int control_status(struct ctdb_c
        }
  
        if(options.machinereadable){
-               printf(":Node:IP:Status:\n");
+               printf(":Node:IP:Connected:Disabled:Permanently Disabled:\n");
                for(i=0;i<nodemap->num;i++){
-                       printf(":%d:%s:%d:\n", nodemap->nodes[i].vnn,
+                       printf(":%d:%s:%d:%d:%d:\n", nodemap->nodes[i].vnn,
                                inet_ntoa(nodemap->nodes[i].sin.sin_addr),
-                               !!nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED);
+                               !!(nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED),
 -                              !!(nodemap->nodes[i].flags&NODE_FLAGS_DISABLED),
++                              !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY),
+                               !!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED));
                }
                return 0;
        }
        printf("Number of nodes:%d\n", nodemap->num);
        for(i=0;i<nodemap->num;i++){
                const char *flags_str;
-               if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) {
+               if (nodemap->nodes[i].flags & NODE_FLAGS_PERMANENTLY_DISABLED) {
 -                      flags_str = "PERM DISABLED";
 -              } else if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) {
                        flags_str = "DISABLED";
++              } else if (nodemap->nodes[i].flags & NODE_FLAGS_UNHEALTHY) {
++                      flags_str = "UNHEALTHY";
                } else if (nodemap->nodes[i].flags & NODE_FLAGS_CONNECTED) {
                        flags_str = "CONNECTED";
                } else {