[node-patches] Change in ovirt-node[master]: Move the check for DEV_LIVE in ovirtfunctions to a function

rbarry at redhat.com rbarry at redhat.com
Fri Jul 5 15:55:39 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Move the check for DEV_LIVE in ovirtfunctions to a function
......................................................................

Move the check for DEV_LIVE in ovirtfunctions to a function

Instead of using DEV_LIVE as a global which depends on
ovirt-functions returning a non-zero exit status (and crashes the
storage page if it does not), move it to a function which can be
queried only if ovirtfunctions needs to know where the live disk
is.

Change-Id: Ia9d609c298f8093701ba19dc847b2ee0a2d00fae
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirtnode/ovirtfunctions.py
1 file changed, 11 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/20/16520/1

diff --git a/src/ovirtnode/ovirtfunctions.py b/src/ovirtnode/ovirtfunctions.py
index 1dffeda..33d64c8 100644
--- a/src/ovirtnode/ovirtfunctions.py
+++ b/src/ovirtnode/ovirtfunctions.py
@@ -63,10 +63,6 @@
 PRODUCT_VERSION = aug.get("/files/etc/default/version/VERSION")
 PRODUCT_RELEASE = aug.get("/files/etc/default/version/RELEASE")
 
-DEV_LIVE = "/dev/{live}".format(live=process.check_output(
-                                "/usr/libexec/ovirt-functions get_live_disk")
-                                .strip())
-
 OVIRT_VARS = {}
 # Parse all OVIRT_* variables
 
@@ -85,6 +81,9 @@
             pass
     f.close()
     return OVIRT_VARS
+
+def get_dev_live():
+    return "/dev/{live}".format(live=process.check_output("/usr/libexec/ovirt-functions get_live_disk").strip())
 
 
 # fallback when default is empty
@@ -439,16 +438,17 @@
 # not available when booted from local disk installation
 def mount_live():
     live_dev = ""
+    dev_live = get_dev_live()
     if os.path.ismount("/live"):
         if os.path.exists("/live/isolinux") or os.path.exists("/live/syslinux"):
             return True
-    if not os.path.exists(DEV_LIVE):
+    if not os.path.exists(dev_live):
         if system("losetup /dev/loop0|grep -q '\.iso'"):
             # PXE boot
             live_dev="/dev/loop0"
         else:
             try:
-                # DEV_LIVE if not exist alternative
+                # dev_live if not exist alternative
                 client = gudev.Client(['block'])
                 cmdline = open("/proc/cmdline")
                 cdlabel = re.search('CDLABEL\=([a-zA-Z0-9_\.-]+)', cmdline.read())
@@ -467,7 +467,7 @@
     elif os.path.exists("/data/updates/ovirt-node-image.iso"):
         live_dev = "-o loop /data/updates/ovirt-node-image.iso"
     else:
-        live_dev = DEV_LIVE
+        live_dev = dev_live
 
     system_closefds("mkdir -p /live")
     system_closefds("mount -r " + live_dev + " /live &>/dev/null")
@@ -1004,10 +1004,11 @@
 
 def get_live_disk():
     live_disk=""
-    if os.path.exists(DEV_LIVE):
-        live_disk = os.path.dirname(udev_info(DEV_LIVE,"path"))
+    dev_live = get_dev_live()
+    if os.path.exists(dev_live):
+        live_disk = os.path.dirname(udev_info(dev_live,"path"))
         if "block" in live_disk:
-            live_disk = os.path.basename(udev_info(DEV_LIVE,"path")).strip()
+            live_disk = os.path.basename(udev_info(dev_live,"path")).strip()
             # if dm-XX, not enough detail to map correctly
             if "dm-" in live_disk:
                 live_disk = findfs("LIVE")[:-2]


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

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



More information about the node-patches mailing list