From 71c27f667a64cfff61036d23a651bdf25dd87539 Mon Sep 17 00:00:00 2001 From: yves Date: Wed, 14 Dec 2011 00:15:59 +0100 Subject: rearragend executor api --- createAndExportDisk.py | 21 +++++++++++---------- 1 file 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] ] -- cgit v1.2.3-1-g7c22