geo-replication: revamp CONFIG command
Drop the config_type RPC req field, use just a "subop" key in the param dict. Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2785 (gsyncd logs on slave side go to /dev/null) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2785
This commit is contained in:
parent
29ac0febec
commit
0dd8c38d17
@ -1121,11 +1121,11 @@ int32_t
|
|||||||
cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
|
cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
|
||||||
{
|
{
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
int32_t config_type = 0;
|
|
||||||
dict_t *dict = NULL;
|
dict_t *dict = NULL;
|
||||||
gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE;
|
gf1_cli_gsync_set type = GF_GSYNC_OPTION_TYPE_NONE;
|
||||||
char *append_str = NULL;
|
char *append_str = NULL;
|
||||||
size_t append_len = 0;
|
size_t append_len = 0;
|
||||||
|
char *subop = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
GF_ASSERT (words);
|
GF_ASSERT (words);
|
||||||
@ -1192,34 +1192,32 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((strcmp (words[2], "config")) == 0) {
|
if ((strcmp (words[2], "config")) == 0) {
|
||||||
type = GF_GSYNC_OPTION_TYPE_CONFIGURE;
|
type = GF_GSYNC_OPTION_TYPE_CONFIG;
|
||||||
|
|
||||||
switch (wordcount) {
|
switch (wordcount) {
|
||||||
case 5:
|
case 5:
|
||||||
config_type = GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL;
|
subop = gf_strdup ("get-all");
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
if (words[5][0] == '!') {
|
if (words[5][0] == '!') {
|
||||||
config_type = GF_GSYNC_OPTION_TYPE_CONFIG_DEL;
|
(words[5])++;
|
||||||
i = 1;
|
subop = gf_strdup ("del");
|
||||||
} else {
|
} else
|
||||||
config_type = GF_GSYNC_OPTION_TYPE_CONFIG_GET;
|
subop = gf_strdup ("get");
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = dict_set_str (dict, "op_name", ((char *)words[5]) + i);
|
ret = dict_set_str (dict, "op_name", ((char *)words[5]));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
config_type = GF_GSYNC_OPTION_TYPE_CONFIG_SET;
|
|
||||||
|
|
||||||
if (wordcount < 7) {
|
if (wordcount < 7) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subop = gf_strdup ("set");
|
||||||
|
|
||||||
ret = dict_set_str (dict, "op_name", (char *)words[5]);
|
ret = dict_set_str (dict, "op_name", (char *)words[5]);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
@ -1246,9 +1244,10 @@ cli_cmd_gsync_set_parse (const char **words, int wordcount, dict_t **options)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dict_set_int32 (dict, "config_type", config_type);
|
if (!subop || dict_set_dynstr (dict, "subop", subop) != 0) {
|
||||||
if (ret < 0)
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -2586,7 +2586,7 @@ out:
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
gf_cli3_1_gsync_get_command (gf1_cli_gsync_set_rsp rsp)
|
gf_cli3_1_gsync_config_command (gf1_cli_gsync_set_rsp rsp)
|
||||||
{
|
{
|
||||||
char cmd[PATH_MAX] = {0,};
|
char cmd[PATH_MAX] = {0,};
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -2597,28 +2597,21 @@ gf_cli3_1_gsync_get_command (gf1_cli_gsync_set_rsp rsp)
|
|||||||
if (!rsp.gsync_prefix || !rsp.master || !rsp.slave || !rsp.glusterd_workdir)
|
if (!rsp.gsync_prefix || !rsp.master || !rsp.slave || !rsp.glusterd_workdir)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET) {
|
if (strcmp (rsp.subop, "get") != 0 && strcmp (rsp.subop, "get-all") != 0) {
|
||||||
if (!rsp.op_name)
|
cli_out (GEOREP" config updated successfully");
|
||||||
return -1;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf (cmd, PATH_MAX, GSYNCD_PREFIX "/gsyncd -c %s/%s :%s %s"
|
snprintf (cmd, PATH_MAX,
|
||||||
" --config-get %s ",
|
GSYNCD_PREFIX"/gsyncd -c %s/"GSYNC_CONF" :%s %s --config-%s%s%s",
|
||||||
rsp.glusterd_workdir, GSYNC_CONF,
|
rsp.glusterd_workdir, rsp.master, rsp.slave, rsp.subop,
|
||||||
rsp.master, rsp.slave, rsp.op_name);
|
*rsp.op_name ? " " : "", rsp.op_name);
|
||||||
ret = system (cmd);
|
ret = system (cmd);
|
||||||
/*
|
/*
|
||||||
* gf_log() failure from system() ?
|
* gf_log() failure from system() ?
|
||||||
*/
|
*/
|
||||||
} else if (rsp.config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) {
|
|
||||||
snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/%s "
|
|
||||||
":%s %s --config-get-all ",
|
|
||||||
rsp.glusterd_workdir, GSYNC_CONF,
|
|
||||||
rsp.master, rsp.slave);
|
|
||||||
|
|
||||||
ret = system (cmd);
|
return ret ? -1 : 0;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -2730,12 +2723,8 @@ gf_cli3_1_gsync_set_cbk (struct rpc_req *req, struct iovec *iov,
|
|||||||
" has been successful", rsp.master, rsp.slave);
|
" has been successful", rsp.master, rsp.slave);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GF_GSYNC_OPTION_TYPE_CONFIGURE:
|
case GF_GSYNC_OPTION_TYPE_CONFIG:
|
||||||
if(rsp.config_type==GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL
|
ret = gf_cli3_1_gsync_config_command (rsp);
|
||||||
|| rsp.config_type==GF_GSYNC_OPTION_TYPE_CONFIG_GET)
|
|
||||||
ret = gf_cli3_1_gsync_get_command (rsp);
|
|
||||||
else
|
|
||||||
cli_out (GEOREP" config updated successfully");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GF_GSYNC_OPTION_TYPE_STATUS:
|
case GF_GSYNC_OPTION_TYPE_STATUS:
|
||||||
|
@ -749,10 +749,10 @@ xdr_gf1_cli_gsync_set_rsp (XDR *xdrs, gf1_cli_gsync_set_rsp *objp)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
if (!xdr_int (xdrs, &objp->type))
|
if (!xdr_int (xdrs, &objp->type))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!xdr_int (xdrs, &objp->config_type))
|
|
||||||
return FALSE;
|
|
||||||
if (!xdr_string (xdrs, &objp->op_name, ~0))
|
if (!xdr_string (xdrs, &objp->op_name, ~0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (!xdr_string (xdrs, &objp->subop, ~0))
|
||||||
|
return FALSE;
|
||||||
if (!xdr_string (xdrs, &objp->master, ~0))
|
if (!xdr_string (xdrs, &objp->master, ~0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!xdr_string (xdrs, &objp->slave, ~0))
|
if (!xdr_string (xdrs, &objp->slave, ~0))
|
||||||
|
@ -87,12 +87,8 @@ enum gf1_cli_gsync_set {
|
|||||||
GF_GSYNC_OPTION_TYPE_NONE = 0,
|
GF_GSYNC_OPTION_TYPE_NONE = 0,
|
||||||
GF_GSYNC_OPTION_TYPE_START = 1,
|
GF_GSYNC_OPTION_TYPE_START = 1,
|
||||||
GF_GSYNC_OPTION_TYPE_STOP = 2,
|
GF_GSYNC_OPTION_TYPE_STOP = 2,
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIGURE = 3,
|
GF_GSYNC_OPTION_TYPE_CONFIG = 3,
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_SET = 4,
|
GF_GSYNC_OPTION_TYPE_STATUS = 4,
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_DEL = 5,
|
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_GET = 6,
|
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL = 7,
|
|
||||||
GF_GSYNC_OPTION_TYPE_STATUS = 8,
|
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef enum gf1_cli_gsync_set gf1_cli_gsync_set;
|
typedef enum gf1_cli_gsync_set gf1_cli_gsync_set;
|
||||||
@ -478,8 +474,8 @@ struct gf1_cli_gsync_set_rsp {
|
|||||||
int op_errno;
|
int op_errno;
|
||||||
char *op_errstr;
|
char *op_errstr;
|
||||||
int type;
|
int type;
|
||||||
int config_type;
|
|
||||||
char *op_name;
|
char *op_name;
|
||||||
|
char *subop;
|
||||||
char *master;
|
char *master;
|
||||||
char *slave;
|
char *slave;
|
||||||
char *gsync_prefix;
|
char *gsync_prefix;
|
||||||
|
@ -46,11 +46,8 @@ enum gf1_cli_gsync_set {
|
|||||||
GF_GSYNC_OPTION_TYPE_NONE,
|
GF_GSYNC_OPTION_TYPE_NONE,
|
||||||
GF_GSYNC_OPTION_TYPE_START,
|
GF_GSYNC_OPTION_TYPE_START,
|
||||||
GF_GSYNC_OPTION_TYPE_STOP,
|
GF_GSYNC_OPTION_TYPE_STOP,
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIGURE,
|
GF_GSYNC_OPTION_TYPE_CONFIG,
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_SET,
|
GF_GSYNC_OPTION_TYPE_STATUS
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_DEL,
|
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_GET,
|
|
||||||
GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum gf1_cli_stats_op {
|
enum gf1_cli_stats_op {
|
||||||
@ -341,8 +338,8 @@ struct gf1_cli_gsync_set_rsp {
|
|||||||
int op_errno;
|
int op_errno;
|
||||||
string op_errstr<>;
|
string op_errstr<>;
|
||||||
int type;
|
int type;
|
||||||
int config_type;
|
|
||||||
string op_name<>;
|
string op_name<>;
|
||||||
|
string subop<>;
|
||||||
string master<>;
|
string master<>;
|
||||||
string slave<>;
|
string slave<>;
|
||||||
string gsync_prefix<>;
|
string gsync_prefix<>;
|
||||||
|
@ -1752,8 +1752,8 @@ glusterd_handle_gsync_set (rpcsvc_request_t *req)
|
|||||||
strncpy (operation, "stop", sizeof (operation));
|
strncpy (operation, "stop", sizeof (operation));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GF_GSYNC_OPTION_TYPE_CONFIGURE:
|
case GF_GSYNC_OPTION_TYPE_CONFIG:
|
||||||
strncpy (operation, "configure", sizeof (operation));
|
strncpy (operation, "config", sizeof (operation));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GF_GSYNC_OPTION_TYPE_STATUS:
|
case GF_GSYNC_OPTION_TYPE_STATUS:
|
||||||
|
@ -1844,20 +1844,6 @@ gsync_status (char *master, char *slave, int *status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
gsync_validate_config_type (int32_t config_type)
|
|
||||||
{
|
|
||||||
switch (config_type) {
|
|
||||||
case GF_GSYNC_OPTION_TYPE_CONFIG_SET:
|
|
||||||
case GF_GSYNC_OPTION_TYPE_CONFIG_DEL:
|
|
||||||
case GF_GSYNC_OPTION_TYPE_CONFIG_GET:
|
|
||||||
case GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL:return 0;
|
|
||||||
default: return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
glusterd_gsync_volinfo_dict_set (glusterd_volinfo_t *volinfo,
|
glusterd_gsync_volinfo_dict_set (glusterd_volinfo_t *volinfo,
|
||||||
char *key, char *value)
|
char *key, char *value)
|
||||||
@ -1883,61 +1869,77 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
gsync_validate_config_option (dict_t *dict, int32_t config_type,
|
gsync_verify_config_options (dict_t *dict, char **op_errstr)
|
||||||
char **op_errstr)
|
|
||||||
{
|
{
|
||||||
char cmd[PATH_MAX] = {0,};
|
char cmd[PATH_MAX] = {0,};
|
||||||
int ret = -1;
|
|
||||||
char **resopt = NULL;
|
char **resopt = NULL;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
char *subop = NULL;
|
||||||
char *op_name = NULL;
|
char *op_name = NULL;
|
||||||
|
char *op_value = NULL;
|
||||||
gf_boolean_t banned = _gf_true;
|
gf_boolean_t banned = _gf_true;
|
||||||
|
|
||||||
if (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL)
|
if (dict_get_str (dict, "subop", &subop) != 0) {
|
||||||
|
gf_log ("", GF_LOG_WARNING, "missing subop");
|
||||||
|
*op_errstr = gf_strdup ("Invalid config request");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp (subop, "get-all") == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = dict_get_str (dict, "op_name", &op_name);
|
if (dict_get_str (dict, "op_name", &op_name) != 0) {
|
||||||
if (ret < 0) {
|
gf_log ("", GF_LOG_WARNING, "option name missing");
|
||||||
gf_log ("", GF_LOG_WARNING, "option not specified");
|
*op_errstr = gf_strdup ("Option name missing");
|
||||||
*op_errstr = gf_strdup ("Please specify the option");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --config-check %s", op_name);
|
snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --config-check %s", op_name);
|
||||||
ret = system (cmd);
|
if (system (cmd)) {
|
||||||
if (ret) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "Invalid option %s", op_name);
|
gf_log ("", GF_LOG_WARNING, "Invalid option %s", op_name);
|
||||||
*op_errstr = gf_strdup ("Invalid option");
|
*op_errstr = gf_strdup ("Invalid option");
|
||||||
|
|
||||||
ret = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != -1 &&
|
if (strcmp (subop, "get") == 0)
|
||||||
(config_type == GF_GSYNC_OPTION_TYPE_CONFIG_SET ||
|
return 0;
|
||||||
config_type == GF_GSYNC_OPTION_TYPE_CONFIG_DEL)) {
|
|
||||||
/* match option name against reserved options, modulo -/-
|
|
||||||
* difference
|
|
||||||
*/
|
|
||||||
for (resopt = gsync_reserved_opts; *resopt; resopt++) {
|
|
||||||
banned = _gf_true;
|
|
||||||
for (i = 0; (*resopt)[i] && op_name[i]; i++) {
|
|
||||||
if ((*resopt)[i] == op_name[i] ||
|
|
||||||
((*resopt)[i] == '-' && op_name[i] == '_'))
|
|
||||||
continue;
|
|
||||||
banned = _gf_false;
|
|
||||||
}
|
|
||||||
if (banned) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "Reserved option %s", op_name);
|
|
||||||
*op_errstr = gf_strdup ("Reserved option");
|
|
||||||
|
|
||||||
ret = -1;
|
if (strcmp (subop, "set") != 0 && strcmp (subop, "del") != 0) {
|
||||||
break;
|
gf_log ("", GF_LOG_WARNING, "unknown subop %s", subop);
|
||||||
}
|
*op_errstr = gf_strdup ("Invalid config request");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp (subop, "set") == 0 &&
|
||||||
|
dict_get_str (dict, "op_value", &op_value) != 0) {
|
||||||
|
gf_log ("", GF_LOG_WARNING, "missing value for set");
|
||||||
|
*op_errstr = gf_strdup ("missing value");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* match option name against reserved options, modulo -/_
|
||||||
|
* difference
|
||||||
|
*/
|
||||||
|
for (resopt = gsync_reserved_opts; *resopt; resopt++) {
|
||||||
|
banned = _gf_true;
|
||||||
|
for (i = 0; (*resopt)[i] && op_name[i]; i++) {
|
||||||
|
if ((*resopt)[i] == op_name[i] ||
|
||||||
|
((*resopt)[i] == '-' && op_name[i] == '_'))
|
||||||
|
continue;
|
||||||
|
banned = _gf_false;
|
||||||
|
}
|
||||||
|
if (banned) {
|
||||||
|
gf_log ("", GF_LOG_WARNING, "Reserved option %s", op_name);
|
||||||
|
*op_errstr = gf_strdup ("Reserved option");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data)
|
_get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data)
|
||||||
{
|
{
|
||||||
@ -2025,38 +2027,6 @@ _remove_gsync_slave (dict_t *this, char *key, data_t *value, void *data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
gsync_verify_config_options (dict_t *dict, char **op_errstr)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
int config_type = 0;
|
|
||||||
|
|
||||||
GF_VALIDATE_OR_GOTO ("gsync", dict, out);
|
|
||||||
GF_VALIDATE_OR_GOTO ("gsync", op_errstr, out);
|
|
||||||
|
|
||||||
ret = dict_get_int32 (dict, "config_type", &config_type);
|
|
||||||
if (ret < 0) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "config type is missing");
|
|
||||||
*op_errstr = gf_strdup ("config-type missing");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gsync_validate_config_type (config_type);
|
|
||||||
if (ret == -1) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "Invalid config type");
|
|
||||||
*op_errstr = gf_strdup ("Invalid config type");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gsync_validate_config_option (dict, config_type, op_errstr);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
glusterd_remove_slave_in_info (glusterd_volinfo_t *volinfo, char *slave,
|
glusterd_remove_slave_in_info (glusterd_volinfo_t *volinfo, char *slave,
|
||||||
char *host_uuid, char **op_errstr)
|
char *host_uuid, char **op_errstr)
|
||||||
@ -2451,7 +2421,7 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
break;
|
break;
|
||||||
case GF_GSYNC_OPTION_TYPE_CONFIGURE:
|
case GF_GSYNC_OPTION_TYPE_CONFIG:
|
||||||
ret = gsync_verify_config_options (dict, op_errstr);
|
ret = gsync_verify_config_options (dict, op_errstr);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
@ -4109,140 +4079,85 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
gsync_config_set (char *master, char *slave,
|
glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave);
|
||||||
dict_t *dict, char **op_errstr)
|
|
||||||
|
int
|
||||||
|
glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
|
||||||
|
dict_t *dict, char **op_errstr)
|
||||||
{
|
{
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
char *op_name = NULL;
|
char *op_name = NULL;
|
||||||
char *op_value = NULL;
|
char *op_value = NULL;
|
||||||
char cmd[1024] = {0,};
|
char cmd[1024] = {0,};
|
||||||
glusterd_conf_t *priv = NULL;
|
glusterd_conf_t *priv = NULL;
|
||||||
|
char *subop = NULL;
|
||||||
|
char *q1 = NULL;
|
||||||
|
char *q2 = NULL;
|
||||||
|
|
||||||
if (THIS == NULL) {
|
GF_ASSERT (volinfo);
|
||||||
gf_log ("", GF_LOG_ERROR, "THIS of glusterd not present");
|
GF_ASSERT (slave);
|
||||||
*op_errstr = gf_strdup ("Error! Glusterd cannot start "GEOREP);
|
GF_ASSERT (op_errstr);
|
||||||
|
|
||||||
|
ret = dict_get_str (dict, "subop", &subop);
|
||||||
|
if (ret != 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
priv = THIS->private;
|
if (strcmp (subop, "get") == 0 || strcmp (subop, "get-all") == 0) {
|
||||||
|
/* deferred to cli */
|
||||||
if (priv == NULL) {
|
gf_log ("", GF_LOG_DEBUG, "Returning 0");
|
||||||
gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
|
return 0;
|
||||||
*op_errstr = gf_strdup ("Error! Glusterd cannot start "GEOREP);
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dict_get_str (dict, "op_name", &op_name);
|
ret = dict_get_str (dict, "op_name", &op_name);
|
||||||
if (ret < 0) {
|
if (ret != 0)
|
||||||
gf_log ("", GF_LOG_WARNING, "failed to get the "
|
goto out;
|
||||||
"option name for %s %s", master, slave);
|
|
||||||
|
|
||||||
*op_errstr = gf_strdup ("configure command failed, "
|
if (strcmp (subop, "set") == 0) {
|
||||||
"please check the log-file\n");
|
ret = dict_get_str (dict, "op_value", &op_value);
|
||||||
goto out;
|
if (ret != 0)
|
||||||
}
|
goto out;
|
||||||
|
q1 = " \"";
|
||||||
ret = dict_get_str (dict, "op_value", &op_value);
|
q2 = "\"";
|
||||||
if (ret < 0) {
|
} else {
|
||||||
gf_log ("", GF_LOG_WARNING, "failed to get "
|
q1 = "";
|
||||||
"the option value for %s %s",
|
op_value = "";
|
||||||
master, slave);
|
q2 = "";
|
||||||
|
}
|
||||||
*op_errstr = gf_strdup ("configure command "
|
|
||||||
"failed, please check "
|
if (THIS)
|
||||||
"the log-file\n");
|
priv = THIS->private;
|
||||||
goto out;
|
if (priv == NULL) {
|
||||||
}
|
gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
|
||||||
|
*op_errstr = gf_strdup ("glusterd defunct");
|
||||||
ret = snprintf (cmd, 1024, GSYNCD_PREFIX"/gsyncd -c %s/%s :%s %s"
|
|
||||||
" --config-set %s \" %s \"", priv->workdir,
|
|
||||||
GSYNC_CONF, master, slave, op_name, op_value);
|
|
||||||
if (ret <= 0) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "failed to "
|
|
||||||
"construct the gsyncd command");
|
|
||||||
|
|
||||||
*op_errstr = gf_strdup ("configure command failed, "
|
|
||||||
"please check the log-file\n");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = snprintf (cmd, 1024, GSYNCD_PREFIX"/gsyncd -c %s/"GSYNC_CONF" :%s %s"
|
||||||
|
" --config-%s %s" "%s%s%s", priv->workdir,
|
||||||
|
volinfo->volname, slave, subop, op_name,
|
||||||
|
q1, op_value, q2);
|
||||||
ret = system (cmd);
|
ret = system (cmd);
|
||||||
if (ret == -1) {
|
if (ret) {
|
||||||
gf_log ("", GF_LOG_WARNING, "gsyncd failed to "
|
gf_log ("", GF_LOG_WARNING, "gsyncd failed to "
|
||||||
"set %s option for %s %s peer",
|
"%s %s option for %s %s peers",
|
||||||
op_name, master, slave);
|
subop, op_name, volinfo->volname, slave);
|
||||||
|
|
||||||
|
gf_asprintf (op_errstr, GEOREP" config-%s failed for %s %s",
|
||||||
|
subop, volinfo->volname, slave);
|
||||||
|
|
||||||
*op_errstr = gf_strdup ("configure command "
|
|
||||||
"failed, please check "
|
|
||||||
"the log-file\n");
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
ret = 0;
|
ret = 0;
|
||||||
*op_errstr = gf_strdup ("config-set successful");
|
gf_asprintf (op_errstr, "config-%s successful", subop);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return ret;
|
if (!ret) {
|
||||||
}
|
ret = glusterd_check_restart_gsync_session (volinfo, slave);
|
||||||
|
if (ret)
|
||||||
int
|
*op_errstr = gf_strdup ("internal error");
|
||||||
gsync_config_del (char *master, char *slave,
|
|
||||||
dict_t *dict, char **op_errstr)
|
|
||||||
{
|
|
||||||
int32_t ret = -1;
|
|
||||||
char *op_name = NULL;
|
|
||||||
char cmd[PATH_MAX] = {0,};
|
|
||||||
glusterd_conf_t *priv = NULL;
|
|
||||||
|
|
||||||
if (THIS == NULL) {
|
|
||||||
gf_log ("", GF_LOG_ERROR, "THIS of glusterd not present");
|
|
||||||
*op_errstr = gf_strdup ("Error! Glusterd cannot start "GEOREP);
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv = THIS->private;
|
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
|
||||||
|
|
||||||
if (priv == NULL) {
|
|
||||||
gf_log ("", GF_LOG_ERROR, "priv of glusterd not present");
|
|
||||||
*op_errstr = gf_strdup ("Error! Glusterd cannot start "GEOREP);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = dict_get_str (dict, "op_name", &op_name);
|
|
||||||
if (ret < 0) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "failed to get "
|
|
||||||
"the option for %s %s", master, slave);
|
|
||||||
|
|
||||||
*op_errstr = gf_strdup ("configure command "
|
|
||||||
"failed, please check "
|
|
||||||
"the log-file\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd -c %s/%s :%s %s"
|
|
||||||
" --config-del %s ", priv->workdir,
|
|
||||||
GSYNC_CONF, master, slave, op_name);
|
|
||||||
if (ret <= 0) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "failed to "
|
|
||||||
"construct the gsyncd command");
|
|
||||||
*op_errstr = gf_strdup ("configure command "
|
|
||||||
"failed, please check "
|
|
||||||
"the log-file\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = system (cmd);
|
|
||||||
if (ret == -1) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "failed to delete "
|
|
||||||
"%s option for %s %s peer", op_name,
|
|
||||||
master, slave);
|
|
||||||
*op_errstr = gf_strdup ("configure command "
|
|
||||||
"failed, please check "
|
|
||||||
"the log-file\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
ret = 0;
|
|
||||||
*op_errstr = gf_strdup ("config-del successful");
|
|
||||||
out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4387,59 +4302,6 @@ glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave,
|
|
||||||
dict_t *dict, char **op_errstr)
|
|
||||||
{
|
|
||||||
int32_t ret = -1;
|
|
||||||
int32_t config_type = 0;
|
|
||||||
|
|
||||||
GF_ASSERT (volinfo);
|
|
||||||
GF_ASSERT (slave);
|
|
||||||
GF_ASSERT (op_errstr);
|
|
||||||
|
|
||||||
ret = dict_get_int32 (dict, "config_type", &config_type);
|
|
||||||
if (ret < 0) {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "couldn't get the config-type"
|
|
||||||
" for %s %s", volinfo->volname, slave);
|
|
||||||
*op_errstr = gf_strdup ("configure command failed, "
|
|
||||||
"please check the log-file\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_SET) {
|
|
||||||
ret = gsync_config_set (volinfo->volname, slave, dict,
|
|
||||||
op_errstr);
|
|
||||||
if (ret)
|
|
||||||
goto out;
|
|
||||||
goto config_done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_DEL) {
|
|
||||||
ret = gsync_config_del (volinfo->volname, slave, dict,
|
|
||||||
op_errstr);
|
|
||||||
goto config_done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET_ALL) ||
|
|
||||||
(config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET))
|
|
||||||
goto out;
|
|
||||||
else {
|
|
||||||
gf_log ("", GF_LOG_WARNING, "Invalid config type");
|
|
||||||
*op_errstr = gf_strdup ("Invalid config type");
|
|
||||||
ret = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
config_done:
|
|
||||||
ret = glusterd_check_restart_gsync_session (volinfo, slave);
|
|
||||||
if (ret)
|
|
||||||
*op_errstr = gf_strdup (GEOREP" conig: Internal error");
|
|
||||||
out:
|
|
||||||
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
glusterd_marker_create_volfile (glusterd_volinfo_t *volinfo)
|
glusterd_marker_create_volfile (glusterd_volinfo_t *volinfo)
|
||||||
{
|
{
|
||||||
@ -4724,7 +4586,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == GF_GSYNC_OPTION_TYPE_CONFIGURE) {
|
if (type == GF_GSYNC_OPTION_TYPE_CONFIG) {
|
||||||
ret = glusterd_gsync_configure (volinfo, slave, dict,
|
ret = glusterd_gsync_configure (volinfo, slave, dict,
|
||||||
op_errstr);
|
op_errstr);
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -258,17 +258,19 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
|||||||
case GD_OP_GSYNC_SET:
|
case GD_OP_GSYNC_SET:
|
||||||
{
|
{
|
||||||
int type = 0;
|
int type = 0;
|
||||||
int config_type = 0;
|
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
char *master = NULL;
|
char *master = NULL;
|
||||||
char *slave = NULL;
|
char *slave = NULL;
|
||||||
char *op_name = NULL;
|
char *op_name = NULL;
|
||||||
|
char *subop = NULL;
|
||||||
gf1_cli_gsync_set_rsp rsp = {0,};
|
gf1_cli_gsync_set_rsp rsp = {0,};
|
||||||
|
|
||||||
ctx = op_ctx;
|
ctx = op_ctx;
|
||||||
rsp.op_ret = op_ret;
|
rsp.op_ret = op_ret;
|
||||||
rsp.op_errno = op_errno;
|
rsp.op_errno = op_errno;
|
||||||
rsp.op_errstr = "";
|
rsp.op_errstr = "";
|
||||||
rsp.op_name = "";
|
rsp.op_name = "";
|
||||||
|
rsp.subop = "";
|
||||||
rsp.master = "";
|
rsp.master = "";
|
||||||
rsp.slave = "";
|
rsp.slave = "";
|
||||||
rsp.glusterd_workdir = conf->workdir;
|
rsp.glusterd_workdir = conf->workdir;
|
||||||
@ -280,10 +282,6 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
|||||||
ret = dict_get_int32 (ctx, "type", &type);
|
ret = dict_get_int32 (ctx, "type", &type);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
rsp.type = type;
|
rsp.type = type;
|
||||||
ret = dict_get_int32 (ctx, "config_type",
|
|
||||||
&config_type);
|
|
||||||
if (ret == 0)
|
|
||||||
rsp.config_type = config_type;
|
|
||||||
ret = dict_get_str (ctx, "master", &master);
|
ret = dict_get_str (ctx, "master", &master);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
rsp.master = master;
|
rsp.master = master;
|
||||||
@ -292,10 +290,11 @@ glusterd_op_send_cli_response (glusterd_op_t op, int32_t op_ret,
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
rsp.slave = slave;
|
rsp.slave = slave;
|
||||||
|
|
||||||
if (config_type == GF_GSYNC_OPTION_TYPE_CONFIG_GET) {
|
if (type == GF_GSYNC_OPTION_TYPE_CONFIG) {
|
||||||
ret = dict_get_str (ctx, "op_name", &op_name);
|
if (dict_get_str (ctx, "op_name", &op_name) == 0)
|
||||||
if (ret == 0)
|
|
||||||
rsp.op_name = op_name;
|
rsp.op_name = op_name;
|
||||||
|
if (dict_get_str (ctx, "subop", &subop) == 0)
|
||||||
|
rsp.subop = subop;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = dict_allocate_and_serialize (ctx,
|
ret = dict_allocate_and_serialize (ctx,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user