[node-patches] Change in ovirt-node[master]: ui: Improve the setting of the console path

fabiand at fedoraproject.org fabiand at fedoraproject.org
Fri Jun 27 08:47:43 UTC 2014


Fabian Deutsch has uploaded a new change for review.

Change subject: ui: Improve the setting of the console path
......................................................................

ui: Improve the setting of the console path

Previously the exampel did not match what was required to be put into
the field (previously only the device [ttyS0] was required, but the
example stated a full path [/dev/ttyS0]).
This is now corrected, furthermore was the detection of the correct grub
cfg file reordered to be quicker in many cases (the discovery by fs
label was pulled to the end).

Change-Id: I8f88e8c0f5a73400728440339dd6619982c5aea8
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/setup/core/status_page.py
M src/ovirt/node/utils/system.py
2 files changed, 25 insertions(+), 11 deletions(-)


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

diff --git a/src/ovirt/node/setup/core/status_page.py b/src/ovirt/node/setup/core/status_page.py
index 12425c4..5b07dac 100644
--- a/src/ovirt/node/setup/core/status_page.py
+++ b/src/ovirt/node/setup/core/status_page.py
@@ -141,7 +141,7 @@
     def on_change(self, changes):
         if "console.path" in changes:
             if "console.path" is not "" and not os.path.exists(
-                    "/dev/%s" % changes["console.path"].split(',')[0]):
+                    changes["console.path"].split(',')[0]):
                 raise exceptions.InvalidData("Console path must be a valid"
                                              "device or empty")
 
@@ -277,14 +277,16 @@
         self.children = [ui.Label("console.label[0]",
                                   "Enter the path to a valid console device"),
                          ui.Label("console.label[1]",
-                                  "Example: /dev/ttyS0,115200n8"),
+                                  "Examples: /dev/ttyS1 or " +
+                                  "/dev/ttyS0,115200n8"),
+                         ui.Divider("console.divider[0]"),
                          ui.Entry("console.path", "Console path:")]
 
     def _console(self, console_path=None):
         def real_console():
             b = Bootloader().Arguments()
             if not console_path:
-                return b["console"] if "console" in b else ""
+                return b.get("console",  "")
             else:
                 b["console"] = str(console_path)
         return self.plugin.dry_or(real_console) or ""
diff --git a/src/ovirt/node/utils/system.py b/src/ovirt/node/utils/system.py
index 4c44680..ef2d75b 100644
--- a/src/ovirt/node/utils/system.py
+++ b/src/ovirt/node/utils/system.py
@@ -807,13 +807,19 @@
 
     @staticmethod
     def find_by_path(path):
+        """Find the mountpoint for a specific path recursively
+        """
         while not os.path.ismount(path):
             path = os.path.dirname(path)
         return Mount(path)
 
 
 class Bootloader(base.Base):
-    """Figures out where grub.conf can be found and which bootloader is used"""
+    """Figures out where grub.conf can be found and which bootloader is used
+
+    FIXME This really needs a doctest because it is messing with the boot
+    config
+    """
 
     @staticmethod
     def is_grub2():
@@ -824,19 +830,25 @@
     def find_grub_cfg():
         cfg_path = None
 
-        if Filesystem.by_label("Boot"):
-            cfg_path = "/boot/grub/grub.conf"
-        elif os.path.ismount("/dev/.initramfs/live"):
-            if not Bootloader.is_grub2():
-                cfg_path = "/dev/.initramfs/live/grub/grub.conf"
-            else:
+        if os.path.ismount("/dev/.initramfs/live"):
+            if Bootloader.is_grub2():
                 cfg_path = "/dev/.initramfs/live/grub2/grub.cfg"
+            else:
+                cfg_path = "/dev/.initramfs/live/grub/grub.conf"
         elif os.path.ismount("/run/initramfs/.live"):
             cfg_path = "/liveos/grub/grub.conf"
+        elif Filesystem.by_label("Boot"):
+            cfg_path = "/boot/grub/grub.conf"
 
         else:
             raise RuntimeError("Failed to find the path for grub.[cfg|conf]")
-        return File(cfg_path)
+
+        cfg = File(cfg_path)
+
+        if not cfg.exists():
+            raise RuntimeError("Grub config file does not exist: %s" % cfg)
+
+        return cfg
 
     class Arguments(base.Base):
 


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

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



More information about the node-patches mailing list