summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushik BV <kaushikbv@gluster.com>2011-04-21 06:55:45 +0000
committerAnand Avati <avati@gluster.com>2011-04-22 03:52:28 -0700
commit2017d5ed79a0843262695394bfff61968902e9ef (patch)
tree7f0fd11955b678c158333b27326b709094586d2e
parent49603aec03e98a2a38fad66627593b69b6269cbf (diff)
cli: check if gsyncd is present in the configured place, enable geo-replication if present
Signed-off-by: Kaushik BV <kaushikbv@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2744 (make geo-replication package friendly) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2744
-rw-r--r--cli/src/cli-cmd-volume.c73
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c50
2 files changed, 122 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index e49b8f230..bb549589b 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1049,6 +1049,76 @@ out:
return ret;
}
+#if (SYNCDAEMON_COMPILE)
+static int
+cli_check_gsync_present ()
+{
+ FILE *in = NULL;
+ char buff[PATH_MAX] = {0, };
+ char cmd[PATH_MAX + 256] = {0, };
+ char *ptr = NULL;
+ int ret = 0;
+ struct stat stat_buff;
+
+ if (strlen (GSYNCD_PREFIX)+1 > PATH_MAX-strlen("/gsyncd")) {
+ ret = -1;
+ goto out;
+ }
+
+ ret = snprintf (cmd, sizeof(cmd), GSYNCD_PREFIX "/gsyncd");
+ if (ret < 0)
+ return 0;
+ ret = lstat (cmd, &stat_buff);
+
+ if (ret || !(stat_buff.st_mode & S_IXUSR)) {
+ gf_log ("", GF_LOG_INFO, "geo-replication not installed");
+ return -1;
+ }
+
+ ret = setenv ("_GLUSTERD_CALLED_", "1", 1);
+ if (-1 == ret) {
+ gf_log ("", GF_LOG_WARNING, "setenv syscall failed, hence could"
+ "not assert if geo-replication is installed");
+ goto out;
+ }
+
+ memset (cmd, 0, sizeof (cmd));
+ ret = snprintf (cmd, sizeof(cmd), GSYNCD_PREFIX"/gsyncd --version");
+
+ if (!(in = popen(cmd, "r"))) {
+ gf_log ("", GF_LOG_INFO, "geo-replication not installed");
+ return -1;
+ }
+
+ ptr = fgets(buff, sizeof(buff), in);
+ if (ptr)
+ if (!strstr (buff, "gsyncd"))
+ return -1;
+
+ ret = pclose (in);
+
+ if (ret)
+ gf_log ("", GF_LOG_ERROR, "geo-replication not installed");
+
+out:
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret ? -1 : 0;
+
+}
+
+void
+cli_cmd_check_gsync_exists_cbk (struct cli_cmd *this)
+{
+
+ int ret = 0;
+
+ ret = cli_check_gsync_present ();
+ if (ret)
+ this->disable = _gf_true;
+
+}
+#endif
+
int
cli_cmd_volume_gsync_set_cbk (struct cli_state *state, struct cli_cmd_word *word,
const char **words, int wordcount)
@@ -1167,7 +1237,8 @@ struct cli_cmd volume_cmds[] = {
#if (SYNCDAEMON_COMPILE)
{"volume "GEOREP" [<VOLNAME>] [<SLAVE-URL>] {start|stop|config|status} [options...]",
cli_cmd_volume_gsync_set_cbk,
- "Geo-sync operations"},
+ "Geo-sync operations",
+ cli_cmd_check_gsync_exists_cbk},
#endif
{ "volume profile <VOLNAME> {start|info|stop}",
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index f72f05813..b2cf345c7 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -242,6 +242,50 @@ out:
extern int mkdir_if_missing (char *path);
static int
+glusterd_check_gsync_present ()
+{
+ FILE *in = NULL;
+ char buff[PATH_MAX] = {0, };
+ char cmd[PATH_MAX + 256] = {0, };
+ char *ptr = NULL;
+ int ret = 0;
+
+ if (strlen (GSYNCD_PREFIX)+1 > PATH_MAX-strlen("/gsyncd")) {
+ ret = -1;
+ goto out;
+ }
+
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --version");
+
+ if (!(in = popen(cmd, "r"))) {
+ gf_log ("", GF_LOG_INFO, "geo-replication module not installed"
+ " in the system");
+ ret = -1;
+ goto out;
+ }
+
+ ptr = fgets(buff, sizeof(buff), in);
+ if (ptr) {
+ if (!strstr (buff, "gsyncd")) {
+ ret = -1;
+ goto out;
+ }
+ }
+ ret = 0;
+ out:
+ if (in)
+ if (-1 == pclose (in)) {
+ ret = -1;
+ gf_log ("", GF_LOG_INFO, "geo-replication module not"
+ " installed in the system");
+ }
+
+ gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+
+}
+
+int
configure_syncaemon (glusterd_conf_t *conf)
{
int ret = 0;
@@ -273,6 +317,12 @@ configure_syncaemon (glusterd_conf_t *conf)
"Unable to create "GEOREP" slave log directory");
return -1;
}
+ ret = glusterd_check_gsync_present ();
+ if (-1 == ret) {
+ ret = 0;
+ goto out;
+ }
+
blen = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/"GSYNC_CONF
" --config-set-rx ", conf->workdir);