summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShireesh Anjal <anjalshireesh@gmail.com>2011-07-15 04:38:34 -0700
committerShireesh Anjal <anjalshireesh@gmail.com>2011-07-15 04:38:34 -0700
commit665b45744d06bd9c0a53263ec87630cdc2734c90 (patch)
treea72e5efd546db603e893aff10da7cc5412cd95bd /src
parent691f4b7519a7758de9316766d9963d68cdd50924 (diff)
parente95fd9dc82ec09878464ac8629d5c1c88c3c76cf (diff)
Merge pull request #116 from TimothyAsir/master
Updated format_device.py to use fork method to execute background tasks
Diffstat (limited to 'src')
-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")