Resolves: rhbz#500273 In this initial support all used nodes will be either iface bound using default iface. --- data/ui/adddrive.glade | 33 +++++++++++++++++++++++++++++ pyanaconda/iw/advanced_storage.py | 18 ++++++++++++++- pyanaconda/storage/iscsi.py | 42 +++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) diff --git a/data/ui/adddrive.glade b/data/ui/adddrive.glade index cf8ad47..6a0a7cc 100644 --- a/data/ui/adddrive.glade +++ b/data/ui/adddrive.glade @@ -140,6 +140,39 @@ </child> <child> + <widget class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">18</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkCheckButton" id="iscsiBindCheck"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Bind targets to network interfaces</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> <widget class="GtkRadioButton" id="zfcpRadio"> <property name="visible">True</property> <property name="label" translatable="yes">Add _ZFCP LUN</property> diff --git a/pyanaconda/iw/advanced_storage.py b/pyanaconda/iw/advanced_storage.py index ade1135..9cd53f9 100644 --- a/pyanaconda/iw/advanced_storage.py +++ b/pyanaconda/iw/advanced_storage.py @@ -393,7 +393,7 @@ def addFcoeDrive(anaconda): dialog.destroy() return rc -def addIscsiDrive(anaconda): +def addIscsiDrive(anaconda, bind=False): """ Displays a series of dialogs that walk the user through discovering and logging into iscsi nodes. @@ -407,6 +407,15 @@ def addIscsiDrive(anaconda): log.info("addIscsiDrive(): early exit, network disabled.") return gtk.RESPONSE_CANCEL + # This will modify behaviour of iscsi.discovery() function + if pyanaconda.storage.iscsi.iscsi().mode == "none" and not bind: + pyanaconda.storage.iscsi.iscsi().delete_interfaces() + elif (pyanaconda.storage.iscsi.iscsi().mode == "none" and bind) \ + or pyanaconda.storage.iscsi.iscsi().mode == "bind": + active = set(network.getActiveNetDevs()) + created = set(pyanaconda.storage.iscsi.iscsi().ifaces.values()) + pyanaconda.storage.iscsi.iscsi().create_interfaces(active - created) + wizard = iSCSIGuiWizard() login_ok_nodes = pih.drive_iscsi_addition(anaconda, wizard) if len(login_ok_nodes): @@ -454,6 +463,10 @@ def addDrive(anaconda): if not pyanaconda.storage.iscsi.has_iscsi(): dxml.get_widget("iscsiRadio").set_sensitive(False) dxml.get_widget("iscsiRadio").set_active(False) + dxml.get_widget("iscsiBindCheck").set_sensitive(False) + else: + dxml.get_widget("iscsiBindCheck").set_active(bool(pyanaconda.storage.iscsi.iscsi().ifaces)) + dxml.get_widget("iscsiBindCheck").set_sensitive(pyanaconda.storage.iscsi.iscsi().mode == "none") if not pyanaconda.storage.fcoe.has_fcoe(): dxml.get_widget("fcoeRadio").set_sensitive(False) @@ -474,7 +487,8 @@ def addDrive(anaconda): return False if dxml.get_widget("iscsiRadio").get_active() and pyanaconda.storage.iscsi.has_iscsi(): - rc = addIscsiDrive(anaconda) + bind = dxml.get_widget("iscsiBindCheck").get_active() + rc = addIscsiDrive(anaconda, bind) elif dxml.get_widget("fcoeRadio").get_active() and pyanaconda.storage.fcoe.has_fcoe(): rc = addFcoeDrive(anaconda) elif dxml.get_widget("zfcpRadio") is not None and dxml.get_widget("zfcpRadio").get_active(): diff --git a/pyanaconda/storage/iscsi.py b/pyanaconda/storage/iscsi.py index bcc41af..dab323c 100644 --- a/pyanaconda/storage/iscsi.py +++ b/pyanaconda/storage/iscsi.py @@ -98,6 +98,7 @@ class iscsi(object): self._initiator = "" self.initiatorSet = False self.started = False + self.ifaces = {} if flags.ibft: try: @@ -137,6 +138,16 @@ class iscsi(object): itertools.chain(*self.discovered_targets.values()) if logged_in] + self.ibftNodes + def _getMode(self): + if not self.active_nodes(): + return "none" + if self.ifaces: + return "bind" + else: + return "default" + + mode = property(_getMode) + def _mark_node_active(self, node, active=True): """Mark node as one logged in to @@ -186,6 +197,37 @@ class iscsi(object): if intf: w.pop() + def create_interfaces(self, ifaces): + for iface in ifaces: + iscsi_iface_name = "iface%d" % len(self.ifaces) + #iscsiadm -m iface -I iface0 --op=new + iutil.execWithRedirect("iscsiadm", + ["-m", "iface", "-I", iscsi_iface_name, "--op=new"], + stdout="/dev/tty5", + stderr="/dev/tty5") + #iscsiadm -m iface -I iface0 --op=update -n iface.net_ifacename -v eth0 + iutil.execWithRedirect("iscsiadm", + ["-m", "iface", "-I", iscsi_iface_name, + "--op=update", "-n", + "iface.net_ifacename", "-v", iface], + stdout="/dev/tty5", + stderr="/dev/tty5") + + self.ifaces[iscsi_iface_name] = iface + log.debug("created_interface %s:%s" % (iscsi_iface_name, iface)) + + def delete_interfaces(self): + if not self.ifaces: + return None + for iscsi_iface_name in self.ifaces: + #iscsiadm -m iface -I iface0 --op=delete + iutil.execWithRedirect("iscsiadm", + ["-m", "iface", "-I", iscsi_iface_name, + "--op=delete"], + stdout="/dev/tty5", + stderr="/dev/tty5") + self.ifaces = {} + def startup(self, intf = None): if self.started: return -- 1.7.4 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list