public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: Christine Caulfield <chrissie@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: master - cman & config: Move special cases out of config modules Date: Wed, 03 Sep 2008 11:00:00 -0000 [thread overview] Message-ID: <20080903101724.D3B9AC07B7@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=f308bb5e0a3f7dde8340046a92acee8e72c0017c Commit: f308bb5e0a3f7dde8340046a92acee8e72c0017c Parent: 5c4bb52cd4aa851afade847e2f3251205d6d7ee8 Author: Christine Caulfield <ccaulfie@redhat.com> AuthorDate: Wed Sep 3 11:14:04 2008 +0100 Committer: Christine Caulfield <ccaulfie@redhat.com> CommitterDate: Wed Sep 3 11:14:04 2008 +0100 cman & config: Move special cases out of config modules It was previously the job of the config modules to move items like <totem>, <logging> etc from under <cluster> and into the root of the tree so that corosync could find them. This is obviously absurd. So I've made cman-preconfig do this now. This means that the config modules do only what they should do, read in the config tree as they see it into objdb. Any other new keys we need to add to /cluster that actually apply to corosync can be added in one place. Signed-off-by: Christine Caulfield <ccaulfie@redhat.com> --- cman/daemon/cman-preconfig.c | 79 ++++++++++++++++++++++++++++++++++++++ config/plugins/ccsais/config.c | 8 ---- config/plugins/ldap/configldap.c | 4 -- config/plugins/xml/config.c | 9 ---- 4 files changed, 79 insertions(+), 21 deletions(-) diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c index 4e691f4..6715b3f 100644 --- a/cman/daemon/cman-preconfig.c +++ b/cman/daemon/cman-preconfig.c @@ -916,6 +916,76 @@ static int set_noccs_defaults(struct objdb_iface_ver0 *objdb) return 0; } +/* Move an object/key tree */ +static int move_config_tree(struct objdb_iface_ver0 *objdb, unsigned int source_object, unsigned int target_parent_object) +{ + unsigned int object_handle; + unsigned int new_object; + unsigned int find_handle; + char object_name[1024]; + int object_name_len; + void *key_name; + int key_name_len; + void *key_value; + int key_value_len; + int res; + + /* Create new parent object if necessary */ + objdb->object_name_get(source_object, object_name, &object_name_len); + + objdb->object_find_create(target_parent_object, object_name, strlen(object_name), &find_handle); + if (objdb->object_find_next(find_handle, &object_handle)) + objdb->object_create(target_parent_object, &new_object, object_name, object_name_len); + objdb->object_find_destroy(find_handle); + + /* Copy the keys */ + objdb->object_key_iter_reset(new_object); + + while (!objdb->object_key_iter(source_object, &key_name, &key_name_len, + &key_value, &key_value_len)) { + + objdb->object_key_create(new_object, key_name, key_name_len, + key_value, key_value_len); + } + + /* Create sub-objects */ + res = objdb->object_find_create(source_object, NULL, 0, &find_handle); + if (res) { + sprintf(error_reason, "error resetting object iterator for object %d: %d\n", source_object, res); + return -1; + } + + while ( (res = objdb->object_find_next(find_handle, &object_handle) == 0)) { + + /* Down we go ... */ + move_config_tree(objdb, object_handle, new_object); + } + objdb->object_find_destroy(find_handle); + + return 0; +} + +/* + * Move trees from /cluster where they live in cluster.conf, into the root + * of the config tree where corosync expects to find them. + */ +static int move_tree_to_root(struct objdb_iface_ver0 *objdb, char *name) +{ + unsigned int find_handle; + unsigned int object_handle; + int res=0; + + objdb->object_find_create(cluster_parent_handle, name, strlen(name), &find_handle); + if (objdb->object_find_next(find_handle, &object_handle) == 0) { + res = move_config_tree(objdb, object_handle, OBJECT_PARENT_HANDLE); + } + objdb->object_find_destroy(find_handle); + + // TODO Destroy original ?? + // objdb->object_destroy(object_handle); + return res; +} + static int get_cman_globals(struct objdb_iface_ver0 *objdb) { unsigned int object_handle; @@ -955,6 +1025,13 @@ static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, char **error_strin objdb->object_find_next(find_handle, &cluster_parent_handle); objdb->object_find_destroy(find_handle); + /* Move these to a place where corosync expects to find them */ + ret = move_tree_to_root(objdb, "totem"); + ret = move_tree_to_root(objdb, "logging"); + ret = move_tree_to_root(objdb, "event"); + ret = move_tree_to_root(objdb, "amf"); + ret = move_tree_to_root(objdb, "aisexec"); + objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle); if (objdb->object_find_next(find_handle, &object_handle)) { @@ -973,6 +1050,8 @@ static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, char **error_strin ret = get_nodename(objdb); add_cman_overrides(objdb); } + + if (!ret) { sprintf (error_reason, "%s", "Successfully parsed cman config\n"); } diff --git a/config/plugins/ccsais/config.c b/config/plugins/ccsais/config.c index b56a24f..4db379b 100644 --- a/config/plugins/ccsais/config.c +++ b/config/plugins/ccsais/config.c @@ -209,14 +209,6 @@ static int init_config(struct objdb_iface_ver0 *objdb, char *error_string) return -1; } - /* These first few are just versions of openais.conf */ - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "totem", "/cluster/totem", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "logging", "/cluster/logging", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "event", "/cluster/event", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "aisexec", "/cluster/aisexec", 1); - read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "amf", "/cluster/amf", 1); - - /* This is stuff specific to us, eg quorum device timeout */ read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "cluster", "/cluster", 1); ccs_disconnect(cd); diff --git a/config/plugins/ldap/configldap.c b/config/plugins/ldap/configldap.c index e5a571a..0f49cc0 100644 --- a/config/plugins/ldap/configldap.c +++ b/config/plugins/ldap/configldap.c @@ -284,10 +284,6 @@ static int init_config(struct objdb_iface_ver0 *objdb) } rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "cluster", "cn=cluster", 1); - if (!rc) - rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "totem", "cn=totem,cn=cluster", 1); - if (!rc) - rc = read_config_for(ld, objdb, OBJECT_PARENT_HANDLE, "logging", "cn=logging,cn=cluster", 1); ldap_unbind(ld); return 0; diff --git a/config/plugins/xml/config.c b/config/plugins/xml/config.c index 9d59772..8ba290b 100644 --- a/config/plugins/xml/config.c +++ b/config/plugins/xml/config.c @@ -289,15 +289,6 @@ static int init_config(struct objdb_iface_ver0 *objdb, char *configfile, char *e } /* load it in objdb */ - - /* These first few are just versions of openais.conf */ - read_config_for(ctx, objdb, OBJECT_PARENT_HANDLE, "totem", "/cluster/totem", 1); - read_config_for(ctx, objdb, OBJECT_PARENT_HANDLE, "logging", "/cluster/logging", 1); - read_config_for(ctx, objdb, OBJECT_PARENT_HANDLE, "event", "/cluster/event", 1); - read_config_for(ctx, objdb, OBJECT_PARENT_HANDLE, "aisexec", "/cluster/aisexec", 1); - read_config_for(ctx, objdb, OBJECT_PARENT_HANDLE, "amf", "/cluster/amf", 1); - - /* This is stuff specific to us, eg quorum device timeout */ read_config_for(ctx, objdb, OBJECT_PARENT_HANDLE, "cluster", "/cluster", 1); fail:
reply other threads:[~2008-09-03 10:18 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20080903101724.D3B9AC07B7@lists.fedorahosted.org \ --to=chrissie@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).