I am trying to create snapshots in python through vboxapi, but since I never used vboxapi before, I feel a bit lost when I dive in documentation and examples from python, java and C# to know the right steps to accomplish this.
So I came to this script where I am getting,
Code: Select all
NameError: name 'LockType' is not defined
Where I am calling LockType in a possible wrong way or due to missing library importation, but I really dont know how to set it.
Here is my actual script:
Code: Select all
import datetime
import vboxapi
def virtual_machines_master():
inicial_date = datetime.datetime.now()
virtualboxmanager = vboxapi.VirtualBoxManager(None, None)
vbox = virtualboxmanager.getVirtualBox()
usb_server_1=vbox.findMachine("usb-server-1")
session = virtualboxmanager.getSessionObject(vbox)
usb_server_1.lockMachine(session,LockType.LockType_Shared)
session.console.takeSnapshot('Snapshot '+inicial_date.strftime("%y%m%d"), 'Snapshot taken through vboxapi')
session.unlockMachine()
if __name__=="__main__":
virtual_machines_master()
- Python 3.6.5
- VirtuaBox 5.2.16
- Windows 10