From 5c791f92f77aa65fd0c744b5660336ef300248b2 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 15 Jul 2011 16:47:53 +0530 Subject: Removed subprocess.popen and used fork method to execute background tasks. --- .../src/format_device.py | 16 ++++++++++------ .../src/get_format_device_status.py | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/com.gluster.storage.management.server.scripts') diff --git a/src/com.gluster.storage.management.server.scripts/src/format_device.py b/src/com.gluster.storage.management.server.scripts/src/format_device.py index 80334d8a..061236e0 100755 --- a/src/com.gluster.storage.management.server.scripts/src/format_device.py +++ b/src/com.gluster.storage.management.server.scripts/src/format_device.py @@ -64,14 +64,18 @@ def main(): sys.exit(2) if options.fstype: - process = Utils.runCommandBG("gluster_provision_block_wrapper.py -t %s %s" % (options.fstype, device), root=True) + command = ["gluster_provision_block_wrapper.py", "-t", "%s" % (options.fstype), "%s" % (device)] else: - process = Utils.runCommandBG("gluster_provision_block_wrapper.py %s" % device, root=True) - if process: - sys.exit(0) + command = ["gluster_provision_block_wrapper.py", "%s" % (device)] - sys.stderr.write("Device format failed\n") - sys.exit(3) + try: + pid = os.fork() + except OSError, e: + Utils.log("failed to fork a child process: %s" % str(e)) + sys.exit(1) + if pid == 0: + os.execv("/usr/sbin/gluster_provision_block_wrapper.py", command) + sys.exit(0) if __name__ == "__main__": diff --git a/src/com.gluster.storage.management.server.scripts/src/get_format_device_status.py b/src/com.gluster.storage.management.server.scripts/src/get_format_device_status.py index a24cb77a..57fc0455 100755 --- a/src/com.gluster.storage.management.server.scripts/src/get_format_device_status.py +++ b/src/com.gluster.storage.management.server.scripts/src/get_format_device_status.py @@ -18,6 +18,7 @@ import os import sys +import time import Utils import DiskUtils from XmlHandler import ResponseXml @@ -33,6 +34,7 @@ def main(): deviceFormatStatusFile = Utils.getDeviceFormatStatusFile(device) deviceFormatOutputFile = Utils.getDeviceFormatOutputFile(device) + time.sleep(1) if not os.path.exists(deviceFormatLockFile): if not os.path.exists(deviceFormatStatusFile): sys.stderr.write("Device format not initiated\n") -- cgit