[node-patches] Change in ovirt-node[master]: setup: Add NIC identify button

fabiand at fedoraproject.org fabiand at fedoraproject.org
Fri Apr 5 10:37:32 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: setup: Add NIC identify button
......................................................................

setup: Add NIC identify button

Prviously a button to identify a NIC by flashing it's lights was
missing. This button is now present in the NIC details dialog.

rhbz#916946

Change-Id: Ide55fa01474a54528e2d07264ddbdf693934beaf
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/app.py
M scripts/tui/src/ovirt/node/setup/network_page.py
M scripts/tui/src/ovirt/node/ui/__init__.py
M scripts/tui/src/ovirt/node/ui/urwid_builder.py
M scripts/tui/src/ovirt/node/utils/network.py
5 files changed, 29 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/32/13632/1

diff --git a/scripts/tui/src/ovirt/node/app.py b/scripts/tui/src/ovirt/node/app.py
index c60c6fe..cf8f73e 100644
--- a/scripts/tui/src/ovirt/node/app.py
+++ b/scripts/tui/src/ovirt/node/app.py
@@ -332,10 +332,15 @@
         self.ui.quit()
 
     def notice(self, msg):
-        children = [ui.Label("app.notice.text", msg)]
-        dialog = ui.Dialog("app.notice", "Notice", children)
-        dialog.buttons = [ui.CloseButton("app.notice.close")]
-        self.show(dialog)
+        """Displays a notice on the screen
+        """
+        if True:
+            children = [ui.Label("app.notice.text", msg)]
+            dialog = ui.Dialog("app.notice", "Notice", children)
+            dialog.buttons = [ui.CloseButton("app.notice.close")]
+            self.show(dialog)
+        else:
+            self.ui._show_on_notice(msg)
 
     def _check_outstanding_changes(self):
         """This function checks if any UI Element has changed
diff --git a/scripts/tui/src/ovirt/node/setup/network_page.py b/scripts/tui/src/ovirt/node/setup/network_page.py
index 8796c47..73b8db7 100644
--- a/scripts/tui/src/ovirt/node/setup/network_page.py
+++ b/scripts/tui/src/ovirt/node/setup/network_page.py
@@ -181,6 +181,12 @@
             self.application.switch_to_plugin(plugin_type)
             return
 
+        if "dialog.nic.identify" in changes:
+            iface = self._model_extra["dialog.nic.iface"]
+            utils.network.NIC(iface).identify()
+            self.application.notice("Flashing lights now")
+            return
+
         # This object will contain all transaction elements to be executed
         txs = utils.Transaction("DNS and NTP configuration")
 
@@ -346,5 +352,7 @@
         self.children = ws
         self.buttons = [ui.SaveButton("dialog.nic.save", "Save"),
                         ui.CloseButton("dialog.nic.close", "Close"),
+                        ui.Button("dialog.nic.identify",
+                                  "Flash Lights to Identify")
                         ]
         self.plugin._nic_details_group.enabled(False)
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index cc9af30..7344aaa 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -578,6 +578,12 @@
         """
         raise NotImplementedError
 
+    def _show_on_notice(self, text):
+        """Shows the text in the notice field
+        Something liek a HUD display
+        """
+        raise NotImplementedError
+
     def close_dialog(self, dialog):
         """Close the ui.Dialog
         """
diff --git a/scripts/tui/src/ovirt/node/ui/urwid_builder.py b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
index 3e1f4f0..466f152 100644
--- a/scripts/tui/src/ovirt/node/ui/urwid_builder.py
+++ b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
@@ -523,14 +523,10 @@
             self.__menu.set_focus(0)
             columns += [("weight", 0.3, self.__menu)]
 
-        self.__notice = urwid.Text("Note: ")
-        self.__notice_filler = urwid.Filler(self.__notice)
-        self.__notice_attrmap = urwid.AttrMap(self.__notice_filler, "notice")
         columns += [self.__page_frame]
 
         menu_frame_columns = urwid.Columns(columns, 4)
 
-        #("fixed", 3, self.__notice_attrmap),
         body = urwid.Pile([menu_frame_columns])
 
         header = urwid.Text(self.header, wrap='clip')
diff --git a/scripts/tui/src/ovirt/node/utils/network.py b/scripts/tui/src/ovirt/node/utils/network.py
index 7d6fb66..694670e 100644
--- a/scripts/tui/src/ovirt/node/utils/network.py
+++ b/scripts/tui/src/ovirt/node/utils/network.py
@@ -412,6 +412,11 @@
                              vlanids)
         return vlanids[0] if vlanids else None
 
+    def identify(self):
+        """Flash the lights of this NIC to identify it
+        """
+        utils.process.call("ethtool --identify %s 10" % self.iface)
+
     def __str__(self):
         return "<NIC iface='%s' at %s" % (self.iface, hex(id(self)))
 
@@ -528,4 +533,4 @@
     except (OSError, AttributeError):
         print "Warning: could not find __res_init in libresolv.so.2"
         r = -1
-    return r
+    return r
\ No newline at end of file


--
To view, visit http://gerrit.ovirt.org/13632
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide55fa01474a54528e2d07264ddbdf693934beaf
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list