| 85 | self._sshHostConfig = None |
| 86 | |
| 87 | def maybeUp(self): |
| 88 | if not self._controlVagrant: |
| 89 | return |
| 90 | state = self._vagrant.status(vm_name=self.host)[0].state |
| 91 | if state == Vagrant.NOT_CREATED: |
| 92 | self._vagrant.up(vm_name=self.host) |
| 93 | self._startedVagrant = True |
| 94 | elif state in [Vagrant.POWEROFF, Vagrant.SAVED, Vagrant.ABORTED]: |
| 95 | raise Exception( |
| 96 | "SystemVM testing does not support resume(), do not use vagrant suspend/halt") |
| 97 | elif state == Vagrant.RUNNING: |
| 98 | self._startedVagrant = False |
| 99 | else: |
| 100 | raise Exception("Unrecognized vagrant state %s" % state) |
| 101 | |
| 102 | def maybeDestroy(self): |
| 103 | if not self._controlVagrant or not self._startedVagrant: |