Whamcloud - gitweb
LU-4939 obdclass: llog_print params file 20/31620/8
authorBen Evans <bevans@cray.com>
Fri, 9 Mar 2018 20:51:26 +0000 (15:51 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 9 Apr 2018 19:50:15 +0000 (19:50 +0000)
Allow llog_print to handle the params file in yaml

Signed-off-by: Ben Evans <bevans@cray.com>
Change-Id: Icf286bca7a1466bf3c8d9084971e58d2e8b8a651
Test-Parameters: trivial testlist=sanity
Reviewed-on: https://review.whamcloud.com/31620
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
lustre/obdclass/obd_config.c
lustre/tests/sanity.sh

index aaab911..86bae16 100644 (file)
@@ -1889,7 +1889,7 @@ static struct lcfg_type_data {
        { LCFG_DEL_CONN, "del_conn", { "1", "2", "3", "4" }  },
        { LCFG_LOV_ADD_OBD, "add_osc", { "ost", "index", "gen", "UUID" } },
        { LCFG_LOV_DEL_OBD, "del_osc", { "1", "2", "3", "4" } },
-       { LCFG_PARAM, "set_param", { "parameter", "value", "3", "4" } },
+       { LCFG_PARAM, "conf_param", { "parameter", "value", "3", "4" } },
        { LCFG_MARKER, "marker", { "1", "2", "3", "4" } },
        { LCFG_LOG_START, "log_start", { "1", "2", "3", "4" } },
        { LCFG_LOG_END, "log_end", { "1", "2", "3", "4" } },
@@ -1903,6 +1903,7 @@ static struct lcfg_type_data {
        { LCFG_POOL_DEL, "del_pool", { "fsname", "pool", "3", "4" } },
        { LCFG_SET_LDLM_TIMEOUT, "set_ldlm_timeout",
          { "parameter", "2", "3", "4" } },
+       { LCFG_SET_PARAM, "set_param", { "parameter", "value", "3", "4" } },
        { 0, NULL, { NULL, NULL, NULL, NULL } }
 };
 
@@ -1970,6 +1971,30 @@ int class_config_yaml_output(struct llog_rec_hdr *rec, char *buf, int size)
                ptr += snprintf(ptr, end - ptr, ", device: %s",
                                lustre_cfg_string(lcfg, 0));
 
+       if (lcfg->lcfg_command == LCFG_SET_PARAM) {
+               /*
+                * set_param -P parameters have param=val here, separate
+                * them through pointer magic and print them out in
+                * native yamlese
+                */
+               char *cfg_str = lustre_cfg_string(lcfg, 1);
+               char *tmp = strchr(cfg_str, '=');
+               size_t len;
+
+               if (tmp == NULL)
+                       return -ENOTTY;
+
+               ptr += snprintf(ptr, end - ptr, ", %s: ", ldata->ltd_bufs[0]);
+               len = tmp - cfg_str + 1;
+               snprintf(ptr, len, "%s", cfg_str);
+               ptr += len - 1;
+
+               ptr += snprintf(ptr, end - ptr, ", %s: ", ldata->ltd_bufs[1]);
+               ptr += snprintf(ptr, end - ptr, "%s", tmp + 1);
+
+               goto out_done;
+       }
+
        for (i = 1; i < lcfg->lcfg_bufcount; i++) {
                if (LUSTRE_CFG_BUFLEN(lcfg, i) > 0)
                        ptr += snprintf(ptr, end - ptr, ", %s: %s",
@@ -1977,6 +2002,7 @@ int class_config_yaml_output(struct llog_rec_hdr *rec, char *buf, int size)
                                        lustre_cfg_string(lcfg, i));
        }
 
+out_done:
        ptr += snprintf(ptr, end - ptr, " }\n");
        /* return consumed bytes */
        rc = ptr - buf;
index efc4b9d..50e7abd 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+d#!/bin/bash
 # -*- tab-width: 8; indent-tabs-mode: t; -*-
 #
 # Run select tests by setting ONLY, or as arguments to the script.
@@ -6205,6 +6205,26 @@ test_60aa() {
 }
 run_test 60aa "llog_print works with FIDs and simple names"
 
+test_60ab() {
+       # test llog_print with params
+       local yaml
+       local orig_val
+
+       orig_val=$(do_facet mgs $LCTL get_param jobid_name)
+       do_facet mgs $LCTL set_param -P jobid_name="testname"
+
+       yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
+           grep jobid_name | tail -n 1)
+
+       local param=`awk '{ print $10 }' <<< "$yaml"`
+       local val=`awk '{ print $12 }' <<< "$yaml"`
+       #return to the default
+       do_facet mgs $LCTL set_param -P jobid_name=$orig_val
+       [ $val = "testname" ] || error "bad value: $val"
+       [ $param = "jobid_name," ] || error "Bad param: $param"
+}
+run_test 60ab "llog_print params output values from set_param -P"
+
 test_60b() { # bug 6411
        [ $PARALLEL == "yes" ] && skip "skip parallel run"