[node-patches] Change in ovirt-node[master]: pages: Update to reflect network changes

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Dec 11 20:09:37 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: pages: Update to reflect network changes
......................................................................

pages: Update to reflect network changes

Change-Id: Ic17c22f7e84ce2c374e673e3840b49c1b1968ddd
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/bin/ovirt-config-setup-molch
M scripts/tui/src/ovirt/node/plugins/network_page.py
M scripts/tui/src/ovirt/node/plugins/status_page.py
M scripts/tui/src/ovirt/node/plugins/support_page.py
M scripts/tui/src/ovirt/node/tui.py
M scripts/tui/src/ovirt/node/ui/widgets.py
M scripts/tui/src/ovirt/node/utils/__init__.py
M scripts/tui/src/ovirt/node/utils/security.py
8 files changed, 38 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/13/9913/1

diff --git a/scripts/tui/bin/ovirt-config-setup-molch b/scripts/tui/bin/ovirt-config-setup-molch
index 844a59a..996da15 100755
--- a/scripts/tui/bin/ovirt-config-setup-molch
+++ b/scripts/tui/bin/ovirt-config-setup-molch
@@ -2,4 +2,7 @@
 
 export PYTHONPATH=$PYTHONPATH:
 export PYTHONDONTWRITEBYTECODE=x
-python -B -m ovirt.node.main "$@"
+#export PYTHONUNBUFFERED=x
+#export PYTHONDEBUG=
+#export PYTHONVERBOSE=x
+python -t -m ovirt.node.main "$@"
diff --git a/scripts/tui/src/ovirt/node/plugins/network_page.py b/scripts/tui/src/ovirt/node/plugins/network_page.py
index 257af73..45c6f12 100644
--- a/scripts/tui/src/ovirt/node/plugins/network_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/network_page.py
@@ -28,6 +28,7 @@
 import ovirt.node.ui
 import ovirt.node.utils
 import ovirt.node.utils.network
+import ovirt.node.config.network
 
 LOGGER = logging.getLogger(__name__)
 
@@ -52,11 +53,11 @@
         return 10
 
     def model(self):
-        nameservers = ovirt.node.utils.network.nameservers()
+        nameservers = ovirt.node.config.network.nameservers()
         for idx, nameserver in enumerate(nameservers):
             self._model["dns[%d]" % idx] = nameserver
 
-        timeservers = ovirt.node.utils.network.timeservers()
+        timeservers = ovirt.node.config.network.timeservers()
         for idx, timeserver in enumerate(timeservers):
             self._model["ntp[%d]" % idx] = timeserver
 
@@ -135,21 +136,22 @@
         # Populate model with nic specific informations
         iface = self._model["nics"]
         LOGGER.debug("Getting informations for NIC details page")
-        info = ovirt.node.utils.network.node_nics(with_live=True)[iface]
+        cfg = ovirt.node.config.network.iface(iface)
+        live = ovirt.node.utils.network.node_nics()[iface]
 
         self._model.update({
-            "dialog.nic.iface": info["name"],
-            "dialog.nic.driver": info["driver"],
-            "dialog.nic.protocol": info["bootproto"] or "N/A",
-            "dialog.nic.vendor": info["vendor"],
-            "dialog.nic.link_status": "Connected" if info["link_detected"]
+            "dialog.nic.iface": live["name"],
+            "dialog.nic.driver": live["driver"],
+            "dialog.nic.protocol": cfg["bootproto"] or "N/A",
+            "dialog.nic.vendor": live["vendor"],
+            "dialog.nic.link_status": "Connected" if live["link_detected"]
                                                   else "Disconnected",
-            "dialog.nic.hwaddress": info["hwaddr"],
-            "dialog.nic.ipv4.bootproto": info["bootproto"],
-            "dialog.nic.ipv4.address": info["ipaddr"] or "",
-            "dialog.nic.ipv4.netmask": info["netmask"] or "",
-            "dialog.nic.ipv4.gateway": info["gateway"] or "",
-            "dialog.nic.vlanid": "none",
+            "dialog.nic.hwaddress": live["hwaddr"],
+            "dialog.nic.ipv4.bootproto": cfg["bootproto"],
+            "dialog.nic.ipv4.address": cfg["ipaddr"] or "",
+            "dialog.nic.ipv4.netmask": cfg["netmask"] or "",
+            "dialog.nic.ipv4.gateway": cfg["gateway"] or "",
+            "dialog.nic.vlanid": cfg["vlanid"] or "",
         })
 
         padd = lambda l: l.ljust(14)
diff --git a/scripts/tui/src/ovirt/node/plugins/status_page.py b/scripts/tui/src/ovirt/node/plugins/status_page.py
index 5c08068..8558eb8 100644
--- a/scripts/tui/src/ovirt/node/plugins/status_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/status_page.py
@@ -54,8 +54,8 @@
         net_addrs_str = "\nIPv4: {inet}\nIPv6: {inet6}".format(**net_addrs)
 
         num_domains = "N/A"
-        with virt.LibvirtConnection() as con:
-            num_domains = str(con.numOfDomains())
+#        with virt.LibvirtConnection() as con:
+#            num_domains = str(con.numOfDomains())
 
         return {
             "status": virt.virtualization_hardware_status(),
@@ -70,7 +70,7 @@
         This is an ordered list of (path, widget) tuples.
         """
         # Function to expand all "keywords" to the same length
-        aligned = lambda l: l.ljust(16)
+        aligned = lambda l: l.ljust(14)
 
         # Network related widgets, appearing in one row
         network_widgets = [
@@ -142,12 +142,10 @@
         elif "_save" in changes:
             self._widgets["dialog.hostkey"].close()
 
-
     def _build_dialog(self, path, txt, widgets):
         self._widgets.update(dict(widgets))
         self._widgets[path] = ovirt.node.ui.Dialog(txt, widgets)
         return self._widgets[path]
-
 
     def _build_hostkey_dialog(self):
         fp, hk = ovirt.node.utils.security.get_ssh_hostkey()
diff --git a/scripts/tui/src/ovirt/node/plugins/support_page.py b/scripts/tui/src/ovirt/node/plugins/support_page.py
index 0b1ed0b..04eb095 100644
--- a/scripts/tui/src/ovirt/node/plugins/support_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/support_page.py
@@ -33,7 +33,7 @@
 class Plugin(ovirt.node.plugins.NodePlugin):
     def __init__(self, application):
         # Register F8: Display this plugin when F( is pressed
-        application.ui.register_hotkey(["f8"], 
+        application.ui.register_hotkey(["f8"],
                                 lambda: application.ui.display_plugin(self))
 
     def name(self):
diff --git a/scripts/tui/src/ovirt/node/tui.py b/scripts/tui/src/ovirt/node/tui.py
index 0434403..b795193 100644
--- a/scripts/tui/src/ovirt/node/tui.py
+++ b/scripts/tui/src/ovirt/node/tui.py
@@ -80,6 +80,7 @@
                ('plugin.widget.progressbar.uncomplete', None),
                ('plugin.widget.progressbar.complete', None, 'light gray'),
                ('plugin.widget.options.label', 'dark gray, bold'),
+               ('plugin.widget.dialog', None),
                ]
 
     def __init__(self, app):
@@ -104,7 +105,8 @@
         menu_frame_columns = urwid.Columns([("weight", 0.3, self.__menu),
                               self.__page_frame], 4)
 
-        body = urwid.Pile([("fixed", 3, self.__notice_attrmap),
+        body = urwid.Pile([
+#                           ("fixed", 3, self.__notice_attrmap),
                            menu_frame_columns
                         ])
 
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index 455705e..2affe1e 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -61,7 +61,7 @@
         if button != 1 or not urwid.util.is_mouse_press(event):
             return False
 
-        self._emit('click')
+        self._emit('click', self)
         return True
 
 
@@ -168,8 +168,7 @@
 class ModalDialog(urwid.WidgetWrap):
     signals = ['close']
 
-    def __init__(self, title, body, escape_key, previous_widget, bodyattr=None,
-                 titleattr=None):
+    def __init__(self, title, body, escape_key, previous_widget):
         self.escape_key = escape_key
         self.previous_widget = previous_widget
 
@@ -177,11 +176,11 @@
             body = urwid.Text(body)
 
         body = urwid.LineBox(body, title)
-
         overlay = urwid.Overlay(body, previous_widget, 'center',
                                           ('relative', 70), 'middle',
                                           ('relative', 70))
-        super(ModalDialog, self).__init__(overlay)
+        overlay_attrmap = urwid.AttrMap(overlay, "plugin.widget.dialog")
+        super(ModalDialog, self).__init__(overlay_attrmap)
 
     def close(self):
         urwid.emit_signal(self, "close")
@@ -385,6 +384,8 @@
                 bkey = self._button_to_key[button]
                 if key == bkey:
                     button.set_state(True)
+                    LOGGER.debug("Selected option %s (%s)" % (key, button))
+        LOGGER.warning("Could not set selection '%s'" % key)
 
     def set_text(self, txt):
         self.select(txt)
diff --git a/scripts/tui/src/ovirt/node/utils/__init__.py b/scripts/tui/src/ovirt/node/utils/__init__.py
index 6c932cf..1586367 100644
--- a/scripts/tui/src/ovirt/node/utils/__init__.py
+++ b/scripts/tui/src/ovirt/node/utils/__init__.py
@@ -35,8 +35,11 @@
 #        self._aug = _augeas.Augeas() # Is broken
         self._aug.set("/augeas/save/copy_if_rename_fails", "")
 
-    def get(self, p):
-        return self._aug.get(p)
+    def get(self, p, strip_quotes=False):
+        v = self._aug.get(p)
+        if v and strip_quotes:
+            v = v.strip("'\"")
+        return v
 
     def set(self, p, v):
         self._aug.set(p, v)
diff --git a/scripts/tui/src/ovirt/node/utils/security.py b/scripts/tui/src/ovirt/node/utils/security.py
index 2259955..6148ff7 100644
--- a/scripts/tui/src/ovirt/node/utils/security.py
+++ b/scripts/tui/src/ovirt/node/utils/security.py
@@ -38,7 +38,6 @@
     with open(fn_hostkey) as hkf:
         hostkey = hkf.read()
 
-
     hostkey_fp_cmd = "ssh-keygen -l -f '%s'" % fn_hostkey
     stdout = process.pipe(hostkey_fp_cmd, without_retval=True)
     fingerprint = stdout.strip().split(" ")[1]


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic17c22f7e84ce2c374e673e3840b49c1b1968ddd
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