def main(): api = API('https://192.168.11.100/', 'root', 'test') print api vm_template = api.get_instant_vm_template_by_name('ubuntu10.04-server') print vm_template new_vm = vm_template.clone('sandbox') print new_vm new_vm.provision() print new_vm.ref print 'start...' new_vm.start() time.sleep(10) print 'suspend...' new_vm.suspend() time.sleep(10) print 'resume...' new_vm.resume() time.sleep(10) print 'reboot...' new_vm.reboot() time.sleep(20) print 'shutdown...' new_vm.shutdown()
""" >python sample.py <xswizard.api.API: url=http://192.168.11.100/, username=root> [<VM: debian01-sandbox>, <VM: debian04-php>, <VM: debian02-py>, <VM: ubuntu03-py>, <VM: Control domain on host: xenserver01>] <VM: test_snapshot_1299773422> """ import time from xswizard.api import API URL = 'https://192.168.11.100/' USERNAME = '******' PASSWORD = '' api = API(URL, USERNAME, PASSWORD) print api vms = api.get_hosts()[0].residentVMs print vms vm = vms[1].snapshot('test_snapshot_%s' % int(time.time())) print vm #vm.export_as_file('test.xva')