[node-patches] Change in ovirt-node[master]: Add seperate installer and setup

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


Fabian Deutsch has uploaded a new change for review.

Change subject: Add seperate installer and setup
......................................................................

Add seperate installer and setup

Change-Id: I7f74603137881e8f663517df7cae3aa4d05f716c
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
C scripts/tui/bin/ovirt-config-installer
R scripts/tui/bin/ovirt-config-setup
R scripts/tui/src/ovirt/node/app/__init__.py
C scripts/tui/src/ovirt/node/app/installer.py
R scripts/tui/src/ovirt/node/app/setup.py
C scripts/tui/src/ovirt/node/base.py
M scripts/tui/src/ovirt/node/config/defaults.py
M scripts/tui/src/ovirt/node/plugins/__init__.py
M scripts/tui/src/ovirt/node/plugins/setup/engine_page.py
M scripts/tui/src/ovirt/node/plugins/setup/example.py
M scripts/tui/src/ovirt/node/plugins/setup/features.py
M scripts/tui/src/ovirt/node/plugins/setup/kdump_page.py
M scripts/tui/src/ovirt/node/plugins/setup/keyboard_page.py
M scripts/tui/src/ovirt/node/plugins/setup/logging_page.py
M scripts/tui/src/ovirt/node/plugins/setup/monitoring_page.py
M scripts/tui/src/ovirt/node/plugins/setup/network_page.py
M scripts/tui/src/ovirt/node/plugins/setup/ping.py
M scripts/tui/src/ovirt/node/plugins/setup/remote_storage_page.py
M scripts/tui/src/ovirt/node/plugins/setup/security_page.py
M scripts/tui/src/ovirt/node/plugins/setup/snmp_page.py
M scripts/tui/src/ovirt/node/plugins/setup/status_page.py
M scripts/tui/src/ovirt/node/plugins/setup/support_page.py
M scripts/tui/src/ovirt/node/plugins/setup/usage.py
M scripts/tui/src/ovirt/node/ui/__init__.py
M scripts/tui/src/ovirt/node/ui/tui.py
M scripts/tui/src/ovirt/node/utils/__init__.py
M scripts/tui/src/ovirt/node/utils/security.py
M scripts/tui/src/ovirt/node/utils/virt.py
M scripts/tui/src/ovirt/node/valid.py
29 files changed, 99 insertions(+), 150 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/31/9931/1

diff --git a/scripts/tui/bin/ovirt-config-setup-molch b/scripts/tui/bin/ovirt-config-installer
similarity index 77%
copy from scripts/tui/bin/ovirt-config-setup-molch
copy to scripts/tui/bin/ovirt-config-installer
index 996da15..f50eca4 100755
--- a/scripts/tui/bin/ovirt-config-setup-molch
+++ b/scripts/tui/bin/ovirt-config-installer
@@ -5,4 +5,4 @@
 #export PYTHONUNBUFFERED=x
 #export PYTHONDEBUG=
 #export PYTHONVERBOSE=x
-python -t -m ovirt.node.main "$@"
+python -t -m ovirt.node.app.installer "$@"
diff --git a/scripts/tui/bin/ovirt-config-setup-molch b/scripts/tui/bin/ovirt-config-setup
similarity index 78%
rename from scripts/tui/bin/ovirt-config-setup-molch
rename to scripts/tui/bin/ovirt-config-setup
index 996da15..af0610b 100755
--- a/scripts/tui/bin/ovirt-config-setup-molch
+++ b/scripts/tui/bin/ovirt-config-setup
@@ -5,4 +5,4 @@
 #export PYTHONUNBUFFERED=x
 #export PYTHONDEBUG=
 #export PYTHONVERBOSE=x
-python -t -m ovirt.node.main "$@"
+python -t -m ovirt.node.app.setup "$@"
diff --git a/scripts/tui/src/ovirt/node/app.py b/scripts/tui/src/ovirt/node/app/__init__.py
similarity index 95%
rename from scripts/tui/src/ovirt/node/app.py
rename to scripts/tui/src/ovirt/node/app/__init__.py
index 0373706..92f57fc 100644
--- a/scripts/tui/src/ovirt/node/app.py
+++ b/scripts/tui/src/ovirt/node/app/__init__.py
@@ -74,6 +74,8 @@
 
     def run(self):
         self.__load_plugins()
+        if not self.plugins:
+            raise Exception("No plugins found in '%s'" % self.plugin_base)
         self.ui.register_hotkey("f12", self.__drop_to_shell)
         self.ui.register_hotkey("window resize", self.__check_terminal_size)
         self.ui.footer = "Press esc to quit."
@@ -81,4 +83,4 @@
 
     def quit(self):
         LOGGER.info("Quitting")
-        self.ui.quit()
+        self.ui.quit()
\ No newline at end of file
diff --git a/scripts/tui/src/ovirt/node/main.py b/scripts/tui/src/ovirt/node/app/installer.py
similarity index 80%
copy from scripts/tui/src/ovirt/node/main.py
copy to scripts/tui/src/ovirt/node/app/installer.py
index 2e5c3f5..ae6e730 100644
--- a/scripts/tui/src/ovirt/node/main.py
+++ b/scripts/tui/src/ovirt/node/app/installer.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# main.py - Copyright (C) 2012 Red Hat, Inc.
+# ovirt-config-setup.py - Copyright (C) 2012 Red Hat, Inc.
 # Written by Fabian Deutsch <fabiand at redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -19,13 +19,13 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
 """
-Create an setup application instance an start it.
+Create an installer application instance an start it.
 """
 
 import ovirt.node.app
-import ovirt.node.plugins.setup
+import ovirt.node.plugins.installer
 
 
 if __name__ == '__main__':
-    app = ovirt.node.app.Application(ovirt.node.plugins.setup)
+    app = ovirt.node.app.Application(ovirt.node.plugins.installer)
     app.run()
diff --git a/scripts/tui/src/ovirt/node/main.py b/scripts/tui/src/ovirt/node/app/setup.py
similarity index 94%
rename from scripts/tui/src/ovirt/node/main.py
rename to scripts/tui/src/ovirt/node/app/setup.py
index 2e5c3f5..074391b 100644
--- a/scripts/tui/src/ovirt/node/main.py
+++ b/scripts/tui/src/ovirt/node/app/setup.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# main.py - Copyright (C) 2012 Red Hat, Inc.
+# ovirt-config-setup.py - Copyright (C) 2012 Red Hat, Inc.
 # Written by Fabian Deutsch <fabiand at redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
diff --git a/scripts/tui/src/ovirt/node/main.py b/scripts/tui/src/ovirt/node/base.py
similarity index 71%
copy from scripts/tui/src/ovirt/node/main.py
copy to scripts/tui/src/ovirt/node/base.py
index 2e5c3f5..7b8c055 100644
--- a/scripts/tui/src/ovirt/node/main.py
+++ b/scripts/tui/src/ovirt/node/base.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# main.py - Copyright (C) 2012 Red Hat, Inc.
+# base.py - Copyright (C) 2012 Red Hat, Inc.
 # Written by Fabian Deutsch <fabiand at redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -19,13 +19,20 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 
 """
-Create an setup application instance an start it.
+Base for all classes
 """
 
-import ovirt.node.app
-import ovirt.node.plugins.setup
+import logging
 
 
-if __name__ == '__main__':
-    app = ovirt.node.app.Application(ovirt.node.plugins.setup)
-    app.run()
+class Base(object):
+    """Base class for all objects."""
+
+    @property
+    def logger(self):
+        """Logger."""
+        return self._logger
+
+    def __init__(self):
+        """Contructor."""
+        self._logger = logging.getLogger(self.__module__)
\ No newline at end of file
diff --git a/scripts/tui/src/ovirt/node/config/defaults.py b/scripts/tui/src/ovirt/node/config/defaults.py
index 1931d8e..44f0aa1 100644
--- a/scripts/tui/src/ovirt/node/config/defaults.py
+++ b/scripts/tui/src/ovirt/node/config/defaults.py
@@ -39,6 +39,8 @@
 
 import ovirt.node.utils
 import ovirt.node.config
+from ovirt.node import base
+
 
 LOGGER = logging.getLogger(__name__)
 
@@ -99,7 +101,7 @@
     return wrapper
 
 
-class CentralNodeConfiguration(object):
+class CentralNodeConfiguration(base.Base):
     def __init__(self, keys):
         assert type(keys) is tuple, "Keys need to have an order, " + \
                                     "therefor a tuple expected"
@@ -175,12 +177,12 @@
         """
         ovirt_config = defaults()
         if "OVIRT_DNS" not in ovirt_config:
-            LOGGER.debug("No DNS server entry in default config")
+            self.logger.debug("No DNS server entry in default config")
             return
 
         servers = ovirt_config["OVIRT_DNS"]
         if servers is None or servers == "":
-            LOGGER.debug("No DNS servers configured in default config")
+            self.logger.debug("No DNS servers configured in default config")
 
         servers = servers.split(",")
 
diff --git a/scripts/tui/src/ovirt/node/plugins/__init__.py b/scripts/tui/src/ovirt/node/plugins/__init__.py
index fb457c1..a4b52d2 100644
--- a/scripts/tui/src/ovirt/node/plugins/__init__.py
+++ b/scripts/tui/src/ovirt/node/plugins/__init__.py
@@ -22,11 +22,9 @@
 This contains much stuff related to plugins
 """
 import pkgutil
-import logging
 
+from ovirt.node import base
 import ovirt.node.exceptions
-
-LOGGER = logging.getLogger(__name__)
 
 
 def __walk_plugins(module):
@@ -48,7 +46,7 @@
     return modules
 
 
-class NodePlugin(object):
+class NodePlugin(base.Base):
     """
     Basically a plugin provides a model which is changed by the UI (using the
     model() method)
@@ -68,6 +66,7 @@
     validate_changes = True
 
     def __init__(self, application):
+        super(NodePlugin, self).__init__()
         self.__changes = {}
         self.application = application
 
@@ -182,15 +181,15 @@
         Raises:
             An exception on a problem
         """
-        LOGGER.debug("Triggering revalidation of model")
+        self.logger.debug("Triggering revalidation of model")
         is_valid = True
         try:
             model = model or self.model()
             self.on_change(model)
         except NotImplementedError:
-            LOGGER.debug("Plugin has no model")
+            self.logger.debug("Plugin has no model")
         except ovirt.node.exceptions.InvalidData:
-            LOGGER.warning("Plugins model does not pass sematic check: %s" % \
+            self.logger.warning("Plugins model does not pass sematic check: %s" % \
                            model)
             is_valid = False
         finally:
@@ -215,21 +214,21 @@
         change is expected to be a dict.
         """
         if type(change) is not dict:
-            LOGGER.warning("Change is not a dict: %s" % change)
+            self.logger.warning("Change is not a dict: %s" % change)
 
-        LOGGER.debug("Passing UI change to callback on_change: %s" % change)
+        self.logger.debug("Passing UI change to callback on_change: %s" % change)
         if self.validate_changes:
             self.validate(change)
         self.on_change(change)
         self.__changes.update(change)
-        LOGGER.debug("Sum of all UI changes up to now: %s" % self.__changes)
+        self.logger.debug("Sum of all UI changes up to now: %s" % self.__changes)
         return True
 
     def _on_ui_save(self):
         """Called when data should be saved
         Calls merge_changes, but only with values that really changed
         """
-        LOGGER.debug("Request to apply model changes")
+        self.logger.debug("Request to apply model changes")
         effective_changes = self.pending_changes() or {}
         successfull_merge = self.on_merge(effective_changes)
         if successfull_merge:
@@ -260,10 +259,10 @@
             model = self.model()
             for key, value in self.__changes.items():
                 if key in model and value == model[key]:
-                    LOGGER.debug(("Skipping pseudo-change of '%s', value " + \
+                    self.logger.debug(("Skipping pseudo-change of '%s', value " + \
                                   "(%s) did not change") % (key, value))
                 else:
                     effective_changes[key] = value
         else:
-            LOGGER.debug("No effective changes detected.")
+            self.logger.debug("No effective changes detected.")
         return effective_changes if len(effective_changes) > 0 else None
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/engine_page.py b/scripts/tui/src/ovirt/node/plugins/setup/engine_page.py
index 8d97580..daa94a4 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/engine_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/engine_page.py
@@ -21,14 +21,11 @@
 """
 Configure Engine
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
 import ovirt.node.utils
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/example.py b/scripts/tui/src/ovirt/node/plugins/setup/example.py
index d438d89..589b43c 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/example.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/example.py
@@ -21,14 +21,10 @@
 """
 Example plugin with TUI
 """
-import logging
-
 import ovirt.node.plugins
 import ovirt.node.ui
 import ovirt.node.exceptions
 import ovirt.node.valid
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
@@ -86,9 +82,9 @@
     def on_change(self, changes):
         """Applies the changes to the plugins model, will do all required logic
         """
-        LOGGER.debug("checking %s" % changes)
+        self.logger.debug("checking %s" % changes)
         if "foo.hostname" in changes:
-            LOGGER.debug("Found foo.hostname")
+            self.logger.debug("Found foo.hostname")
 
             if "/" in changes["foo.hostname"]:
                 raise ovirt.node.exceptions.InvalidData("No slash allowed")
@@ -101,20 +97,20 @@
 
             if "dis" in changes["foo.hostname"]:
                 self._widgets["foo.port"].enabled(False)
-                LOGGER.debug("change to dis")
+                self.logger.debug("change to dis")
                 self._widgets["foo.section"].text(changes["foo.hostname"])
                 #raise ovirt.node.plugins.ContentRefreshRequest()
             else:
                 self._widgets["foo.port"].enabled(True)
 
         if "foo.port" in changes:
-            LOGGER.debug("Found foo.port")
+            self.logger.debug("Found foo.port")
 
             if "/" in changes["foo.port"]:
                 raise ovirt.node.exceptions.InvalidData("No slashes allowed")
 
         if "dialog.button" in changes:
-            LOGGER.debug("Request to close the dialog")
+            self.logger.debug("Request to close the dialog")
             self._widgets["dialog.dialog"].close()
 
         return True
@@ -122,7 +118,7 @@
     def on_merge(self, effective_changes):
         """Applies the changes to the plugins model, will do all required logic
         """
-        LOGGER.debug("saving %s" % effective_changes)
+        self.logger.debug("saving %s" % effective_changes)
         # Look for conflicts etc
         self._model.update(effective_changes)
 
@@ -131,7 +127,7 @@
         return dialog
 
     def _create_dialog(self, txt):
-        LOGGER.debug("Building dialog")
+        self.logger.debug("Building dialog")
         widgets = [
                 ("dialog.text", ovirt.node.ui.Label(txt)),
                 ("dialog.button", ovirt.node.ui.Button("Close"))
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/features.py b/scripts/tui/src/ovirt/node/plugins/setup/features.py
index 2a17965..4e8720b 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/features.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/features.py
@@ -21,13 +21,10 @@
 """
 A plugin illustrating the features of the TUI
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.ui
 
-
-LOGGER = logging.getLogger(__name__)
 
 features = """
 - Resize the terminal window and watch
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/kdump_page.py b/scripts/tui/src/ovirt/node/plugins/setup/kdump_page.py
index 5c06104..8d7d03e 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/kdump_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/kdump_page.py
@@ -21,13 +21,10 @@
 """
 Configure KDump
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
@@ -89,7 +86,7 @@
     def on_change(self, changes):
         """Applies the changes to the plugins model, will do all required logic
         """
-        LOGGER.debug("New (valid) address: %s" % changes)
+        self.logger.debug("New (valid) address: %s" % changes)
         if "kdump.type" in changes:
             net_types = ["kdump.ssh_location", "kdump.nfs_location"]
 
@@ -109,6 +106,6 @@
         """
 
         if effective_changes:
-            LOGGER.debug("Generating conf according to model and changes")
+            self.logger.debug("Generating conf according to model and changes")
         else:
-            LOGGER.debug("Generating no new conf as there are no changes")
+            self.logger.debug("Generating no new conf as there are no changes")
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/keyboard_page.py b/scripts/tui/src/ovirt/node/plugins/setup/keyboard_page.py
index d914b65..8927c12 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/keyboard_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/keyboard_page.py
@@ -21,12 +21,9 @@
 """
 Configure Keyboard Layout
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.ui
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/logging_page.py b/scripts/tui/src/ovirt/node/plugins/setup/logging_page.py
index 2f56ff4..4a2f86e 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/logging_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/logging_page.py
@@ -21,14 +21,10 @@
 """
 Configure Logging
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
-
-LOGGER = logging.getLogger(__name__)
-
 
 class Plugin(ovirt.node.plugins.NodePlugin):
     _model = None
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/monitoring_page.py b/scripts/tui/src/ovirt/node/plugins/setup/monitoring_page.py
index 2a1ff8e..9945be6 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/monitoring_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/monitoring_page.py
@@ -21,13 +21,10 @@
 """
 Configure Monitoring
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/network_page.py b/scripts/tui/src/ovirt/node/plugins/setup/network_page.py
index 23048c8..0ef7954 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/network_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/network_page.py
@@ -21,15 +21,12 @@
 """
 Network plugin
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
 import ovirt.node.utils.network
 import ovirt.node.config.network
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
@@ -129,7 +126,7 @@
     def _build_nic_details_dialog(self):
         # Populate model with nic specific informations
         iface = self._model["nics"]
-        LOGGER.debug("Getting informations for NIC details page")
+        self.logger.debug("Getting informations for NIC details page")
         live = ovirt.node.utils.network.node_nics()[iface]
 
         self._model.update({
@@ -209,15 +206,15 @@
         changes = self.pending_changes(False)
         effective_model = dict(self._model)
         effective_model.update(effective_changes)
-        LOGGER.info("effm %s" % effective_model)
-        LOGGER.info("effc %s" % effective_changes)
-        LOGGER.info("allc %s" % changes)
+        self.logger.info("effm %s" % effective_model)
+        self.logger.info("effc %s" % effective_changes)
+        self.logger.info("allc %s" % changes)
 
         if "dns[0]" in effective_changes or \
            "dns[1]" in effective_changes:
             new_servers = [v for k, v in effective_model \
                              if k.startswith("dns[")]
-            LOGGER.info("Setting new nameservers: %s" % new_servers)
+            self.logger.info("Setting new nameservers: %s" % new_servers)
             model = ovirt.node.config.defaults.Nameservers()
             model.configure(new_servers)
 
@@ -225,11 +222,11 @@
            "ntp[1]" in effective_changes:
             new_servers = [v for k, v in effective_model \
                              if k.startswith("ntp[")]
-            LOGGER.info("Setting new timeservers: %s" % new_servers)
+            self.logger.info("Setting new timeservers: %s" % new_servers)
             model = ovirt.node.config.defaults.Timeservers()
             model.configure(new_servers)
 
         if "nics" in changes:
             iface = changes["nics"]
-            LOGGER.debug("Opening NIC Details dialog for '%s'" % iface)
+            self.logger.debug("Opening NIC Details dialog for '%s'" % iface)
             return self._build_nic_details_dialog()
\ No newline at end of file
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/ping.py b/scripts/tui/src/ovirt/node/plugins/setup/ping.py
index 3d01cf6..aaa4717 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/ping.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/ping.py
@@ -21,14 +21,11 @@
 """
 A ping tool page
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
 import ovirt.node.utils.process
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
@@ -89,7 +86,7 @@
     def on_change(self, changes):
         """Applies the changes to the plugins model, will do all required logic
         """
-        LOGGER.debug("New (valid) address: %s" % changes)
+        self.logger.debug("New (valid) address: %s" % changes)
         if "ping.address" in changes:
             self._model.update(changes)
         if "ping.count" in changes:
@@ -107,7 +104,7 @@
         if "ping.address" in self._model:
             addr = self._model["ping.address"]
             count = self._model["ping.count"]
-            LOGGER.debug("Pinging %s" % addr)
+            self.logger.debug("Pinging %s" % addr)
 
             cmd = "ping"
             if ovirt.node.valid.IPv6Address().validate(addr):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/remote_storage_page.py b/scripts/tui/src/ovirt/node/plugins/setup/remote_storage_page.py
index 80c3d2d..77fc64c 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/remote_storage_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/remote_storage_page.py
@@ -21,12 +21,9 @@
 """
 Configure Remote Storage
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.ui
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/security_page.py b/scripts/tui/src/ovirt/node/plugins/setup/security_page.py
index d1aef46..5d099f0 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/security_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/security_page.py
@@ -21,13 +21,10 @@
 """
 Configure Security
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/snmp_page.py b/scripts/tui/src/ovirt/node/plugins/setup/snmp_page.py
index a0ce026..1851aeb 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/snmp_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/snmp_page.py
@@ -21,13 +21,10 @@
 """
 Configure SNMP
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.valid
 import ovirt.node.ui
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/status_page.py b/scripts/tui/src/ovirt/node/plugins/setup/status_page.py
index e3dd12e..667f3b8 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/status_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/status_page.py
@@ -21,7 +21,6 @@
 """
 Status plugin
 """
-import logging
 import textwrap
 
 import ovirt.node.plugins
@@ -29,8 +28,6 @@
 import ovirt.node.utils as utils
 import ovirt.node.utils.virt as virt
 import ovirt.node.utils.security
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
@@ -122,20 +119,20 @@
     def on_merge(self, changes):
         # Handle button presses
         if "action.lock" in changes:
-            LOGGER.info("Locking screen")
+            self.logger.info("Locking screen")
 
         elif "action.logoff" in changes:
-            LOGGER.info("Logging off")
+            self.logger.info("Logging off")
             self.application.quit()
 
         elif "action.restart" in changes:
-            LOGGER.info("Restarting")
+            self.logger.info("Restarting")
 
         elif "action.poweroff" in changes:
-            LOGGER.info("Shutting down")
+            self.logger.info("Shutting down")
 
         elif "action.hostkey" in changes:
-            LOGGER.info("Showing hostkey")
+            self.logger.info("Showing hostkey")
             return self._build_hostkey_dialog()
 
         elif "_save" in changes:
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/support_page.py b/scripts/tui/src/ovirt/node/plugins/setup/support_page.py
index 04eb095..1974cb0 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/support_page.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/support_page.py
@@ -21,13 +21,9 @@
 """
 A plugin for a support page
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.ui
-
-
-LOGGER = logging.getLogger(__name__)
 
 
 class Plugin(ovirt.node.plugins.NodePlugin):
diff --git a/scripts/tui/src/ovirt/node/plugins/setup/usage.py b/scripts/tui/src/ovirt/node/plugins/setup/usage.py
index b2513e6..2bd8a4b 100644
--- a/scripts/tui/src/ovirt/node/plugins/setup/usage.py
+++ b/scripts/tui/src/ovirt/node/plugins/setup/usage.py
@@ -21,13 +21,10 @@
 """
 A plugin illustrating how to use the TUI
 """
-import logging
 
 import ovirt.node.plugins
 import ovirt.node.ui
 
-
-LOGGER = logging.getLogger(__name__)
 
 usage = """Plugins need to be derived from a provided class and need to \
 implement a couple of methods.
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index 8eeed93..4aefe8f 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -21,18 +21,12 @@
 """
 This contains abstract UI Elements
 """
-import logging
 
-LOGGER = logging.getLogger(__name__)
-
-
-def deprecated(func):
-    LOGGER.warning("Deprecated %s" % func)
-    return lambda *args, **kwargs: func(*args, **kwargs)
+from ovirt.node import base
 
 
 # http://stackoverflow.com/questions/739654/understanding-python-decorators
-class Element(object):
+class Element(base.Base):
     """An abstract UI Element.
     This basically provides signals to communicate between real UI widget and
     the plugins
@@ -43,7 +37,8 @@
         """Registers all widget signals.
         All signals must be given in self.signals
         """
-        LOGGER.debug("Initializing new %s" % self)
+        super(Element, self).__init__()
+        self.logger.debug("Initializing new %s" % self)
 
     @staticmethod
     def signal_change(func):
@@ -66,7 +61,7 @@
             self._signal_cbs = {}
         if name not in self._signal_cbs:
             self._signal_cbs[name] = []
-            LOGGER.debug("Registered new signal '%s' for '%s'" % (name, self))
+            self.logger.debug("Registered new signal '%s' for '%s'" % (name, self))
 
     def connect_signal(self, name, cb):
         """Connect an callback to a signal
@@ -82,9 +77,9 @@
         """
         if self._signal_cbs is None or name not in self._signal_cbs:
             return False
-        LOGGER.debug("Emitting '%s'" % name)
+        self.logger.debug("Emitting '%s'" % name)
         for cb in self._signal_cbs[name]:
-            LOGGER.debug("... %s" % cb)
+            self.logger.debug("... %s" % cb)
             cb(self, userdata)
 
     def set_text(self, value):
@@ -98,9 +93,9 @@
     """
 
     def __init__(self, name, is_enabled):
+        super(InputElement, self).__init__()
         self.name = name
         self.enabled(is_enabled)
-        super(InputElement, self).__init__()
 
     @Element.signal_change
     def enabled(self, is_enabled=None):
@@ -124,8 +119,8 @@
     children = []
 
     def __init__(self, children):
-        self.children = children
         super(ContainerElement, self).__init__()
+        self.children = children
 
     def children(self, v=None):
         if v:
@@ -144,9 +139,9 @@
     """
 
     def __init__(self, title, children):
+        super(Dialog, self).__init__(children)
         self.title = title
         self.close(False)
-        super(Dialog, self).__init__(children)
 
     @Element.signal_change
     def close(self, v=True):
@@ -164,8 +159,8 @@
     """
 
     def __init__(self, text):
-        self.text(text)
         super(Label, self).__init__()
+        self.text(text)
 
     @Element.signal_change
     def text(self, text=None):
@@ -187,9 +182,8 @@
     """
 
     def __init__(self, keyword, text=""):
-        super(Label, self).__init__()
+        super(KeywordLabel, self).__init__(text)
         self.keyword = keyword
-        self.text(text)
 
 
 class Entry(InputElement):
@@ -198,9 +192,9 @@
     """
 
     def __init__(self, label, enabled=True, align_vertical=False):
+        super(Entry, self).__init__(label, enabled)
         self.label = label
         self.align_vertical = align_vertical
-        super(Entry, self).__init__(label, enabled)
 
 
 class PasswordEntry(Entry):
@@ -229,6 +223,7 @@
 
 class Divider(Element):
     def __init__(self, char=u" "):
+        super(Divider, self).__init__()
         self.char = char
 
 
@@ -240,10 +235,10 @@
         options:
     """
     def __init__(self, label, options):
+        super(Options, self).__init__()
         self.label = label
         self.options = options
         self.option(options[0])
-        super(Options, self).__init__()
 
     @Element.signal_change
     def option(self, option=None):
@@ -263,6 +258,7 @@
         state: The initial change
     """
     def __init__(self, label, state=False):
+        super(Checkbox, self).__init__()
         self.label = label
         self.state(state)
 
@@ -281,9 +277,9 @@
         done: The maximum value
     """
     def __init__(self, current=0, done=100):
+        super(ProgressBar, self).__init__()
         self.current(current)
         self.done = done
-        super(ProgressBar, self).__init__()
 
     @Element.signal_change
     def current(self, current=None):
@@ -310,11 +306,11 @@
     """
 
     def __init__(self, label, header, items, height=5, enabled=True):
+        super(Table, self).__init__(label, enabled)
         self.label = label
         self.header = header
         self.items = items
         self.height = height
-        super(Table, self).__init__(label, enabled)
 
     @Element.signal_change
     def select(self, selected=None):
@@ -328,7 +324,8 @@
     """
 
     def __init__(self, app):
-        LOGGER.info("Creating UI for application '%s'" % app)
+        super(Window, self).__init__()
+        self.logger.info("Creating UI for application '%s'" % app)
         self.app = app
 
         self._plugins = {}
@@ -346,8 +343,8 @@
         """
         if type(hotkey) is str:
             hotkey = [hotkey]
-        LOGGER.debug("Registering hotkey '%s': %s" % (hotkey, cb))
+        self.logger.debug("Registering hotkey '%s': %s" % (hotkey, cb))
         self._hotkeys[str(hotkey)] = cb
 
     def run(self):
-        raise NotImplementedError
+        raise NotImplementedError
\ No newline at end of file
diff --git a/scripts/tui/src/ovirt/node/ui/tui.py b/scripts/tui/src/ovirt/node/ui/tui.py
index f763b68..043233b 100644
--- a/scripts/tui/src/ovirt/node/ui/tui.py
+++ b/scripts/tui/src/ovirt/node/ui/tui.py
@@ -90,9 +90,8 @@
                ]
 
     def __init__(self, app):
-        LOGGER.info("Creating urwid tui for '%s'" % app)
-        self.app = app
         super(UrwidTUI, self).__init__(app)
+        self.logger.info("Creating urwid tui for '%s'" % app)
 
     def __build_menu(self):
         self.__menu = ovirt.node.ui.widgets.PluginMenu(self._plugins)
diff --git a/scripts/tui/src/ovirt/node/utils/__init__.py b/scripts/tui/src/ovirt/node/utils/__init__.py
index 1ddcd7e..aa556cf 100644
--- a/scripts/tui/src/ovirt/node/utils/__init__.py
+++ b/scripts/tui/src/ovirt/node/utils/__init__.py
@@ -26,17 +26,17 @@
 And use the model.py module for oVirt Node's defaults file.
 """
 
-import logging
 import hashlib
 import augeas as _augeas
 
-LOGGER = logging.getLogger(__name__)
+from ovirt.node import base
 
 
-class AugeasWrapper(object):
+class AugeasWrapper(base.Base):
     _aug = _augeas.Augeas()
 
     def __init__(self):
+        super(AugeasWrapper, self).__init__()
 #        self._aug = _augeas.Augeas() # Is broken
         self._aug.set("/augeas/save/copy_if_rename_fails", "")
 
diff --git a/scripts/tui/src/ovirt/node/utils/security.py b/scripts/tui/src/ovirt/node/utils/security.py
index 6cd0c45..a368b16 100644
--- a/scripts/tui/src/ovirt/node/utils/security.py
+++ b/scripts/tui/src/ovirt/node/utils/security.py
@@ -23,11 +23,8 @@
 """
 
 import os.path
-import logging
 
-import ovirt.node.utils.process as process
-
-LOGGER = logging.getLogger(__name__)
+from . import process
 
 
 def get_ssh_hostkey(variant="rsa"):
@@ -35,7 +32,6 @@
     if not os.path.exists(fn_hostkey):
         raise Exception("SSH hostkey does not yet exist.")
 
-    hostkey = None
     with open(fn_hostkey) as hkf:
         hostkey = hkf.read()
 
diff --git a/scripts/tui/src/ovirt/node/utils/virt.py b/scripts/tui/src/ovirt/node/utils/virt.py
index e99a527..81915ed 100644
--- a/scripts/tui/src/ovirt/node/utils/virt.py
+++ b/scripts/tui/src/ovirt/node/utils/virt.py
@@ -23,10 +23,9 @@
 """
 
 import os.path
-import logging
 import libvirt
 
-LOGGER = logging.getLogger(__name__)
+from ovirt.node import base
 
 
 def virtualization_hardware_is_available():
@@ -81,8 +80,9 @@
     return "No virtualization hardware was detected on this system"
 
 
-class LibvirtConnection(object):
+class LibvirtConnection(base.Base):
     def __init__(self, readonly=True):
+        super(LibvirtConnection, self).__init__()
         if readonly:
             self.con = libvirt.openReadOnly(None)
         else:
diff --git a/scripts/tui/src/ovirt/node/valid.py b/scripts/tui/src/ovirt/node/valid.py
index 2706cce..5c21dd0 100644
--- a/scripts/tui/src/ovirt/node/valid.py
+++ b/scripts/tui/src/ovirt/node/valid.py
@@ -22,18 +22,13 @@
 A module with several validators for common user inputs.
 """
 import re
-import logging
 import socket
 
-import ovirt.node.plugins
-import ovirt.node.exceptions
+from . import base
+from . import exceptions
 
 
-logging.basicConfig(level=logging.DEBUG)
-LOGGER = logging.getLogger(__name__)
-
-
-class Validator(object):
+class Validator(base.Base):
     """This class is used to validate user inputs
     Basically an exception is raised if an invalid value was given. The value
     is validated using the self.validate(value) method raises an exception.
@@ -67,7 +62,7 @@
 
     def raise_exception(self):
         msg = self.__exception_msg.format(description=self.description)
-        raise ovirt.node.exceptions.InvalidData(msg)
+        raise exceptions.InvalidData(msg)
 
     def __or__(self, other):
         """This allows to combin validators using |


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

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