This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
cluster: master - cman: Add cman_set_version
- From: Christine Caulfield <chrissie at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Tue, 13 Jan 2009 11:05:33 +0000 (UTC)
- Subject: cluster: master - cman: Add cman_set_version
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=d4dea5845f2a785d4801d691019148e7b7437cc1
Commit: d4dea5845f2a785d4801d691019148e7b7437cc1
Parent: 096f7588fbb05e9a61515dc9661d98f7971afe58
Author: Christine Caulfield <ccaulfie@redhat.com>
AuthorDate: Tue Jan 13 11:05:04 2009 +0000
Committer: Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Tue Jan 13 11:05:04 2009 +0000
cman: Add cman_set_version
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
cman/cman_tool/main.c | 5 +--
cman/services/cman/lib/libcman.c | 50 ++++++++++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c
index fc9a999..61196ae 100644
--- a/cman/cman_tool/main.c
+++ b/cman/cman_tool/main.c
@@ -578,13 +578,13 @@ static void set_votes(commandline_t *comline)
}
-// TODO this is obsolete really
+/* This just tells corosync to reload the config file */
static void version(commandline_t *comline)
{
struct cman_version ver;
cman_handle_t h;
int result;
-#if 0
+
h = open_cman_handle(1);
if ((result = cman_get_version(h, &ver)))
@@ -602,7 +602,6 @@ static void version(commandline_t *comline)
die("can't set version: %s", cman_error(errno));
out:
cman_finish(h);
-#endif
}
static int cluster_wait(commandline_t *comline)
diff --git a/cman/services/cman/lib/libcman.c b/cman/services/cman/lib/libcman.c
index b3e1131..e9022a5 100644
--- a/cman/services/cman/lib/libcman.c
+++ b/cman/services/cman/lib/libcman.c
@@ -46,7 +46,6 @@ struct cman_inst {
corosync_cfg_handle_t cfg_handle;
cmanquorum_handle_t cmq_handle;
- confdb_handle_t confdb_handle;
};
static void cfg_shutdown_callback(
@@ -950,6 +949,53 @@ int cman_get_cluster(cman_handle_t handle, cman_cluster_t *clinfo)
return 0;
}
+int cman_set_version(cman_handle_t handle, const cman_version_t *version)
+{
+ struct cman_inst *cman_inst;
+ confdb_handle_t confdb_handle;
+ unsigned int ccs_handle;
+ char *value;
+ char error[256];
+ int ret = 0;
+ int cur_version=0;
+ confdb_callbacks_t callbacks = {
+ .confdb_key_change_notify_fn = NULL,
+ .confdb_object_create_change_notify_fn = NULL,
+ .confdb_object_delete_change_notify_fn = NULL
+ };
+
+
+ cman_inst = (struct cman_inst *)handle;
+ VALIDATE_HANDLE(cman_inst);
+
+ ccs_handle = ccs_connect();
+ if (!ccs_get(ccs_handle, "/cluster/@config_version", &value)) {
+ cur_version = atoi(value);
+ free(value);
+ }
+ ccs_disconnect(ccs_handle);
+
+ if (cur_version >= version->cv_config) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (confdb_initialize(&confdb_handle, &callbacks) != CS_OK) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (confdb_reload(confdb_handle, 0, error) != CS_OK) {
+ ret = EINVAL;
+ }
+
+ confdb_finalize(confdb_handle);
+ return ret;
+}
+
+
+
+
int cman_get_version(cman_handle_t handle, cman_version_t *version)
{
struct cman_inst *cman_inst;
@@ -1120,7 +1166,7 @@ int cman_start_notification(cman_handle_t handle, cman_callback_t callback)
cman_inst->notify_callback = callback;
- if (cmanquorum_trackstart(cman_inst->cmq_handle, (uint64_t)handle, CS_TRACK_CURRENT) != CS_OK)
+ if (cmanquorum_trackstart(cman_inst->cmq_handle, (uint64_t)(long)handle, CS_TRACK_CURRENT) != CS_OK)
return -1;
return 0;