if all nodes are STOPPED, pick one of the STOPPED nodes as natgw master
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 16 Jul 2009 23:36:22 +0000 (09:36 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 16 Jul 2009 23:36:22 +0000 (09:36 +1000)
tools/ctdb.c

index 352c74f4ad3081a7e1560cf0b5b7ef8aadf6e025..d1ff7593514fb76606c1cef5ec09144e65e2f820 100644 (file)
@@ -686,6 +686,19 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
                        break;
                }
        }
+       /* unless all nodes are STOPPED, when we pick one anyway */
+       if (i == nodemap->num) {
+               for(i=0;i<nodemap->num;i++){
+                       if (!(nodemap->nodes[i].flags & (NODE_FLAGS_DISCONNECTED|NODE_FLAGS_DELETED))) {
+                               printf("%d\n", nodemap->nodes[i].pnn);
+                               break;
+                       }
+               }
+               /* or if we still can not find any */
+               if (i == nodemap->num) {
+                       printf("-1\n");
+               }
+       }
 
        /* print the pruned list of nodes belonging to this natgw list */
        for(i=0;i<nodemap->num;i++){