[PATCH atomic-rhel-7.1] rescue: find root partition of ostree (atomic) installations (#1152041)

Radek Vykydal rvykydal at redhat.com
Mon Jan 19 13:19:42 UTC 2015


This patch is targeted for RHEL Atomic Host 7.1 which is using 7.0 anaconda
plus patches in atomic-rhel-7.1 dist-git branch. So the patch should go to
rhel7-branch in 7.2 dev.

---
 pyanaconda/rescue.py | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index e0c4e13..fbf3f06 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -264,6 +264,42 @@ def _unlock_devices(intf, storage):
                         device.format.passphrase = None
                         try_passphrase = None
 
+def findExistingOstreePartitions(devicetree):
+    import blivet
+    if not os.path.exists(blivet.getTargetPhysicalRoot()):
+        util.makedirs(blivet.getTargetPhysicalRoot())
+
+    roots = []
+    for device in devicetree.leaves:
+        if not device.format.linuxNative or not device.format.mountable or \
+           not device.controllable:
+            continue
+
+        try:
+            device.setup()
+        except Exception: # pylint: disable=broad-except
+            log.warning("setup of %s failed", [device.name])
+            continue
+
+        options = device.format.options + ",ro"
+        try:
+            device.format.mount(options=options, mountpoint=iutil.getSysroot())
+        except Exception: # pylint: disable=broad-except
+            log.warning("mount of %s as %s failed", device.name, device.format.type)
+            device.teardown()
+            continue
+
+        if not os.access(iutil.getSysroot() + "/ostree", os.R_OK):
+            device.teardown(recursive=True)
+            continue
+
+        name = _("Ostree on %s") % device.name
+        roots.append(blivet.Root(mounts=None, swaps=None, name=device.name))
+
+    return roots
+
+
+
 def doRescue(intf, rescue_mount, ksdata):
     import blivet
 
@@ -323,6 +359,7 @@ def doRescue(intf, rescue_mount, ksdata):
     blivet.storageInitialize(sto, ksdata, [])
     _unlock_devices(intf, sto)
     roots = blivet.findExistingInstallations(sto.devicetree)
+    roots.extend(findExistingOstreePartitions(sto.devicetree))
 
     if not roots:
         root = None
-- 
1.9.3



More information about the anaconda-patches mailing list