summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryves <steve.harrison@gmx.net>2011-12-14 00:15:59 +0100
committeryves <steve.harrison@gmx.net>2011-12-14 00:15:59 +0100
commit71c27f667a64cfff61036d23a651bdf25dd87539 (patch)
tree2987eb8387ad909f05b3dff0f6eacbd1a10e6075
parentaeb4f9729b8936405a5435119b9a5a13f5a03922 (diff)
downloadiscsi-helper-71c27f667a64cfff61036d23a651bdf25dd87539.tar.gz
iscsi-helper-71c27f667a64cfff61036d23a651bdf25dd87539.tar.bz2
iscsi-helper-71c27f667a64cfff61036d23a651bdf25dd87539.zip
rearragend executor api
-rwxr-xr-xcreateAndExportDisk.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/createAndExportDisk.py b/createAndExportDisk.py
index ffa71ca..01ba10b 100755
--- a/createAndExportDisk.py
+++ b/createAndExportDisk.py
@@ -11,18 +11,19 @@ class ExecutionPlan:
self.commands = commands
self.executed = []
self.logFile = open("/tmp/log","w")
- self.todo = len(self.commands)
def execute_all(self):
- for i in range(len(self.executed),self.todo):
- print("[" + str(i+1) + "/" + str(self.todo) + "]: excuting ",end="")
- self.execute_next()
- print("\r[" + str(i+1) + "/" + str(self.todo) + "]: excuted ")
-
- def execute_next(self):
- cmd = self.commands.pop(0)
+ for i in range(len(self.executed),len(self.commands)):
+ total = len(self.commands)
+ print("[" + str(i+1) + "/" + str(total) + "]: excuting "
+ + self.commands[i][0],end="")
+ self.execute(self.commands[i])
+ print("\r[" + str(i+1) + "/" + str(total) + "]: excuted "
+ + self.commands[i][0] + " ")
+
+ def execute(self, cmd):
# safty anker subprocess.call(cmd)
- subprocess.call(['echo','>>>'] + cmd,stdout=self.logFile)
+ subprocess.call(['echo','#>>>'] + cmd,stdout=self.logFile)
subprocess.call(['echo'] + cmd,stdout=self.logFile,stderr=self.logFile)
self.executed.append(cmd)
@@ -105,7 +106,7 @@ diskSize, diskSizeUnit = parseDiskSize(options.size)
cmds = [
["lvcreate", "-n", vmName, "-L", str(diskSize) + str(diskSizeUnit)],
- ["mkfs", "/dev/" + volumeGroupName + "/" + vmName, "-l",vmName],
+ ["mkfs.ext4", "/dev/" + volumeGroupName + "/" + vmName, "-l",vmName],
["addIscsiDisk", vmName]
]