Permalink
Browse files

one more esthetic - start raises, so let stop raise as well

  • Loading branch information...
1 parent 4f717a5 commit dd154e3bf3df719811f1f75a7bc044a0bba688ca @rep rep committed Oct 9, 2012
Showing with 22 additions and 22 deletions.
  1. +22 −22 modules/machinemanagers/virtualbox.py
View
44 modules/machinemanagers/virtualbox.py
@@ -79,28 +79,28 @@ def stop(self, label):
log.debug("Stopping vm %s" % label)
if self._status(label) in [self.POWEROFF, self.ABORTED]:
- log.debug("Trying to stop an already stopped vm %s" % label)
- else:
- try:
- proc = subprocess.Popen([self.options.virtualbox.path, "controlvm", label, "poweroff"],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- # Sometimes VBoxManage stucks when stopping vm so we needed
- # to add a timeout and kill it after that.
- stop_me = 0
- while proc.poll() is None:
- if stop_me < self.options.virtualbox.timeout:
- time.sleep(1)
- stop_me += 1
- else:
- log.debug("Stopping vm %s timeouted. Killing" % label)
- proc.terminate()
-
- if proc.returncode != 0 and stop_me < self.options.virtualbox.timeout:
- log.debug("VBoxManage exited with error powering off the machine")
- except OSError as e:
- raise CuckooMachineError("VBoxManage failed powering off the machine: %s" % e)
- self._wait_status(label, [self.POWEROFF, self.ABORTED])
+ raise CuckooMachineError("Trying to stop an already stopped vm %s" % label)
+
+ try:
+ proc = subprocess.Popen([self.options.virtualbox.path, "controlvm", label, "poweroff"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ # Sometimes VBoxManage stucks when stopping vm so we needed
+ # to add a timeout and kill it after that.
+ stop_me = 0
+ while proc.poll() is None:
+ if stop_me < self.options.virtualbox.timeout:
+ time.sleep(1)
+ stop_me += 1
+ else:
+ log.debug("Stopping vm %s timeouted. Killing" % label)
+ proc.terminate()
+
+ if proc.returncode != 0 and stop_me < self.options.virtualbox.timeout:
+ log.debug("VBoxManage exited with error powering off the machine")
+ except OSError as e:
+ raise CuckooMachineError("VBoxManage failed powering off the machine: %s" % e)
+ self._wait_status(label, [self.POWEROFF, self.ABORTED])
def _list(self):
"""Lists virtual machines installed.

0 comments on commit dd154e3

Please sign in to comment.