}
run_test 123ai "llog_print display all non skipped records"
-test_123F() {
+test_123_prep() {
remote_mgs_nodsh && skip "remote MGS with nodsh"
[ -d $MOUNT/.lustre ] || setup
- local yaml_file="$TMP/$tfile.yaml"
+ yaml_file="$TMP/$tfile.yaml"
do_facet mgs rm "$yaml_file"
- local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
+ cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
sed 's/config_log://')
# set jobid_var to a different value for test
- local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
+ orig_val=$(do_facet mgs $LCTL get_param jobid_var)
do_facet mgs $LCTL set_param -P jobid_var="TESTNAME"
writeconf_all
echo "Remounting"
setup_noconfig
+}
- # Reapply the config from before
- echo "Setting configuration parameters"
- do_facet mgs "lctl set_param -F $yaml_file"
-
- local set_val=$(do_facet mgs $LCTL get_param jobid_var)
+test_123_restore() {
+ set_val=$(do_facet mgs $LCTL get_param jobid_var)
do_facet mgs $LCTL set_param -P $orig_val
do_facet mgs rm "$yaml_file"
cleanup
}
+
+test_123F() {
+ local yaml_file
+ local cfgfiles
+ local orig_val
+ local set_val
+
+ test_123_prep
+
+ # Reapply the config from before
+ echo "Setting configuration parameters"
+ do_facet mgs "lctl set_param -F $yaml_file"
+
+ test_123_restore
+}
run_test 123F "clear and reset all parameters using set_param -F"
+test_123G() {
+ local yaml_file
+ local cfgfiles
+ local orig_val
+ local set_val
+
+ test_123_prep
+
+ # Reapply the config from before
+ echo "Setting configuration parameters"
+ do_facet mgs "lctl apply_yaml $yaml_file"
+
+ test_123_restore
+}
+run_test 123G "clear and reset all parameters using apply_yaml"
+
+
test_124()
{
[ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
return -1;
}
}
+ if (popt->po_perm && popt->po_file) {
+ fprintf(stderr, "warning: ignoring -P option\n");
+ popt->po_perm = 0;
+ }
return optind;
}
{ PS_NONE, "none" }
};
-void conf_to_set_param(enum paramtype confset, const char *param,
- const char *device, char *buf,
- int bufsize)
+static enum paramtype construct_param(enum paramtype confset, const char *param,
+ const char *device, char *buf,
+ int bufsize, bool convert)
{
char *tmp;
if (confset == PT_SETPARAM) {
strncpy(buf, param, bufsize);
- return;
+ return confset;
}
-
/*
* sys.* params are top level, we just need to trim the sys.
*/
if (tmp) {
tmp += 4;
strncpy(buf, tmp, bufsize);
- return;
+ return PT_SETPARAM;
}
- /*
- * parameters look like type.parameter, we need to stick the device
- * in the middle. Example combine mdt.identity_upcall with device
- * lustre-MDT0000 for mdt.lustre-MDT0000.identity_upcall
- */
+ if (convert) {
+ /*
+ * parameters look like type.parameter, we need to stick the
+ * device in the middle. Example combine mdt.identity_upcall
+ * with device lustre-MDT0000 for
+ * mdt.lustre-MDT0000.identity_upcall
+ */
+
+ tmp = strchrnul(param, '.');
+ snprintf(buf, tmp - param + 1, "%s", param);
+ buf += tmp - param;
+ bufsize -= tmp - param;
+ snprintf(buf, bufsize, ".%s%s", device, tmp);
+ return PT_SETPARAM;
+ }
+ /* create for conf_param */
+ if (strlen(device)) {
+ int rc;
- tmp = strchrnul(param, '.');
- snprintf(buf, tmp - param + 1, "%s", param);
- buf += tmp - param;
- bufsize -= tmp - param;
- snprintf(buf, bufsize, ".%s%s", device, tmp);
+ rc = snprintf(buf, bufsize, "%s.%s", device, param);
+ if (rc < 0)
+ return PT_NONE;
+ return confset;
+ }
+ return PT_NONE;
}
-int lcfg_setparam_yaml(char *func, char *filename)
+int lcfg_apply_param_yaml(char *func, char *filename)
{
FILE *file;
yaml_parser_t parser;
yaml_token_t token;
- int rc = 0;
+ int rc = 0, rc1 = 0;
enum paramtype confset = PT_NONE;
int param = PS_NONE;
char parameter[PARAM_SZ + 1];
char value[PARAM_SZ + 1];
char device[PARAM_SZ + 1];
+ bool convert;
+ convert = !strncmp(func, "set_param", 9);
file = fopen(filename, "rb");
yaml_parser_initialize(&parser);
yaml_parser_set_input_file(&parser, file);
* when we have all 3, create param=val and call the
* appropriate function for set/conf param
*/
- while (token.type != YAML_STREAM_END_TOKEN && rc == 0) {
+ while (token.type != YAML_STREAM_END_TOKEN) {
int i;
yaml_token_delete(&token);
continue;
if (param & PS_PARAM_FOUND) {
- conf_to_set_param(confset,
- (char *)token.data.alias.value,
- device, parameter, PARAM_SZ);
+ enum paramtype rc;
+
+ rc = construct_param(confset,
+ (char *)token.data.alias.value,
+ device, parameter, PARAM_SZ, convert);
+
+ if (rc == PT_NONE)
+ printf("error: conf_param without device\n");
+ confset = rc;
param |= PS_PARAM_SET;
param &= ~PS_PARAM_FOUND;
}
snprintf(buf, size, "%s=%s", parameter, value);
- printf("set_param: %s\n", buf);
- rc = lcfg_setparam_perm(func, buf);
-
+ printf("%s: %s\n", confset == PT_SETPARAM ?
+ "set_param" : "conf_param", buf);
+
+ if (confset == PT_SETPARAM)
+ rc = lcfg_setparam_perm(func, buf);
+ else
+ rc = lcfg_conf_param(func, buf);
+ if (rc) {
+ printf("error: failed to apply parameter rc = %d, tyring next one\n",
+ rc);
+ rc1 = rc;
+ rc = 0;
+ }
confset = PT_NONE;
param = PS_NONE;
parameter[0] = '\0';
yaml_parser_delete(&parser);
fclose(file);
- return rc;
+ return rc1;
+}
+
+int jt_lcfg_applyyaml(int argc, char **argv)
+{
+ int index;
+ struct param_opts popt = {0};
+
+ index = setparam_cmdline(argc, argv, &popt);
+ if (index < 0 || index >= argc)
+ return CMD_HELP;
+
+ return lcfg_apply_param_yaml(argv[0], argv[index]);
}
int jt_lcfg_setparam(int argc, char **argv)
*/
return jt_lcfg_setparam_perm(argc, argv, &popt);
- if (popt.po_file)
- return lcfg_setparam_yaml(argv[0], argv[index]);
-
+ if (popt.po_file) {
+#if LUSTRE_VERSION >= OBD_OCD_VERSION(2,17,0,0)
+ fprintf(stderr, "warning: 'lctl set_param -F' is deprecated, use 'lctl apply_yaml' instead\n");
+ return -EINVAL;
+#else
+ printf("This option left for backward compatibility, please use 'lctl apply_yaml' instead\n");
+ return lcfg_apply_param_yaml(argv[0], argv[index]);
+#endif
+ }
for (i = index; i < argc; i++) {
int rc2;