[node-patches] Change in ovirt-node[master]: Split find_grub_cfg EFI changes from iSCSI

rbarry at redhat.com rbarry at redhat.com
Wed Dec 10 16:37:21 UTC 2014


Hello hadong,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/36077

to review the following change.

Change subject: Split find_grub_cfg EFI changes from iSCSI
......................................................................

Split find_grub_cfg EFI changes from iSCSI

Break the patch in half so we can commit EFI only for now.

Change-Id: I797083ed8dfa7343206ae726913ad2f364620879
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1046887
Signed-off-by: hadong <hadong at redhat.com>
---
M src/ovirt/node/utils/system.py
1 file changed, 18 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/77/36077/1

diff --git a/src/ovirt/node/utils/system.py b/src/ovirt/node/utils/system.py
index 3a6f2bf..447f623 100644
--- a/src/ovirt/node/utils/system.py
+++ b/src/ovirt/node/utils/system.py
@@ -979,27 +979,29 @@
 
     @staticmethod
     def find_grub_cfg():
-        cfg_path = None
-
-        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"
+        cfg = None
+        if Filesystem.by_label("Boot"):
+            cfg_path = "/boot/grub/"
+        elif is_efi():
+            mount_efi(target="/liveos")
+            cfg_path = "/liveos/EFI"
+        elif os.path.ismount("/dev/.initramfs/live"):
+            cfg_path = "/dev/.initramfs/live"
         elif os.path.ismount("/run/initramfs/.live"):
-            cfg_path = "/liveos/grub/grub.conf"
-        elif Filesystem.by_label("Boot"):
-            cfg_path = "/boot/grub/grub.conf"
+            cfg_path = "/liveos"
 
-        else:
+        for dirName, subdirList, fileList in os.walk(cfg_path):
+            for f in fileList:
+                if f.endswith(".conf") or f.endswith(".cfg"):
+                    cfg = "%s/%s" % (dirName, f)
+                    LOGGER.debug("The path for grub is: %s" % cfg)
+
+        if not cfg:
             raise RuntimeError("Failed to find the path for grub.[cfg|conf]")
 
-        cfg = File(cfg_path)
-
-        if not cfg.exists():
+        if not File(cfg).exists():
             raise RuntimeError("Grub config file does not exist: %s" % cfg)
-
-        return cfg
+        return File(cfg)
 
     class Arguments(base.Base):
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I797083ed8dfa7343206ae726913ad2f364620879
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
Gerrit-Reviewer: hadong <hadong0720 at gmail.com>



More information about the node-patches mailing list