*
* LGPL HEADER END
*
- * Copyright (c) 2014, 2016, Intel Corporation.
+ * Copyright (c) 2014, 2017, Intel Corporation.
*
* Author:
* Amir Shehata <amir.shehata@intel.com>
"\t NID in the list becomes the Primary NID of a newly created\n"
"\t peer. \n"
"\t--nid: one or more peer NIDs\n"
- "\t--non_mr: create this peer as not Multi-Rail capable\n"},
+ "\t--non_mr: create this peer as not Multi-Rail capable\n"
+ "\t--ip2nets: specify a range of nids per peer"},
{"del", jt_del_peer_nid, 0, "delete a peer NID\n"
"\t--prim_nid: Primary NID of the peer.\n"
"\t--nid: list of NIDs to remove. If none provided,\n"
- "\t peer is deleted\n"},
+ "\t peer is deleted\n"
+ "\t--ip2nets: specify a range of nids per peer"},
{"show", jt_show_peer, 0, "show peer information\n"
"\t--nid: NID of peer to filter on.\n"
"\t--verbose: display detailed output per peer."
}
rc = lustre_lnet_show_route(network, gateway, hop, prio, detail, -1,
- &show_rc, &err_rc);
+ &show_rc, &err_rc, false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
}
}
- rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_net(network, (int) detail, -1, &show_rc, &err_rc,
+ false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
if (rc)
return rc;
- rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc, false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
int rc;
FILE *f = NULL;
int opt;
+ bool backup = false;
+ char *file = NULL;
- const char *const short_options = "h";
+ const char *const short_options = "bh";
static const struct option long_options[] = {
+ { .name = "backup", .has_arg = no_argument, .val = 'b' },
{ .name = "help", .has_arg = no_argument, .val = 'h' },
{ .name = NULL } };
while ((opt = getopt_long(argc, argv, short_options,
long_options, NULL)) != -1) {
switch (opt) {
+ case 'b':
+ backup = true;
+ break;
case 'h':
+ default:
printf("export > FILE.yaml : export configuration\n"
+ "\t--backup: export only what's necessary for reconfig\n"
"\t--help: display this help\n");
return 0;
- default:
- return 0;
}
}
- if (argc >= 2) {
- f = fopen(argv[1], "w");
+ if (backup && argc >= 3)
+ file = argv[2];
+ else if (!backup && argc >= 2)
+ file = argv[1];
+ else
+ f = stdout;
+
+ if (file) {
+ f = fopen(file, "w");
if (f == NULL)
return -1;
- } else
- f = stdout;
+ }
- rc = lustre_lnet_show_net(NULL, 2, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_net(NULL, 2, -1, &show_rc, &err_rc, backup);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
}
rc = lustre_lnet_show_route(NULL, NULL, -1, -1, 1, -1, &show_rc,
- &err_rc);
+ &err_rc, backup);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
err_rc = NULL;
}
- rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_routing(-1, &show_rc, &err_rc, backup);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
err_rc = NULL;
}
- rc = lustre_lnet_show_peer(NULL, 2, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_peer(NULL, 2, -1, &show_rc, &err_rc, backup);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
cYAML_free_tree(err_rc);
struct cYAML *err_rc = NULL;
int rc = LUSTRE_CFG_RC_NO_ERR, opt, i;
bool non_mr = false;
-
- const char *const short_options = "k:n:m";
- const struct option long_options[] = {
- { "prim_nid", 1, NULL, 'k' },
- { "nid", 1, NULL, 'n' },
- { "non_mr", 0, NULL, 'm'},
- { NULL, 0, NULL, 0 },
- };
+ bool ip2nets = false, nid_list = false, prim_nid_present = false;
+
+ const char *const short_opts = "k:mn:";
+ const struct option long_opts[] = {
+ { .name = "prim_nid", .has_arg = required_argument, .val = 'k' },
+ { .name = "non_mr", .has_arg = no_argument, .val = 'm' },
+ { .name = "nid", .has_arg = required_argument, .val = 'n' },
+ { .name = "ip2nets", .has_arg = required_argument, .val = 'i' },
+ { .name = NULL } };
rc = check_cmd(peer_cmds, "peer", "add", 2, argc, argv);
if (rc)
return rc;
- while ((opt = getopt_long(argc, argv, short_options,
- long_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, short_opts,
+ long_opts, NULL)) != -1) {
switch (opt) {
case 'k':
+ prim_nid_present = true;
+ if (ip2nets) {
+ cYAML_build_error(-1, -1, "peer", "add",
+ "ip2nets can not be specified"
+ " along side prim_nid parameter.",
+ &err_rc);
+ goto failed;
+ }
prim_nid = optarg;
break;
+ case 'i':
case 'n':
+ if (opt == 'i')
+ ip2nets = true;
+
+ if (opt == 'n')
+ nid_list = true;
+
+ if (ip2nets && (nid_list || prim_nid_present)) {
+ cYAML_build_error(-1, -1, "peer", "add",
+ "ip2nets can not be specified"
+ " along side nid or prim_nid"
+ " parameters", &err_rc);
+ goto failed;
+ }
+
size = lustre_lnet_parse_nids(optarg, nids, size,
&nids2);
if (nids2 == NULL)
}
}
+ for (; optind < argc; optind++) {
+ size = lustre_lnet_parse_nids(argv[optind], nids, size,
+ &nids2);
+ if (nids2 == NULL)
+ goto failed;
+ nids = nids2;
+ }
+
rc = lustre_lnet_config_peer_nid(prim_nid, nids, size,
- !non_mr, -1, &err_rc);
+ !non_mr, ip2nets, -1, &err_rc);
failed:
if (nids) {
char **nids = NULL, **nids2 = NULL;
struct cYAML *err_rc = NULL;
int rc = LUSTRE_CFG_RC_NO_ERR, opt, i, size = 0;
+ bool ip2nets = false, nid_list = false, prim_nid_present = false;
- const char *const short_options = "k:n:";
- const struct option long_options[] = {
- { "prim_nid", 1, NULL, 'k' },
- { "nid", 1, NULL, 'n' },
- { NULL, 0, NULL, 0 },
- };
+ const char *const short_opts = "k:n:";
+ const struct option long_opts[] = {
+ { .name = "prim_nid", .has_arg = required_argument, .val = 'k' },
+ { .name = "nid", .has_arg = required_argument, .val = 'n' },
+ { .name = "ip2nets", .has_arg = required_argument, .val = 'i' },
+ { .name = NULL } };
rc = check_cmd(peer_cmds, "peer", "del", 2, argc, argv);
if (rc)
return rc;
- while ((opt = getopt_long(argc, argv, short_options,
- long_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, short_opts,
+ long_opts, NULL)) != -1) {
switch (opt) {
case 'k':
+ prim_nid_present = true;
+ if (ip2nets) {
+ cYAML_build_error(-1, -1, "peer", "add",
+ "ip2nets can not be specified"
+ " along side prim_nid parameter.",
+ &err_rc);
+ goto failed;
+ }
prim_nid = optarg;
break;
+ case 'i':
case 'n':
+ if (opt == 'i')
+ ip2nets = true;
+
+ if (opt == 'n')
+ nid_list = true;
+
+ if (ip2nets && (nid_list || prim_nid_present)) {
+ cYAML_build_error(-1, -1, "peer", "add",
+ "ip2nets can not be specified"
+ " along side nid or prim_nid"
+ " parameters", &err_rc);
+ goto failed;
+ }
size = lustre_lnet_parse_nids(optarg, nids, size,
&nids2);
if (nids2 == NULL)
}
}
- rc = lustre_lnet_del_peer_nid(prim_nid, nids, size, -1, &err_rc);
+ for (; optind < argc; optind++) {
+ size = lustre_lnet_parse_nids(argv[optind], nids, size,
+ &nids2);
+ if (nids2 == NULL)
+ goto failed;
+ nids = nids2;
+ }
+
+ rc = lustre_lnet_del_peer_nid(prim_nid, nids, size, ip2nets, -1, &err_rc);
failed:
if (nids) {
struct cYAML *err_rc = NULL, *show_rc = NULL;
long int detail = 0;
- const char *const short_options = "n:v::h";
- const struct option long_options[] = {
- { "nid", 1, NULL, 'n' },
- { "verbose", 2, NULL, 'v' },
- { "help", 0, NULL, 'h' },
- { NULL, 0, NULL, 0 },
- };
+ const char *const short_opts = "hn:v::";
+ const struct option long_opts[] = {
+ { .name = "help", .has_arg = no_argument, .val = 'h' },
+ { .name = "nid", .has_arg = required_argument, .val = 'n' },
+ { .name = "verbose", .has_arg = optional_argument, .val = 'v' },
+ { .name = NULL } };
rc = check_cmd(peer_cmds, "peer", "show", 1, argc, argv);
if (rc)
return rc;
- while ((opt = getopt_long(argc, argv, short_options,
- long_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, short_opts,
+ long_opts, NULL)) != -1) {
switch (opt) {
case 'n':
nid = optarg;
}
}
- rc = lustre_lnet_show_peer(nid, (int) detail, -1, &show_rc, &err_rc);
+ rc = lustre_lnet_show_peer(nid, (int) detail, -1, &show_rc, &err_rc,
+ false);
if (rc != LUSTRE_CFG_RC_NO_ERR)
cYAML_print_tree2file(stderr, err_rc);
int timeout = 1000;
int rc = 0, opt;
- const char *const short_options = "t:h";
+ const char *const short_options = "ht:";
const struct option long_options[] = {
- { "timeout", 1, NULL, 't' },
- { "help", 0, NULL, 'h' },
- { NULL, 0, NULL, 0 },
- };
+ { .name = "help", .has_arg = no_argument, .val = 'h' },
+ { .name = "timeout", .has_arg = required_argument, .val = 't' },
+ { .name = NULL } };
while ((opt = getopt_long(argc, argv, short_options,
long_options, NULL)) != -1) {
const char *const short_options = "fh";
const struct option long_options[] = {
- { "force", 0, NULL, 'f' },
- { "help", 0, NULL, 'h' },
- { NULL, 0, NULL, 0 },
- };
+ { .name = "force", .has_arg = no_argument, .val = 'f' },
+ { .name = "help", .has_arg = no_argument, .val = 'h' },
+ { .name = NULL } };
while ((opt = getopt_long(argc, argv, short_options,
long_options, NULL)) != -1) {