This gets us rid of iscsi.addTarget() completely. Currently the kickstart iscsi support is limited to: 1) use the same credentials sets for both the discovery and the login, i.e. user can't specify different sets 2) log into every discovered node (i.e. user can't specify only a subset of discovered targets to log into) Note that this change makes it easier to implement an enhancement removing both these limitations. --- pyanaconda/kickstart.py | 25 +++++++++++++---- pyanaconda/storage/iscsi.py | 62 +------------------------------------------ 2 files changed, 20 insertions(+), 67 deletions(-) diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 7e5480c..84acd1d 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -384,15 +384,28 @@ class IgnoreDisk(commands.ignoredisk.RHEL6_IgnoreDisk): class IscsiData(commands.iscsi.F10_IscsiData): def execute(self, anaconda): + self.anaconda = anaconda try: - storage.iscsi.iscsi().addTarget(self.ipaddr, self.port, - self.user, self.password, - self.user_in, self.password_in, - anaconda.intf) - log.info("added iscsi target: %s" %(self.ipaddr,)) - except (IOError, ValueError), e: + discovered_nodes = \ + storage.iscsi.iscsi().discover(self.ipaddr, self.port, + self.user, self.password, + self.user_in, self.password_in, + self.anaconda.intf) + logged_into_nodes = filter(self.iscsi_login, discovered_nodes) + if len(logged_into_nodes) < 1: + msg = _("Could not log into any iSCSI nodes at the portal.") + raise KickstartValueError, formatErrorMsg(self.lineno, + msg=msg) + + except (IOError, ValueError) as e: raise KickstartValueError, formatErrorMsg(self.lineno, msg=str(e)) + def iscsi_login(self, node): + (rc, _) = storage.iscsi.iscsi().log_into_node(node, + self.user, self.password, + self.user_in, self.password_in, + self.anaconda.intf) + return rc class IscsiName(commands.iscsiname.FC6_IscsiName): def execute(self, anaconda): diff --git a/pyanaconda/storage/iscsi.py b/pyanaconda/storage/iscsi.py index c9c21cc..a29fc36 100644 --- a/pyanaconda/storage/iscsi.py +++ b/pyanaconda/storage/iscsi.py @@ -79,7 +79,7 @@ class iscsi(object): This class will automatically discover and login to iBFT (or other firmware) configured iscsi devices when the startup() method gets called. It can also be used to manually configure iscsi devices - through the addTarget() method. + through the discover() and log_into_node() methods. As this class needs to make sure certain things like starting iscsid and logging in to firmware discovered disks only happens once @@ -265,66 +265,6 @@ class iscsi(object): return (rc, msg) - def addTarget(self, ipaddr, port="3260", user=None, pw=None, - user_in=None, pw_in=None, intf=None): - authinfo = None - found = 0 - logged_in = 0 - - if not has_iscsi(): - raise IOError, _("iSCSI not available") - if self._initiator == "": - raise ValueError, _("No initiator name set") - - if user or pw or user_in or pw_in: - # Note may raise a ValueError - authinfo = libiscsi.chapAuthInfo(username=user, password=pw, - reverse_username=user_in, - reverse_password=pw_in) - self.startup(intf) - - # Note may raise an IOError - found_nodes = libiscsi.discover_sendtargets(address=ipaddr, - port=int(port), - authinfo=authinfo) - if found_nodes == None: - raise IOError, _("No iSCSI nodes discovered") - - if intf: - w = intf.waitWindow(_("Logging in to iSCSI nodes"), - _("Logging in to iSCSI nodes")) - - for node in found_nodes: - # skip nodes we already have - if node in self.nodes: - continue - - found = found + 1 - try: - if (authinfo): - node.setAuth(authinfo) - node.login() - log.info("iscsi.addTarget logged in to %s %s %s" % (node.name, node.address, node.port)) - self.nodes.append(node) - logged_in = logged_in + 1 - except IOError, e: - log.warning( - "Could not log into discovered iscsi target %s: %s" % - (node.name, str(e))) - # some nodes may require different credentials - pass - - if intf: - w.pop() - - if found == 0: - raise IOError, _("No new iSCSI nodes discovered") - - if logged_in == 0: - raise IOError, _("Could not log in to any of the discovered nodes") - - self.stabilize(intf) - def writeKS(self, f): if not self.initiatorSet: return -- 1.7.1.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list