-command_t list[] = {
- {"lnet", jt_lnet, 0, "lnet {configure | unconfigure} [--all]"},
- {"route", jt_route, 0, "route {add | del | show | help}"},
- {"net", jt_net, 0, "net {add | del | show | help}"},
- {"routing", jt_routing, 0, "routing {show | help}"},
- {"set", jt_set, 0, "set {tiny_buffers | small_buffers | large_buffers"
- " | routing}"},
- {"import", jt_import, 0, "import {--add | --del | --show | "
- "--help} FILE.yaml"},
- {"export", jt_export, 0, "export {--help} FILE.yaml"},
- {"stats", jt_stats, 0, "stats {show | help}"},
- {"peer", jt_peers, 0, "peer {add | del | show | help}"},
- {"help", Parser_help, 0, "help"},
- {"exit", Parser_quit, 0, "quit"},
- {"quit", Parser_quit, 0, "quit"},
- { 0, 0, 0, NULL }
-};
+static int jt_list_peer(int argc, char **argv)
+{
+ int rc;
+ struct cYAML *err_rc = NULL, *list_rc = NULL;
+
+ rc = check_cmd(peer_cmds, "peer", "list", 0, argc, argv);
+ if (rc)
+ return rc;
+
+ rc = lustre_lnet_list_peer(-1, &list_rc, &err_rc);
+
+ if (rc != LUSTRE_CFG_RC_NO_ERR)
+ cYAML_print_tree2file(stderr, err_rc);
+ else if (list_rc)
+ cYAML_print_tree(list_rc);
+
+ cYAML_free_tree(err_rc);
+ cYAML_free_tree(list_rc);
+
+ return rc;
+}
+
+static int jt_ping(int argc, char **argv)
+{
+ struct cYAML *err_rc = NULL;
+ struct cYAML *show_rc = NULL;
+ int timeout = 1000;
+ int rc = 0, opt;
+
+ const char *const short_options = "t:h";
+ const struct option long_options[] = {
+ { "timeout", 1, NULL, 't' },
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+
+ while ((opt = getopt_long(argc, argv, short_options,
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 't':
+ timeout = 1000 * atol(optarg);
+ break;
+ case 'h':
+ printf("ping nid[,nid,...]\n"
+ "\t --timeout: ping timeout\n"
+ "\t --help: display this help\n");
+ return 0;
+ default:
+ return 0;
+ }
+ }
+
+ for (; optind < argc; optind++)
+ rc = lustre_lnet_ping_nid(argv[optind], timeout, -1, &show_rc, &err_rc);
+
+ if (show_rc)
+ cYAML_print_tree(show_rc);
+
+ if (err_rc)
+ cYAML_print_tree2file(stderr, err_rc);
+
+ cYAML_free_tree(err_rc);
+ cYAML_free_tree(show_rc);
+
+ return rc;
+}
+
+static int jt_discover(int argc, char **argv)
+{
+ struct cYAML *err_rc = NULL;
+ struct cYAML *show_rc = NULL;
+ int force = 0;
+ int rc = 0, opt;
+
+ const char *const short_options = "fh";
+ const struct option long_options[] = {
+ { "force", 0, NULL, 'f' },
+ { "help", 0, NULL, 'h' },
+ { NULL, 0, NULL, 0 },
+ };
+
+ while ((opt = getopt_long(argc, argv, short_options,
+ long_options, NULL)) != -1) {
+ switch (opt) {
+ case 'f':
+ force = 1;
+ break;
+ case 'h':
+ printf("discover nid[,nid,...]\n"
+ "\t --force: force discovery\n"
+ "\t --help: display this help\n");
+ return 0;
+ default:
+ return 0;
+ }
+ }
+
+ for (; optind < argc; optind++)
+ rc = lustre_lnet_discover_nid(argv[optind], force, -1, &show_rc,
+ &err_rc);
+
+ if (show_rc)
+ cYAML_print_tree(show_rc);
+
+ if (err_rc)
+ cYAML_print_tree2file(stderr, err_rc);
+
+ cYAML_free_tree(err_rc);
+ cYAML_free_tree(show_rc);
+
+ return rc;
+}
+
+static int lnetctl_list_commands(int argc, char **argv)
+{
+ char buffer[81] = ""; /* 80 printable chars + terminating NUL */
+
+ Parser_list_commands(cmd_list, buffer, sizeof(buffer), NULL, 0, 4);
+
+ return 0;
+}