コード例 #1
0
ファイル: VirtualMachine.py プロジェクト: szydre/pyVBox
    def delete(self):
        """Delete the VM.

        VM must be locked or unregistered"""
        with VirtualBoxException.ExceptionHandler():
            iMachine = self.getIMachine()
            iprogress = iMachine.delete(None)
            progress = Progress(iprogress)
            progress.waitForCompletion()
コード例 #2
0
    def createBaseStorage(self, size, variant=None, wait=True):
        """Create storage for the drive of the given size (in MB).

        Returns Progress instance. If wait is True, does not return until process completes."""
        if variant is None:
            variant = Constants.MediumVariant_Standard
        with VirtualBoxException.ExceptionHandler():
            progress = self.getIMedium().createBaseStorage(size, variant)
        progress = Progress(progress)
        if wait:
            progress.waitForCompletion()
        return progress
コード例 #3
0
ファイル: VirtualMachine.py プロジェクト: szydre/pyVBox
    def deleteSnapshot(self, snapshot, wait=True):
        """Deletes the specified snapshot.

        Returns Progress instance. If wait is True, does not return until process completes."""
        assert(snapshot is not None)
        with self.lock() as session:
            with VirtualBoxException.ExceptionHandler():
                iprogress = session.console.deleteSnapshot(snapshot.id)
                progress = Progress(iprogress)
        # XXX Not sure if we need a lock for this or not
        if wait:
            progress.waitForCompletion()
        return progress
コード例 #4
0
ファイル: VirtualMachine.py プロジェクト: szydre/pyVBox
    def takeSnapshot(self, name, description=None, wait=True):
        """Saves the current execution state and all settings of the machine and creates differencing images for all normal (non-independent) media.

        Returns Progress instance. If wait is True, does not return until process completes."""
        assert(name is not None)
        with self.lock() as session:
            with VirtualBoxException.ExceptionHandler():
                iprogress = session.console.takeSnapshot(name, description)
                progress = Progress(iprogress)
        # XXX Not sure if we need a lock for this or not
        if wait:
            progress.waitForCompletion()
        return progress
コード例 #5
0
 def cloneTo(self, target, variant=None, parent=None, wait=True):
     """Clone to the target hard drive.
     
     Returns Progress instance. If wait is True, does not return until process completes."""
     if variant is None:
         variant = Constants.MediumVariant_Standard
     with VirtualBoxException.ExceptionHandler():
         progress = self.getIMedium().cloneTo(target.getIMedium(),
                                              variant,
                                              parent)
     progress = Progress(progress)
     if wait:
         progress.waitForCompletion()
     return progress
コード例 #6
0
ファイル: VirtualMachine.py プロジェクト: szydre/pyVBox
    def powerOn(self, type="gui", env=""):
        """Spawns a new process that executes a virtual machine.

        This is spawning a "remote session" in VirtualBox terms."""
        # TODO: Add a wait argument
        if not self.isRegistered():
            raise VirtualBoxException.VirtualBoxInvalidVMStateException(
                "VM is not registered")
        with VirtualBoxException.ExceptionHandler():
            iMachine = self.getIMachine()
            session = Session.create()
            iprogress = iMachine.launchVMProcess(session.getISession(),
                                                 type, env)
            progress = Progress(iprogress)
            progress.waitForCompletion()
            session.unlockMachine()