From 66d430da4e3788aeb41eea46455ca25a2d19a626 Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Mon, 26 Mar 2012 16:11:29 +0530 Subject: glusterd: Added init scripts like interface for gluster commands Directories to hold the scripts mentioned above would be created for each gluster command under glusterd's 'working dir' as follows: (eg.) /hooks/version/create/pre /hooks/version/create/post where, version corresponds to the version of hook scripts. The scripts beginning with 'S' under the above directories would be run before (pre) and after (post) the volume created. The scripts would receive a command line argument as below: --volname= This can be optionally used by the script. Change-Id: Ia81b4ff9dd4477d99dd59b39c805aa645521edb0 BUG: 806996 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/3010 Tested-by: Gluster Build System Reviewed-by: Csaba Henk Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-store.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'xlators/mgmt/glusterd/src/glusterd-store.h') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.h b/xlators/mgmt/glusterd/src/glusterd-store.h index b381e5a0c..788949d55 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.h +++ b/xlators/mgmt/glusterd/src/glusterd-store.h @@ -30,6 +30,7 @@ #include "glusterfs.h" #include "xlator.h" +#include "run.h" #include "logging.h" #include "call-stub.h" #include "fd.h" @@ -73,6 +74,10 @@ typedef enum glusterd_store_ver_ac_{ #define GLUSTERD_STORE_KEY_PEER_HOSTNAME "hostname" #define GLUSTERD_STORE_KEY_PEER_STATE "state" +#define GLUSTERD_GET_HOOKS_DIR(path, version, priv) \ + snprintf (path, PATH_MAX, "%s/hooks/%d", priv->workdir,\ + version); + #define glusterd_for_each_entry(entry, dir) \ do {\ entry = NULL;\ @@ -85,6 +90,7 @@ typedef enum glusterd_store_ver_ac_{ }\ } while (0); \ + typedef enum { GD_STORE_SUCCESS, GD_STORE_KEY_NULL, @@ -95,6 +101,14 @@ typedef enum { GD_STORE_STAT_FAILED } glusterd_store_op_errno_t; +#define GLUSTERD_HOOK_VER 1 +typedef enum glusterd_commit_hook_type { + GD_COMMIT_HOOK_NONE = 0, + GD_COMMIT_HOOK_PRE, + GD_COMMIT_HOOK_POST, + GD_COMMIT_HOOK_MAX +} glusterd_commit_hook_type_t; + int32_t glusterd_store_volinfo (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t ac); @@ -138,4 +152,13 @@ glusterd_perform_volinfo_version_action (glusterd_volinfo_t *volinfo, glusterd_volinfo_ver_ac_t ac); gf_boolean_t glusterd_store_is_valid_brickpath (char *volname, char *brick); + +int +glusterd_store_create_hooks_directory (char *basedir); + +char * +glusterd_store_get_hooks_cmd_subdir (glusterd_op_t op); + +int +glusterd_store_run_hooks (char *hooks_path, dict_t *op_ctx); #endif -- cgit