From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26024 invoked by alias); 5 Feb 2009 15:34:28 -0000 Received: (qmail 26016 invoked by alias); 5 Feb 2009 15:34:28 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,J_CHICKENPOX_54,J_CHICKENPOX_64,SPF_HELO_PASS X-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,J_CHICKENPOX_54,J_CHICKENPOX_64,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com Subject: cluster: master - config: Add cman-mkconf To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: c469ea22e6170760ca74a77f61bd2f6b13e90e92 X-Git-Newrev: 71fd5650faa08a94aed6f2824b231e1d05b4b883 From: Christine Caulfield Message-Id: <20090205153207.07FECC024D@lists.fedorahosted.org> Date: Thu, 05 Feb 2009 15:34: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-q1/txt/msg00388.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=71fd5650faa08a94aed6f2824b231e1d05b4b883 Commit: 71fd5650faa08a94aed6f2824b231e1d05b4b883 Parent: c469ea22e6170760ca74a77f61bd2f6b13e90e92 Author: Christine Caulfield AuthorDate: Thu Feb 5 15:30:28 2009 +0000 Committer: Christine Caulfield CommitterDate: Thu Feb 5 15:30:28 2009 +0000 config: Add cman-mkconf cman-mkconf is a little program to generate very basic cluster.conf file from a running system. Signed-off-by: Christine Caulfield --- config/tools/Makefile | 2 +- config/tools/mkconf/Makefile | 27 ++++++ config/tools/mkconf/mkconf.c | 211 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+), 1 deletions(-) diff --git a/config/tools/Makefile b/config/tools/Makefile index 04cc742..8feab10 100644 --- a/config/tools/Makefile +++ b/config/tools/Makefile @@ -1,4 +1,4 @@ include ../../make/defines.mk include $(OBJDIR)/make/passthrough.mk -SUBDIRS=ccs_tool ldap man +SUBDIRS=ccs_tool ldap mkconf man diff --git a/config/tools/mkconf/Makefile b/config/tools/mkconf/Makefile new file mode 100644 index 0000000..4741c31 --- /dev/null +++ b/config/tools/mkconf/Makefile @@ -0,0 +1,27 @@ +TARGET= cman-mkconf + +SBINDIRT=$(TARGET) + +all: ${TARGET} + +include ../../../make/defines.mk +include $(OBJDIR)/make/cobj.mk +include $(OBJDIR)/make/clean.mk +include $(OBJDIR)/make/install.mk +include $(OBJDIR)/make/uninstall.mk + +OBJS= mkconf.o + +CFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE +CFLAGS += -I${corosyncincdir} +CFLAGS += -I${incdir} + +LDFLAGS += -L${corosynclibdir} -lconfdb -lquorum -lcfg -lccs +LDFLAGS += -L${libdir} + +${TARGET}: ${OBJS} + $(CC) -o $@ $^ $(LDFLAGS) + +clean: generalclean + +-include $(OBJS:.o=.d) diff --git a/config/tools/mkconf/mkconf.c b/config/tools/mkconf/mkconf.c new file mode 100644 index 0000000..a4cc71b --- /dev/null +++ b/config/tools/mkconf/mkconf.c @@ -0,0 +1,211 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +struct node_info { + uint32_t nodeid; + char name[256]; +}; + +static uint32_t node_list_size; +static struct node_info *node_list; + + +static char *node_name(corosync_cfg_node_address_t *addr) +{ + static char name[256]; + + if (getnameinfo((struct sockaddr *)addr->address, addr->address_length, name, sizeof(name), + NULL, 0, NI_NAMEREQD)) + return NULL; + else + return name; +} + +static void quorum_notification_callback( + quorum_handle_t handle, + uint32_t quorate, + uint64_t ring_seq, + uint32_t view_list_entries, + uint32_t *view_list) +{ + int i; + + node_list = malloc(sizeof(struct node_info) * view_list_entries); + if (node_list) { + for (i=0; i Use this cluster name\n"); + printf(" -i Use IP Addresses rather than resolved node names\n"); + printf(" -f Fence agent name (default: 'default')\n"); + printf(" -F Fence agent parameter name (default: 'ipaddr'\n"); + printf(" -v Config version number (default: 0)\n"); + + printf("\n"); + + printf("NOTE: It is stringly recommended that the existing cluster is shut down\n"); + printf(" completely before restarting any nodes using the generated file\n"); + + printf("\n"); +} + +int main(int argc, char *argv[]) +{ + unsigned int ccs_handle; + char *value; + int optchar; + int nodeid = 0; + int i; + + int seq_nodeids=0; + int use_ip_addrs=0; + int config_version = 0; + char *cluster_name = NULL; + char *fence_type = "default"; + char *fence_param = "ipaddr"; + + /* Parse options... */ + do { + optchar = getopt(argc, argv, "?hNn:if:F:v:"); + switch (optchar) { + case 'N': + seq_nodeids=1; + break; + case 'n': + cluster_name = strdup(optarg); + break; + case 'i': + use_ip_addrs=1; + break; + case 'f': + fence_type = strdup(optarg); + break; + case 'F': + fence_param = strdup(optarg); + break; + case 'v': + config_version = atoi(optarg); + break; + case '?': + case 'h': + usage(argv[0]); + exit(0); + case EOF: + break; + + } + } while (optchar != EOF); + + + /* Get the list of nodes and names */ + if (refresh_node_list()){ + fprintf(stderr, "Unable to get node information from corosync\n"); + return 1; + } + + ccs_handle = ccs_connect(); + + if (!cluster_name) { + if (!ccs_get(ccs_handle, "/cluster/@name", &value)) { + cluster_name = strdup(value); + free(value); + } + } + + /* TODO more ccs keys as a filled in by NOCONFIG ... */ + + /* Print config file header */ + printf("\n"); + printf("\n", cluster_name); + printf(" \n"); + for (i=0; i\n", node_list[i].name, + seq_nodeids?++nodeid:node_list[i].nodeid); + printf(" \n"); + printf(" \n"); + printf(" \n", fence_type, fence_param,node_list[i].name); + printf(" \n"); + printf(" \n"); + printf(" \n"); + printf("\n"); + } + printf(" \n"); + + printf("\n"); + + ccs_disconnect(ccs_handle); + return 0; +}