summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.server.scripts
diff options
context:
space:
mode:
authorTim <timothyasir@gluster.com>2011-07-15 16:47:53 +0530
committerTim <timothyasir@gluster.com>2011-07-15 16:47:53 +0530
commit5c791f92f77aa65fd0c744b5660336ef300248b2 (patch)
tree7eae3f9c5067da141db0154bf7ac4ccc580e10f0 /src/com.gluster.storage.management.server.scripts
parent44b51de1a42fbec404c6a613cb3bfea1ce13da0c (diff)
Removed subprocess.popen and used fork method to execute background tasks.
Diffstat (limited to 'src/com.gluster.storage.management.server.scripts')
-rwxr-xr-xsrc/com.gluster.storage.management.server.scripts/src/format_device.py16
-rwxr-xr-xsrc/com.gluster.storage.management.server.scripts/src/get_format_device_status.py2
2 files changed, 12 insertions, 6 deletions
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")