summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2009-10-11 21:22:30 -0500
committerMike Christie <michaelc@cs.wisc.edu>2009-10-11 21:22:30 -0500
commit333f720ded74ab96281157d538e864682cbc5402 (patch)
treebb501ab5d039bb745415dd61d24bba40b3614ab5
parentce63c33527a2ec22d9df4eda8b9e71cc7d325b9c (diff)
downloadopen-iscsi-333f720ded74ab96281157d538e864682cbc5402.tar.gz
iscsiadm: fix discovery record use
iscsiadm is not using the discovery record settings. This has iscsiadm -m discovery -t st -p ip:port search for a discovery setting for ip:port. If found it will use those values for discovery. Previously it would always use the iscsid.conf settings. To change the discovery settings for a record you can do iscsiadm -m discovery -p ip:port -o update -n setting_name -v value like in node mode. Or you can completely remove the discovery record and targets found through it by doing iscsiadm -m discovery -p ip:port -o delete then run the discovery command which will then use the iscsid.conf values and create a new discovery record.
-rw-r--r--README18
-rw-r--r--doc/iscsiadm.84
-rw-r--r--usr/idbm.c8
-rw-r--r--usr/idbm.h2
-rw-r--r--usr/iscsiadm.c13
5 files changed, 25 insertions, 20 deletions
diff --git a/README b/README
index 1f1d9fc..43a4569 100644
--- a/README
+++ b/README
@@ -186,11 +186,15 @@ Usage: iscsiadm [OPTION]
perform [type] discovery for target portal with
ip-address [ip] and port [port].
- By default this command will remove records
- for portals no longer returned. And, if a portal is
- returned by the target, then the discovery command
- will create a new record or modify an existing one
- with values from iscsi.conf and the command line.
+ By default this command will searh for a discovery
+ record for ip:port, and if found will use the
+ record's settings for discovery. If a record does
+ not exist iscsiadm will create one. It will then
+ remove records for portals no longer returned. And,
+ if a portal is returned by the target, then the
+ discovery command will create a new record or modify
+ an existing one with values from iscsi.conf and the
+ command line.
[op] can be passed in multiple times to this
command, and it will alter the DB manipulation.
@@ -200,8 +204,8 @@ Usage: iscsiadm [OPTION]
not yet have records in the db.
If [op] is passed in and the value is
- "update", iscsiadm will update records using info
- from iscsi.conf and the command line for portals
+ "update", iscsiadm will update node records using
+ info from iscsi.conf and the command line for portals
that are returned during discovery and have
a record in the db.
diff --git a/doc/iscsiadm.8 b/doc/iscsiadm.8
index 8599efa..8131054 100644
--- a/doc/iscsiadm.8
+++ b/doc/iscsiadm.8
@@ -134,9 +134,9 @@ record.
.IP
\fInew\fR creates a new database record for a given \fIportal\fR (IP address and port number). In discovery mode, iscsiadm will create new records for portals returned by the target.
.IP
-\fIdelete\fR deletes a specified \fIrecid\fR. In discovery node, iscsiadm will delete records for portals that are no longer returned.
+\fIdelete\fR deletes a specified \fIrecid\fR. In discovery node, if iscsiadm is performing discovery it will delete records for portals that are no longer returned.
.IP
-\fIupdate\fR will update the \fIrecid\fR with \fIname\fR to the specified \fIvalue\fR. In discovery node the \fIrecid\fR, \fIname\fR and \fIvalue\fR arguments are not needed. The update operation will operate on the portals returned by the target, and will update the record with info from the config file and command line.
+\fIupdate\fR will update the \fIrecid\fR with \fIname\fR to the specified \fIvalue\fR. In discovery node, if iscsiadm is performing discovery the \fIrecid\fR, \fIname\fR and \fIvalue\fR arguments are not needed. The update operation will operate on the portals returned by the target, and will update the node records with info from the config file and command line.
.IP
\fIshow\fR is the default behaviour for node, discovery and iface mode. It is
also used when there are no commands passed into session mode and a running
diff --git a/usr/idbm.c b/usr/idbm.c
index ca5479e..5d1611e 100644
--- a/usr/idbm.c
+++ b/usr/idbm.c
@@ -1519,17 +1519,15 @@ free_portal:
return rc;
}
-int
-idbm_add_discovery(discovery_rec_t *newrec, int overwrite)
+int idbm_add_discovery(discovery_rec_t *newrec)
{
discovery_rec_t rec;
int rc;
if (!idbm_discovery_read(&rec, newrec->address,
newrec->port)) {
- if (!overwrite)
- return 0;
- log_debug(7, "overwriting existing record");
+ log_debug(7, "disc rec already exists");
+ return 0;
} else
log_debug(7, "adding new DB record");
diff --git a/usr/idbm.h b/usr/idbm.h
index 0609c47..8fdd863 100644
--- a/usr/idbm.h
+++ b/usr/idbm.h
@@ -130,7 +130,7 @@ extern int idbm_bind_ifaces_to_nodes(idbm_disc_nodes_fn *disc_node_fn,
extern int idbm_add_nodes(node_rec_t *newrec,
discovery_rec_t *drec, struct list_head *ifaces,
int overwrite);
-extern int idbm_add_discovery(discovery_rec_t *newrec, int overwrite);
+extern int idbm_add_discovery(discovery_rec_t *newrec);
extern void idbm_sendtargets_defaults(struct iscsi_sendtargets_config *cfg);
extern void idbm_slp_defaults(struct iscsi_slp_config *cfg);
extern int idbm_discovery_read(discovery_rec_t *rec, char *addr,
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index c9f9a88..d4f7925 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -1183,7 +1183,7 @@ 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, op & OP_UPDATE);
+ rc = idbm_add_discovery(drec);
if (rc) {
log_error("Could not add new discovery record.");
return rc;
@@ -1927,9 +1927,11 @@ main(int argc, char **argv)
goto out;
}
- idbm_sendtargets_defaults(&drec.u.sendtargets);
- strlcpy(drec.address, ip, sizeof(drec.address));
- drec.port = port;
+ if (idbm_discovery_read(&drec, ip, port)) {
+ idbm_sendtargets_defaults(&drec.u.sendtargets);
+ strlcpy(drec.address, ip, sizeof(drec.address));
+ drec.port = port;
+ }
if (do_sendtargets(&drec, &ifaces, info_level,
do_login, op)) {
@@ -2002,7 +2004,8 @@ main(int argc, char **argv)
}
set_param.name = name;
set_param.value = value;
- if (idbm_discovery_set_param(&set_param, &drec))
+ if (idbm_discovery_set_param(&set_param,
+ &drec))
rc = -1;
} else {
log_error("operation is not supported.");