diff options
-rw-r--r-- | README | 15 | ||||
-rw-r--r-- | doc/iscsiadm.8 | 4 | ||||
-rw-r--r-- | usr/iscsiadm.c | 38 |
3 files changed, 43 insertions, 14 deletions
@@ -182,8 +182,8 @@ Usage: iscsiadm [OPTION] -m, --mode <op> specify operational mode op = <discovery|node> -m discovery --type=[type] --interface=iscsi_ifacename \ --portal=[ip:port] --login --print=[N] \ - --op=[op]=[NEW | UPDATE | DELETE] - perform [type] discovery for target portal with + --op=[op]=[NEW | UPDATE | DELETE | NONPERSISTENT] + perform [type] discovery for target portal with ip-address [ip] and port [port]. By default this command will searh for a discovery @@ -213,6 +213,10 @@ Usage: iscsiadm [OPTION] iscsiadm will delete records for portals that were not returned during discovery. + If [op] is passed in and the value is + "nonpersistent" iscsiadm will not store + the portals found in the node DB. + See the example section for more info. See below for how to setup iscsi ifaces for @@ -592,6 +596,13 @@ To now log into targets it is the same as with sofware iscsi. See section no longer returned. It will not change the record information for existing portals. + - SendTargets iSCSI Discovery in nonpersistent mode: + + ./iscsiadm -m discovery -t sendtargets -p 192.168.1.1:3260 \ + -o nonpersistent + + This command will perform discovery, but not manipulate the node DB. + - SendTargets iSCSI Discovery with a specific interface. If you wish to only use a subset of the interfaces in /etc/iscsi/ifaces then you can pass them in during discovery: diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8 index 0cb0012..1c60216 100644 --- a/doc/iscsiadm.8 +++ b/doc/iscsiadm.8 @@ -127,7 +127,7 @@ operator. .TP \fB\-o\fR, \fB\-\-op=\fIop\fR Specifies a database operator \fIop\fR. \fIop\fR must be one of -\fInew\fR, \fIdelete\fR, \fIupdate\fR or \fIshow\fR. +\fInew\fR, \fIdelete\fR, \fIupdate\fR, \fIshow\fR or \fInonpersistent\fR. .IP This option is valid for all modes except fw. Delete should not be used on a running session. If it is iscsiadm will stop the session and then delete the record. @@ -142,6 +142,8 @@ record. also used when there are no commands passed into session mode and a running sid is passed in. \fIname\fR and \fIvalue\fR are currently ignored when used with \fIshow\fR. +.IP +\fInonpersistent\fR instructs iscsiadm to not manipulate the node DB. .TP \fB\-p\fR, \fB\-\-portal=\fIip[:port]\fR diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c index 2f3bfad..75cd520 100644 --- a/usr/iscsiadm.c +++ b/usr/iscsiadm.c @@ -60,11 +60,12 @@ enum iscsiadm_mode { }; enum iscsiadm_op { - OP_NOOP = 0x0, - OP_NEW = 0x1, - OP_DELETE = 0x2, - OP_UPDATE = 0x4, - OP_SHOW = 0x8, + OP_NOOP = 0x0, + OP_NEW = 0x1, + OP_DELETE = 0x2, + OP_UPDATE = 0x4, + OP_SHOW = 0x8, + OP_NONPERSISTENT = 0x10 }; static struct option const long_options[] = @@ -128,6 +129,8 @@ str_to_op(char *str) op = OP_UPDATE; else if (!strcmp("show", str)) op = OP_SHOW; + else if (!strcmp("nonpersistent", str)) + op = OP_NONPERSISTENT; else op = OP_NOOP; @@ -1104,7 +1107,7 @@ exec_disc_op_on_recs(discovery_rec_t *drec, struct list_head *rec_list, int info_level, int do_login, int op) { int rc = 0, err, found = 0; - struct node_rec *new_rec; + struct node_rec *new_rec, tmp_rec; /* clean up node db */ if (op & OP_DELETE) @@ -1125,7 +1128,18 @@ exec_disc_op_on_recs(discovery_rec_t *drec, struct list_head *rec_list, } } - idbm_print_discovered(drec, info_level); + memset(&tmp_rec, 0, sizeof(node_rec_t)); + list_for_each_entry(new_rec, rec_list, list) { + switch (info_level) { + case 0: + case -1: + idbm_print_node_flat(NULL, new_rec); + break; + case 1: + idbm_print_node_and_iface_tree(&tmp_rec, new_rec); + } + + } if (!do_login) return 0; @@ -1158,10 +1172,12 @@ do_software_sendtargets(discovery_rec_t *drec, struct list_head *ifaces, * DB lined up, but for now just put all the targets found from * a discovery portal in one place */ - rc = idbm_add_discovery(drec); - if (rc) { - log_error("Could not add new discovery record."); - return rc; + if (!(op & OP_NONPERSISTENT)) { + rc = idbm_add_discovery(drec); + if (rc) { + log_error("Could not add new discovery record."); + return rc; + } } rc = idbm_bind_ifaces_to_nodes(discovery_sendtargets, drec, ifaces, |