summaryrefslogtreecommitdiffstats
path: root/cli
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 /cli
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
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli-cmd-volume.c73
1 files changed, 72 insertions, 1 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index e49b8f23011..bb549589be6 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}",