[node-patches] Change in ovirt-node[master]: fix online upgrades to check grub config for backup entry

jboggs at redhat.com jboggs at redhat.com
Thu Nov 15 15:06:52 UTC 2012


Joey Boggs has uploaded a new change for review.

Change subject: fix online upgrades to check grub config for backup entry
......................................................................

fix online upgrades to check grub config for backup entry

rhbz#863982

Change-Id: I55e0593d34186a18caf31e5f9806587c461c4f62
Signed-off-by: Joey Boggs <jboggs at redhat.com>
---
M scripts/ovirtnode/install.py
M scripts/ovirtnode/ovirtfunctions.py
2 files changed, 30 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/69/9269/1

diff --git a/scripts/ovirtnode/install.py b/scripts/ovirtnode/install.py
index 15cec4d..9056ebc 100755
--- a/scripts/ovirtnode/install.py
+++ b/scripts/ovirtnode/install.py
@@ -252,19 +252,26 @@
                 logger.info("Root Installation Not Required, Finished.")
                 return True
 
-        self.oldtitle = None
-        _functions.system("mount -r LABEL=Root /liveos")
+        self.oldtitle=None
+        grub_config_file = None
         if os.path.ismount("/liveos"):
-            if (os.path.exists("/liveos/vmlinuz0") and
-                os.path.exists("/liveos/initrd0.img")):
-                f = open(self.grub_config_file)
-                oldgrub = f.read()
-                f.close()
-                m = re.search("^title (.*)$", oldgrub, re.MULTILINE)
-                if m is not None:
-                    self.oldtitle = m.group(1)
+            if os.path.exists("/liveos/vmlinuz0") and os.path.exists("/liveos/initrd0.img"):
+                grub_config_file = self.grub_config_file
 
-            _functions.system("umount /liveos")
+        elif not is_firstboot():
+            if os.path.ismount("/dev/.initramfs/live"):
+                grub_config_file = "/dev/.initramfs/live/grub/grub.conf"
+            elif os.path.ismount("/run/initramfs/live"):
+                grub_config_file = "/run/initramfs/live/grub/grub.conf"
+
+        if not grub_config_file is None:
+            f=open(grub_config_file)
+            oldgrub=f.read()
+            f.close()
+            m=re.search("^title (.*)$", oldgrub, re.MULTILINE)
+            if m is not None:
+                self.oldtitle=m.group(1)
+        _functions.system("umount /liveos")
 
         if _functions.findfs("BootBackup"):
             self.boot_candidate = "BootBackup"
@@ -452,6 +459,16 @@
         "grub_prefix": self.grub_prefix,
         "efi_hd": self.efi_hd
     }
+        if not is_firstboot():
+            if os.path.ismount("/live"):
+                with open("/live/isolinux/version") as version:
+                    for line in version.readlines():
+                        if "VERSION" in line:
+                            key, value = line.split("=")
+                            self.grub_dict["version"] = value.strip()
+                        if "RELEASE" in line:
+                            key, value = line.split("=")
+                            self.grub_dict["release"] = value.strip()
 
         if os.path.exists("/sbin/grub2-install"):
             if not _functions.is_efi_boot():
diff --git a/scripts/ovirtnode/ovirtfunctions.py b/scripts/ovirtnode/ovirtfunctions.py
index d540885..09746a6 100644
--- a/scripts/ovirtnode/ovirtfunctions.py
+++ b/scripts/ovirtnode/ovirtfunctions.py
@@ -463,7 +463,8 @@
         live_dev="/dev/live"
 
     system_closefds("mkdir -p /live")
-    if not system_closefds("mount -r " + live_dev + " /live &>/dev/null"):
+    system_closefds("mount -r " + live_dev + " /live &>/dev/null")
+    if not os.path.ismount("/live"):
         # check if live device was setup under alternate locations
         if os.path.ismount("/dev/.initramfs/live"):
             system_closefds("mount -o bind /dev/.initramfs/live /live")


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55e0593d34186a18caf31e5f9806587c461c4f62
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>



More information about the node-patches mailing list