[PATCH] (v2) Add support ford iSCSI iface binding.

Radek Vykydal rvykydal at redhat.com
Tue Apr 16 13:28:30 UTC 2013


In v2:
- added keyboard access to bind checkbutton
- configration of iscsi ifaces moved to _discovery (worker thread)
- bind checkbutton made insensitive during discovery

---
 pyanaconda/ui/gui/spokes/advstorage/iscsi.glade | 30 +++++++++++++++++++++++++
 pyanaconda/ui/gui/spokes/advstorage/iscsi.py    | 27 ++++++++++++++++++----
 2 files changed, 53 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/advstorage/iscsi.glade b/pyanaconda/ui/gui/spokes/advstorage/iscsi.glade
index 34b0c41..abe5d1e 100644
--- a/pyanaconda/ui/gui/spokes/advstorage/iscsi.glade
+++ b/pyanaconda/ui/gui/spokes/advstorage/iscsi.glade
@@ -643,6 +643,23 @@
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
+                        <property name="top_attach">7</property>
+                        <property name="width">3</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="bindCheckbutton">
+                        <property name="label" translatable="yes">_Bind targets to network interfaces</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="xalign">0</property>
+                        <property name="use_underline">True</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="left_attach">0</property>
                         <property name="top_attach">6</property>
                         <property name="width">3</property>
                         <property name="height">1</property>
@@ -720,6 +737,17 @@
                                 </child>
                               </object>
                             </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                                <property name="title" translatable="yes">Interface</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                                  <attributes>
+                                    <attribute name="text">3</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
@@ -1247,6 +1275,8 @@
       <column type="gboolean"/>
       <!-- column-name nodeName -->
       <column type="gchararray"/>
+      <!-- column-name nodeIface -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkTreeModelFilter" id="nodeStoreFiltered">
diff --git a/pyanaconda/ui/gui/spokes/advstorage/iscsi.py b/pyanaconda/ui/gui/spokes/advstorage/iscsi.py
index 54d79a0..4aae41e 100644
--- a/pyanaconda/ui/gui/spokes/advstorage/iscsi.py
+++ b/pyanaconda/ui/gui/spokes/advstorage/iscsi.py
@@ -26,6 +26,7 @@ from gi.repository import GLib, Gtk
 from pyanaconda import constants
 from pyanaconda.threads import threadMgr, AnacondaThread
 from pyanaconda.ui.gui import GUIObject
+from pyanaconda import nm
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -40,7 +41,7 @@ Credentials = namedtuple("Credentials", ["style",
                                          "targetIP", "initiator", "username",
                                          "password", "rUsername", "rPassword"])
 
-NodeStoreRow = namedtuple("NodeStoreRow", ["selected", "notLoggedIn", "name"])
+NodeStoreRow = namedtuple("NodeStoreRow", ["selected", "notLoggedIn", "name", "iface"])
 
 def discover_no_credentials(builder):
     return Credentials._make([STYLE_NONE,
@@ -134,6 +135,10 @@ class ISCSIDialog(GUIObject):
         self._configureGrid = self.builder.get_object("configureGrid")
         self._conditionNotebook = self.builder.get_object("conditionNotebook")
 
+        self._bindCheckbox = self.builder.get_object("bindCheckbutton")
+        self._bindCheckbox.set_active(bool(self.iscsi.ifaces))
+        self._bindCheckbox.set_sensitive(self.iscsi.mode == "none")
+
         self._startButton = self.builder.get_object("startButton")
         self._okButton = self.builder.get_object("okButton")
         self._cancelButton = self.builder.get_object("cancelButton")
@@ -171,13 +176,22 @@ class ISCSIDialog(GUIObject):
         # in order to set the Start button sensitivity.
         self.on_discover_field_changed()
 
-    def _discover(self, credentials):
+    def _discover(self, credentials, bind):
         # This needs to be in its own thread, not marked with gtk_action_* because it's
         # called from on_start_clicked, which is in the GTK main loop.  Those decorators
         # won't do anything special in that case.
         if not self.iscsi.initiatorSet:
             self.iscsi.initiator = credentials.initiator
 
+        # interfaces created here affect nodes that iscsi.discover would return
+        if self.iscsi.mode == "none" and not bind:
+            self.iscsi.delete_interfaces()
+        elif (self.iscsi.mode == "bind"
+              or self.iscsi.mode == "none" and bind):
+            activated = set(nm.nm_activated_devices())
+            created = set(self.iscsi.ifaces.values())
+            self.iscsi.create_interfaces(activated - created)
+
         try:
             self._discoveredNodes = self.iscsi.discover(credentials.targetIP,
                                                         username=credentials.username,
@@ -223,6 +237,8 @@ class ISCSIDialog(GUIObject):
         for child in self._configureGrid.get_children():
             if child == self._initiatorEntry:
                 self._initiatorEntry.set_sensitive(not self.iscsi.initiatorSet)
+            elif child == self._bindCheckbox:
+                self._bindCheckbox.set_sensitive(sensitivity and self.iscsi.mode == "none")
             elif child != self._conditionNotebook:
                 child.set_sensitive(sensitivity)
 
@@ -243,11 +259,13 @@ class ISCSIDialog(GUIObject):
         discoveredLabel.set_markup(discoveredLabel.get_label() % {"initiatorName": credentials.initiator,
                                                                   "targetAddress": credentials.targetIP})
 
+        bind = self._bindCheckbox.get_active()
+
         spinner = self.builder.get_object("waitSpinner")
         spinner.start()
 
         threadMgr.add(AnacondaThread(name=constants.THREAD_ISCSI_DISCOVER, target=self._discover,
-                                     args=(credentials,)))
+                                     args=(credentials, bind)))
         GLib.timeout_add(250, self._check_discover)
 
     # When the initiator name, ip address, and any auth fields are filled in
@@ -281,7 +299,8 @@ class ISCSIDialog(GUIObject):
 
     def _add_nodes(self, nodes):
         for node in nodes:
-            self._store.append([False, True, node.name])
+            iface =  self.iscsi.ifaces.get(node.iface, node.iface)
+            self._store.append([False, True, node.name, iface])
 
         # We should select the first node by default.
         self._store[0][0] = True
-- 
1.7.11.7



More information about the anaconda-patches mailing list