내가 VM이 실행중인 경우, 특정 스냅 샷으로 VM을 복원하고 시작 찾기 위해 다음과 같은 기능을 사용할 수 있다는 것을 발견
VM 이름.
from subprocess import Popen, PIPE
def running_vms():
"""
Return list of running vms
"""
f = Popen(r'vboxmanage --nologo list runningvms', stdout=PIPE).stdout
data = [ eachLine.strip() for eachLine in f ]
return data
def restore_vm(name='', snapshot=''):
"""
Restore VM to specific snapshot uuid
name = VM Name
snapshot = uuid of snapshot (uuid can be found in the xml file of your machines folder)
"""
command = r'vboxmanage --nologo snapshot %s restore %s' % (name,snapshot)
f = Popen(command, stdout=PIPE).stdout
data = [ eachLine.strip() for eachLine in f ]
return data
def launch_vm(name=''):
"""
Launch VM
name = VM Name
"""
command = r'vboxmanage --nologo startvm %s ' % name
f = Popen(command, stdout=PIPE).stdout
data = [ eachLine.strip() for eachLine in f ]
return data
우리는 그것을 시도했지만 같은 몇 가지 오류를 가지고 : 역 추적 (마지막으로 가장 최근 통화) : 파일 "", 1 호선, 파일 "/usr/lib/python2.5/site cmdbox '/ 패키지/pyvb-0.0.2-py2.5.egg/pyvb/vb.py ", 줄 65, startVM에 cmd ='% s % s '% (VB_COMMAND_STARTVM, vm.getUUID()) AttributeError :' NoneType '객체에'getUUID '속성이 없습니다. 도와주세요. –
ask
ur 빠른 응답을 주셔서 감사합니다 하지만 실제로 필요한 것은 python virtualbox API를 사용하여 해당 명령을 실행하는 것입니다. – ask
@ask : 죄송합니다. VirtualBox가 명령 줄 도구에서 GUID 대신 이름을 사용하도록 지원했기 때문에 python 라이브러리도 사용할 수 있지만'getVM' 메서드는 GUID가 필요하다고 말합니다. 블레치. 그것에 대한 대답을 업데이트하고'listVMS' 메소드에주의를 환기시킵니다. –