From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5768 invoked by alias); 12 Aug 2009 09:35:21 -0000 Received: (qmail 5733 invoked by alias); 12 Aug 2009 09:35:20 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_55,SPF_HELO_PASS X-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_55,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - config: Fix up some ccs_tool anachronisms To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: 7c04d4ab728bf612ae22cd69d107fad3c220e017 X-Git-Newrev: de503c0247d1ae7191996e8aa6f4fde3d9256a63 From: Christine Caulfield Message-Id: <20090812093449.1C2C0120324@lists.fedorahosted.org> Date: Wed, 12 Aug 2009 09:35:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00191.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=de503c0247d1ae7191996e8aa6f4fde3d9256a63 Commit: de503c0247d1ae7191996e8aa6f4fde3d9256a63 Parent: 7c04d4ab728bf612ae22cd69d107fad3c220e017 Author: Christine Caulfield AuthorDate: Wed Aug 12 10:33:11 2009 +0100 Committer: Christine Caulfield CommitterDate: Wed Aug 12 10:33:11 2009 +0100 config: Fix up some ccs_tool anachronisms ccs_tool no longer tries to contact ccsd by default. Make fence device optional when adding nodes. Add option to 'create' to add node skeletons. Based on an idea by David Teigland Signed-off-by: Christine Caulfield --- config/tools/ccs_tool/editconf.c | 160 +++++++++++++++++++++---------------- 1 files changed, 91 insertions(+), 69 deletions(-) diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c index 8f808e9..cd25b38 100644 --- a/config/tools/ccs_tool/editconf.c +++ b/config/tools/ccs_tool/editconf.c @@ -46,7 +46,7 @@ static void config_usage(int rw) if (rw) { fprintf(stderr, " -o --outputfile Name of output file (defaults to same as --configfile)\n"); - fprintf(stderr, " -C --no_ccs Don't tell CCSD about this change\n"); + fprintf(stderr, " -C --ccs Tell CCSD about this change\n"); fprintf(stderr, " default: run \"ccs_tool update\" if file is updated in place)\n"); fprintf(stderr, " -F --force_ccs Force \"ccs_tool upgrade\" even if input & output files differ\n"); } @@ -71,12 +71,14 @@ static void create_usage(const char *name) { fprintf(stderr, "Usage: %s %s [-2] \n", prog_name, name); fprintf(stderr, " -2 Create a 2-node cman cluster config file\n"); + fprintf(stderr, " -n Create skeleton entries for nodes\n"); + fprintf(stderr, " -f Add a fence device to the node skeletons\n"); config_usage(0); help_usage(); fprintf(stderr, "\n" "Note that \"create\" on its own will not create a valid configuration file.\n" "Fence agents and nodes will need to be added to it before handing it over\n" - "to ccsd.\n" + "to cman.\n" "\n" "eg:\n" " ccs_tool create MyCluster\n" @@ -86,6 +88,9 @@ static void create_usage(const char *name) " ccs_tool addnode node3 -n 3 -f apc port=3\n" " ccs_tool addnode node4 -n 4 -f apc port=4\n" "\n"); + fprintf(stderr, "If you add -n to the command then %s will add skeleton entries for\n", name); + fprintf(stderr, "that many nodes. This file WILL NEED EDITTING MANUALLY before it can be used\n"); + fprintf(stderr, "by cman.\n"); exit(0); } @@ -152,10 +157,10 @@ static void addnode_usage(const char *name) fprintf(stderr, "Examples:\n"); fprintf(stderr, "\n"); fprintf(stderr, "Add a new node to default configuration file:\n"); - fprintf(stderr, " %s %s -n 1 -f manual ipaddr=newnode\n", prog_name, name); + fprintf(stderr, " %s %s newnode1 -n 1 -f manual ipaddr=newnode\n", prog_name, name); fprintf(stderr, "\n"); fprintf(stderr, "Add a new node and dump config file to stdout rather than save it\n"); - fprintf(stderr, " %s %s -n 2 -f apc -o- newnode.temp.net port=1\n", prog_name, name); + fprintf(stderr, " %s %s newnode2 -n 2 -f apc -o- newnode.temp.net port=1\n", prog_name, name); exit(0); } @@ -480,7 +485,7 @@ static void add_clusternode(xmlNode *root_element, struct option_info *ninfo, die("nodeid %s already in use\n", ninfo->nodeid); /* Don't allow random fence types */ - if (!valid_fence_type(root_element, ninfo->fence_type)) + if (ninfo->fence_type && !valid_fence_type(root_element, ninfo->fence_type)) die("fence type '%s' not known\n", ninfo->fence_type); /* Add the new node */ @@ -500,19 +505,22 @@ static void add_clusternode(xmlNode *root_element, struct option_info *ninfo, } /* Add the fence attributes */ - newfence = xmlNewNode(NULL, BAD_CAST "fence"); - newfencemethod = xmlNewNode(NULL, BAD_CAST "method"); - xmlSetProp(newfencemethod, BAD_CAST "name", BAD_CAST "single"); + if (ninfo->fence_type) + { + newfence = xmlNewNode(NULL, BAD_CAST "fence"); + newfencemethod = xmlNewNode(NULL, BAD_CAST "method"); + xmlSetProp(newfencemethod, BAD_CAST "name", BAD_CAST "single"); - newfencedevice = xmlNewNode(NULL, BAD_CAST "device"); - xmlSetProp(newfencedevice, BAD_CAST "name", BAD_CAST ninfo->fence_type); + newfencedevice = xmlNewNode(NULL, BAD_CAST "device"); + xmlSetProp(newfencedevice, BAD_CAST "name", BAD_CAST ninfo->fence_type); - /* Add name=value options */ - add_fence_args(newfencedevice, argc, argv, optindex+1); + /* Add name=value options */ + add_fence_args(newfencedevice, argc, argv, optindex+1); - xmlAddChild(newnode, newfence); - xmlAddChild(newfence, newfencemethod); - xmlAddChild(newfencemethod, newfencedevice); + xmlAddChild(newnode, newfence); + xmlAddChild(newfence, newfencemethod); + xmlAddChild(newfencemethod, newfencedevice); + } } static xmlDoc *open_configfile(struct option_info *ninfo) @@ -567,7 +575,7 @@ struct option addnode_options[] = { "fence_type", required_argument, NULL, 'f'}, { "outputfile", required_argument, NULL, 'o'}, { "configfile", required_argument, NULL, 'c'}, - { "no_ccs", no_argument, NULL, 'C'}, + { "ccs", no_argument, NULL, 'C'}, { "force_ccs", no_argument, NULL, 'F'}, { NULL, 0, NULL, 0 }, }; @@ -576,7 +584,7 @@ struct option delnode_options[] = { { "outputfile", required_argument, NULL, 'o'}, { "configfile", required_argument, NULL, 'c'}, - { "no_ccs", no_argument, NULL, 'C'}, + { "ccs", no_argument, NULL, 'C'}, { "force_ccs", no_argument, NULL, 'F'}, { NULL, 0, NULL, 0 }, }; @@ -585,7 +593,7 @@ struct option addfence_options[] = { { "outputfile", required_argument, NULL, 'o'}, { "configfile", required_argument, NULL, 'c'}, - { "no_ccs", no_argument, NULL, 'C'}, + { "ccs", no_argument, NULL, 'C'}, { "force_ccs", no_argument, NULL, 'F'}, { NULL, 0, NULL, 0 }, }; @@ -607,6 +615,15 @@ struct option list_options[] = { NULL, 0, NULL, 0 }, }; +struct option create_options[] = +{ + { "configfile", required_argument, NULL, 'c'}, + { "nodes", required_argument, NULL, 'n'}, + { "fence", required_argument, NULL, 'f'}, + { "verbose", no_argument, NULL, 'v'}, + { NULL, 0, NULL, 0 }, +}; + static int next_nodeid(int startid, int *nodeids, int nodecount) { @@ -775,7 +792,7 @@ void add_node(int argc, char **argv) xmlNode *root_element; memset(&ninfo, 0, sizeof(ninfo)); - ninfo.tell_ccsd = 1; + ninfo.tell_ccsd = 0; ninfo.votes = "1"; while ( (opt = getopt_long(argc, argv, "v:n:a:f:o:c:CFh?", addnode_options, NULL)) != EOF) @@ -809,7 +826,7 @@ void add_node(int argc, char **argv) break; case 'C': - ninfo.tell_ccsd = 0; + ninfo.tell_ccsd = 1; break; case 'F': @@ -828,10 +845,6 @@ void add_node(int argc, char **argv) else addnode_usage(argv[0]); - if (!ninfo.fence_type) - addnode_usage(argv[0]); - - doc = open_configfile(&ninfo); root_element = xmlDocGetRootElement(doc); @@ -855,7 +868,7 @@ void del_node(int argc, char **argv) xmlNode *root_element; memset(&ninfo, 0, sizeof(ninfo)); - ninfo.tell_ccsd = 1; + ninfo.tell_ccsd = 0; while ( (opt = getopt_long(argc, argv, "o:c:CFh?", delnode_options, NULL)) != EOF) { @@ -870,7 +883,7 @@ void del_node(int argc, char **argv) break; case 'C': - ninfo.tell_ccsd = 0; + ninfo.tell_ccsd = 1; break; case 'F': @@ -984,22 +997,19 @@ void list_nodes(int argc, char **argv) void create_skeleton(int argc, char **argv) { - xmlNode *root_element; - xmlNode *fencedevices; - xmlNode *clusternodes; - xmlNode *rm; - xmlNode *rm1; - xmlNode *rm2; - xmlDocPtr doc; + char *fencename = NULL; char *clustername; struct option_info ninfo; struct stat st; + FILE *outfile; + int i; int twonode = 0; + int numnodes=0; int opt; memset(&ninfo, 0, sizeof(ninfo)); - while ( (opt = getopt_long(argc, argv, "c:2h?", list_options, NULL)) != EOF) + while ( (opt = getopt_long(argc, argv, "c:2hn:f:?", create_options, NULL)) != EOF) { switch(opt) { @@ -1009,6 +1019,13 @@ void create_skeleton(int argc, char **argv) case '2': twonode = 1; + numnodes = 2; + break; + case 'n': + numnodes = atoi(optarg); + break; + case 'f': + fencename = strdup(optarg); break; case '?': @@ -1029,41 +1046,46 @@ void create_skeleton(int argc, char **argv) die("%s already exists", ninfo.outputfile); /* Init libxml */ - xmlInitParser(); - LIBXML_TEST_VERSION; - - doc = xmlNewDoc(BAD_CAST "1.0"); - root_element = xmlNewNode(NULL, BAD_CAST "cluster"); - xmlDocSetRootElement(doc, root_element); - - xmlSetProp(root_element, BAD_CAST "name", BAD_CAST clustername); - xmlSetProp(root_element, BAD_CAST "config_version", BAD_CAST "1"); + outfile = fopen(ninfo.outputfile, "w+"); + if (!outfile) { + perror(" Can't open output file"); + return; + } - /* Generate extra bits for a 2node cman cluster */ + fprintf(outfile, "\n"); + fprintf(outfile, "\n", clustername); + fprintf(outfile, "\n"); if (twonode) { - - xmlNode *cman = xmlNewNode(NULL, BAD_CAST "cman"); - xmlSetProp(cman, BAD_CAST "two_node", BAD_CAST "1"); - xmlSetProp(cman, BAD_CAST "expected_votes", BAD_CAST "1"); - xmlAddChild(root_element, cman); + fprintf(outfile, " \n"); } - clusternodes = xmlNewNode(NULL, BAD_CAST "clusternodes"); - fencedevices = xmlNewNode(NULL, BAD_CAST "fencedevices"); - rm = xmlNewNode(NULL, BAD_CAST "rm"); - rm1 = xmlNewNode(NULL, BAD_CAST "failoverdomains"); - - xmlAddChild(root_element, clusternodes); - xmlAddChild(root_element, fencedevices); - xmlAddChild(root_element, rm); - - /* Create empty resource manager sections to keep GUI happy */ - rm2 = xmlNewNode(NULL, BAD_CAST "resources"); - xmlAddChild(rm, rm1); - xmlAddChild(rm, rm2); - - save_file(doc, &ninfo); - + fprintf(outfile, " \n"); + for (i=1; i< numnodes; i++) { + fprintf(outfile, " \n", i, i); + fprintf(outfile, " \n"); + fprintf(outfile, " \n"); + if (fencename) { + fprintf(outfile, " \n"); + } + fprintf(outfile, " \n"); + fprintf(outfile, " \n"); + fprintf(outfile, " \n"); + } + fprintf(outfile, " \n"); + fprintf(outfile, "\n"); + fprintf(outfile, " \n"); + if (fencename) { + fprintf(outfile, " \n", fencename); + } + fprintf(outfile, " \n"); + fprintf(outfile, "\n"); + fprintf(outfile, " \n"); + fprintf(outfile, " \n"); + fprintf(outfile, " \n"); + fprintf(outfile, " \n"); + fprintf(outfile, "\n"); + + fclose(outfile); } void add_fence(int argc, char **argv) @@ -1078,7 +1100,7 @@ void add_fence(int argc, char **argv) int opt; memset(&ninfo, 0, sizeof(ninfo)); - ninfo.tell_ccsd = 1; + ninfo.tell_ccsd = 0; while ( (opt = getopt_long(argc, argv, "c:o:CFh?", list_options, NULL)) != EOF) { @@ -1092,7 +1114,7 @@ void add_fence(int argc, char **argv) break; case 'C': - ninfo.tell_ccsd = 0; + ninfo.tell_ccsd = 1; break; case 'F': @@ -1149,7 +1171,7 @@ void del_fence(int argc, char **argv) int opt; memset(&ninfo, 0, sizeof(ninfo)); - ninfo.tell_ccsd = 1; + ninfo.tell_ccsd = 0; while ( (opt = getopt_long(argc, argv, "c:o:CFhv?", list_options, NULL)) != EOF) { @@ -1163,7 +1185,7 @@ void del_fence(int argc, char **argv) break; case 'C': - ninfo.tell_ccsd = 0; + ninfo.tell_ccsd = 1; break; case 'F':