def nilfvm(machine, vms, steps, build, test_path, caller): tslib.forcepowerstate(machine, 'off', vms) r = run([ 'cd', '/storage/nilfvm', 'nilfvm-create', '--rootfs=nilfvm-rootfs.i686.cpio.bz2', '--size=256', '--config=service-nilfvm' ], host=machine) tslib.cmdResponse( r, 'nilfvm-create --rootfs=nilfvm-rootfs.i686.cpio.bz2 --size=256 --config=service-nilfvm' ) vm_uuid = run(['xec-vm', '-n', vms, 'get', 'uuid'], host=machine) vm_uuid = vm_uuid.rstrip('\n') tslib.cmdResponse(vm_uuid, 'xec-vm -n ' + vms + ' get uuid') r = run(['xec-vm', '-u', vm_uuid, 'set', 'track-dependencies', 'true'], host=machine) tslib.cmdResponse(r, 'xec-vm -u ' + vm_uuid + ' set track-dependencies true') nilfvm_uuid = run(['xec-vm', '-n', nilfvm01, 'get', 'uuid'], host=machine) r = run([ 'xec-vm', '-u', vm_uuid, '--nic', '0', 'set', 'backend-uuid', nilfvm_uuid ], host=machine) tslib.cmdResponse( r, 'xec-vm -u ' + vm_uuid + ' --nic 0 set backend-uuid ' + nilfvm_uuid)
def poweroffSVM(machine,vms,steps,build,test_path,caller): log(1,'Force Power Off SVM') tslib.hdx_switch(machine, 0, vms) tslib.forcepowerstate(machine, 'on', vms) windows_transitions.vm_poweroff(machine, vms) windows_transitions.vm_poweron(machine) log(2)
def disableSnapshot(machine, vms, steps, build, test_path, caller): dummy = str(random.randint(10000, 20000)) vm_address = str(domain_address(machine, vms)) r = run(['xec-vm', '-n', vms, '--disk', '1', 'get', 'snapshot'], host=machine) if 'temporary' in r: tslib.forcepowerstate(machine, 'off', vms) r = run( ['xec-vm', '-n', vms, '--disk', '1', 'set', 'snapshot', 'none'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' --disk 1 set snapshot none') snapshot = run(['xec-vm', '-n', vms, '--disk', '1', 'get', 'snapshot'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' --disk 1 get snapshot') if 'none' not in snapshot: tslib.pauseToDebug("xec failed to disable snapshot") windows_transitions.vm_poweron(machine, vms) for i in range(2): windows_transitions.vm_reboot_dom0(machine, vms) res = run_via_exec_daemon( ['mkdir', 'C:\\Users\\Administrator\\Desktop\\' + dummy], host=vm_address, wait=True) windows_transitions.vm_reboot_dom0(machine, vms) res = run_via_exec_daemon(['dir', 'C:\\Users\\Administrator\\Desktop\\'], host=vm_address, wait=True) if dummy not in res: tslib.pauseToDebug("Snapshot disabled: Old folders lost after reboot")
def sleepSVM(machine,vms,steps,build,test_path,caller): log(1,'SVM sleep') tslib.hdx_switch(machine, 0, vms) tslib.forcepowerstate(machine, 'on', vms) windows_transitions.vm_sleep_dom0(machine, vms) windows_transitions.vm_resume(machine, vms) windows_transitions.wait_for_vms(machine,vms) log(2)
def hibernateSVM(machine,vms,steps,build,test_path,caller): log(1,'Hibernate of SVM') tslib.hdx_switch(machine, 0, vms) tslib.forcepowerstate(machine, 'on', vms) windows_transitions.vm_hibernate_dom0(machine, vms) windows_transitions.vm_poweron(machine, vms) windows_transitions.wait_for_vms(machine,vms) log(2)
def shutdownSVM(machine,vms,steps,build,test_path,caller): log(1,'Shutdown of SVM') tslib.hdx_switch(machine, 0, vms) tslib.forcepowerstate(machine, 'on', vms) windows_transitions.vm_shutdown_dom0(machine, vms) sleep(10) windows_transitions.vm_poweron(machine, vms) log(2)
def forceShutPVM(machine,vms,steps,build,test_path,caller): log(1,'Force Shutdown of PVM') tslib.forcepowerstate(machine, 'on', vms) tslib.hdx_switch(machine, 1, vms) windows_transitions.vm_poweroff(machine, vms) sleep(10) windows_transitions.vm_poweron(machine, vms) log(2)
def hostShutdown(machine,vms,steps,build,test_path,caller): log(1,'Host Shutdown') tslib.forcepowerstate(machine, 'on', vms) power_control.xenmgr_shutdown(machine) sleep(30) power_control.set_s0(machine) wait_to_come_up(machine, timeout=15) windows_transitions.vm_poweron(machine) log(2)
def audioPassthrough(machine,vms,steps,build,test_path,caller): tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'add-pt-rule','0x0403','any','any'], host=machine) tslib.cmdResponse(r,'xec-vm -n <vmname> add-pt-rule 0x0403 any any') windows_transitions.vm_poweron(machine, vms) r = run(['xec-vm','-n',vms,'list-pt-pci-devices'], host=machine) tslib.cmdResponse(r,'xec-vm -n '+vms+' list-pt-pci-devices') tslib.interact(machine, "Verify if the o/p of list-pt-pci-devices is as expected") tslib.interact(machine, "Verify from the VM that a new audio device is detected. Install driver and proceed")
def disableusbPassthrough(machine,vms,steps,build,test_path,caller): (vendor_id1,device_id1,vendor_id2,device_id2) = getDeviceID(machine,vms,steps,build,test_path,caller) tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'delete-pt-rule','0x0c03',vendor_id1,device_id1], host=machine) tslib.cmdResponse(r, 'xec-vm -n vms delete-pt-rule 0x0c03'+vendor_id1+' '+device_id1) r = run(['xec-vm','-n',vms,'delete-pt-rule','0x0c03',vendor_id2,device_id2], host=machine) tslib.cmdResponse(r, 'xec-vm -n vms delete-pt-rule 0x0c03'+vendor_id2+' '+device_id2) windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Plugin a usb device and verify that it is not passed through to the VM")
def enableusbPassthrough(machine,vms,steps,build,test_path,caller): (vendor_id1,device_id1,vendor_id2,device_id2) = getDeviceID(machine,vms,steps,build,test_path,caller) tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'add-pt-rule','0x0c03',vendor_id1,device_id1], host=machine) tslib.cmdResponse(r, 'xec-vm -n vms add-pt-rule 0x0c03'+vendor_id1+' '+device_id1) r = run(['xec-vm','-n',vms,'add-pt-rule','0x0c03',vendor_id2,device_id2], host=machine) tslib.cmdResponse(r, 'xec-vm -n vms add-pt-rule 0x0c03'+vendor_id2+' '+device_id2) windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Perform VM reboot if required. Plugin a usb device and verify if the device is passed through to the VM")
def disableStubdom(machine,vms,steps,build,test_path,caller): status = run(['xec-vm','-n',vms,'get','stubdom'], host=machine) if 'false' in status: print "INFO: stubdom is already disabled, exiting.." exit() count = xenopslistcount(machine,vms) tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'set','stubdom','false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n'+vms+'set stubdom false') windows_transitions.vm_poweron(machine, vms) if not checkStubdom(machine,vms,count,1): tslib.pauseToDebug("qemu is either not running in dom0 or service VM have not stopped")
def nilfvm(machine,vms,steps,build,test_path,caller): tslib.forcepowerstate(machine, 'off', vms) r = run(['cd','/storage/nilfvm','nilfvm-create','--rootfs=nilfvm-rootfs.i686.cpio.bz2','--size=256','--config=service-nilfvm'], host=machine) tslib.cmdResponse(r, 'nilfvm-create --rootfs=nilfvm-rootfs.i686.cpio.bz2 --size=256 --config=service-nilfvm') vm_uuid = run(['xec-vm','-n',vms,'get','uuid'], host=machine) vm_uuid = vm_uuid.rstrip('\n') tslib.cmdResponse(vm_uuid, 'xec-vm -n '+vms+' get uuid') r = run(['xec-vm','-u',vm_uuid,'set','track-dependencies','true'], host=machine) tslib.cmdResponse(r, 'xec-vm -u '+vm_uuid+' set track-dependencies true') nilfvm_uuid = run(['xec-vm','-n',nilfvm01,'get','uuid'], host=machine) r = run(['xec-vm','-u',vm_uuid,'--nic','0','set','backend-uuid',nilfvm_uuid], host=machine) tslib.cmdResponse(r, 'xec-vm -u '+vm_uuid+' --nic 0 set backend-uuid '+nilfvm_uuid)
def policyAudio(machine,vms,steps,build,test_path,caller): tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'set','policy-audio-access','false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-audio-access false') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Play audio on the test VM and ensure that it fails") tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'set','policy-audio-access','true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-audio-access true') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Play audio on the test VM and ensure that audio plays")
def enableStubdom(machine, vms, steps, build, test_path, caller): status = run(['xec-vm', '-n', vms, 'get', 'stubdom'], host=machine) if 'true' in status: print "INFO: stubdom is already enabled, exiting.." exit() count = xenopslistcount(machine, vms) tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm', '-n', vms, 'set', 'stubdom', 'true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n' + vms + 'set stubdom true') windows_transitions.vm_poweron(machine, vms) if not checkStubdom(machine, vms, count, 0): tslib.pauseToDebug( "qemu is either running in dom0 or service VM have not started")
def hostSleep(machine,vms,steps,build,test_path,caller): log(1,'Host Sleep') if caller == 'PVM': tslib.hdx_switch(machine, 1, vms) if caller == 'SVM': tslib.hdx_switch(machine, 0, vms) if caller == 'noVM': tslib.forcepowerstate(machine, 'off', vms) else: tslib.forcepowerstate(machine, 'on', vms) sleep(5) power_control.xenmgr_sleep(machine) sleep(30) power_control.set_s0(machine) wait_to_come_up(machine, timeout=15) if caller != 'noVM': windows_transitions.wait_for_vms(machine,vms,timeout=15) log(2)
def audioPassthrough(machine, vms, steps, build, test_path, caller): tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm', '-n', vms, 'add-pt-rule', '0x0403', 'any', 'any'], host=machine) tslib.cmdResponse(r, 'xec-vm -n <vmname> add-pt-rule 0x0403 any any') windows_transitions.vm_poweron(machine, vms) r = run(['xec-vm', '-n', vms, 'list-pt-pci-devices'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' list-pt-pci-devices') tslib.interact(machine, "Verify if the o/p of list-pt-pci-devices is as expected") tslib.interact( machine, "Verify from the VM that a new audio device is detected. Install driver and proceed" )
def policyAudio(machine, vms, steps, build, test_path, caller): tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm', '-n', vms, 'set', 'policy-audio-access', 'false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-audio-access false') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Play audio on the test VM and ensure that it fails") tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm', '-n', vms, 'set', 'policy-audio-access', 'true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-audio-access true') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Play audio on the test VM and ensure that audio plays")
def disableSnapshot(machine,vms,steps,build,test_path,caller): dummy = str(random.randint(10000,20000)) vm_address = str(domain_address(machine, vms)) r = run(['xec-vm','-n',vms,'--disk','1','get','snapshot'], host=machine) if 'temporary' in r: tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'--disk','1','set','snapshot','none'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' --disk 1 set snapshot none') snapshot = run(['xec-vm','-n',vms,'--disk','1','get','snapshot'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' --disk 1 get snapshot') if 'none' not in snapshot: tslib.pauseToDebug("xec failed to disable snapshot") windows_transitions.vm_poweron(machine, vms) for i in range(2): windows_transitions.vm_reboot_dom0(machine, vms) res = run_via_exec_daemon(['mkdir','C:\\Users\\Administrator\\Desktop\\'+dummy],host=vm_address, wait=True) windows_transitions.vm_reboot_dom0(machine, vms) res = run_via_exec_daemon(['dir','C:\\Users\\Administrator\\Desktop\\'],host=vm_address, wait=True) if dummy not in res: tslib.pauseToDebug("Snapshot disabled: Old folders lost after reboot")
def enableusbPassthrough(machine, vms, steps, build, test_path, caller): (vendor_id1, device_id1, vendor_id2, device_id2) = getDeviceID(machine, vms, steps, build, test_path, caller) tslib.forcepowerstate(machine, 'off', vms) r = run( ['xec-vm', '-n', vms, 'add-pt-rule', '0x0c03', vendor_id1, device_id1], host=machine) tslib.cmdResponse( r, 'xec-vm -n vms add-pt-rule 0x0c03' + vendor_id1 + ' ' + device_id1) r = run( ['xec-vm', '-n', vms, 'add-pt-rule', '0x0c03', vendor_id2, device_id2], host=machine) tslib.cmdResponse( r, 'xec-vm -n vms add-pt-rule 0x0c03' + vendor_id2 + ' ' + device_id2) windows_transitions.vm_poweron(machine, vms) tslib.interact( machine, "Perform VM reboot if required. Plugin a usb device and verify if the device is passed through to the VM" )
def policyTests(machine,vms,steps,build,test_path,caller): #TODO USB policy to be added tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'set','policy-cd-access','false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-cd-access false') r = run(['xec-vm','-n',vms,'set','policy-print-screen','false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-print-screen false') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Verify that CD cannot be accessed from the VM") tslib.interact(machine, "Verify that print screen is disabled") tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'set','policy-cd-access','true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-cd-access true') r = run(['xec-vm','-n',vms,'set','policy-cd-recording','false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-cd-recording false') r = run(['xec-vm','-n',vms,'set','policy-modify-vm-settings','false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-modify-vm-settings false') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Verify that CD is accessible but cannot be burned from the VM") tslib.interact(machine, "Verify that VM settings cannot be modified") tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm','-n',vms,'set','policy-modify-vm-settings','true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-modify-vm-settings true') r = run(['xec-vm','-n',vms,'set','policy-cd-recording','true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-cd-recording true') r = run(['xec-vm','-n',vms,'set','policy-print-screen','true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n '+vms+' set policy-print-screen true') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Verify that CD can be accessed and burned from the VM") tslib.interact(machine, "Verify that VM settings can be modified") tslib.interact(machine, "Verify that print screen is enabled for the VM")
def disableusbPassthrough(machine, vms, steps, build, test_path, caller): (vendor_id1, device_id1, vendor_id2, device_id2) = getDeviceID(machine, vms, steps, build, test_path, caller) tslib.forcepowerstate(machine, 'off', vms) r = run([ 'xec-vm', '-n', vms, 'delete-pt-rule', '0x0c03', vendor_id1, device_id1 ], host=machine) tslib.cmdResponse( r, 'xec-vm -n vms delete-pt-rule 0x0c03' + vendor_id1 + ' ' + device_id1) r = run([ 'xec-vm', '-n', vms, 'delete-pt-rule', '0x0c03', vendor_id2, device_id2 ], host=machine) tslib.cmdResponse( r, 'xec-vm -n vms delete-pt-rule 0x0c03' + vendor_id2 + ' ' + device_id2) windows_transitions.vm_poweron(machine, vms) tslib.interact( machine, "Plugin a usb device and verify that it is not passed through to the VM" )
def upgradeBuild(machine,vms,steps,build,test_path,caller): build1, build2 = build.split(",") pxe_install_xc(machine, build1) install_guest(machine, vms) sleep(30) install_tools(machine, vms) sleep(30) windows_transitions.vm_reboot_dom0(machine, vms) run(['xec', 'set', 'wallpaper', 'images/wallpaper/s6.png'],host=machine) tslib.forcepowerstate(machine, 'on', vms) domlist = domains.find_guest_vms(machine) for domain in domlist: run(['xec-vm', '-n', domain['name'], 'set', 'vcpus', '2'],host=machine) run(['xec-vm', '-n', domain['name'], 'set', 'slot', '7'],host=machine) run(['xec-vm', '-n', domain['name'], 'set', 'memory', '1048'],host=machine) network_test.network_test_guest(machine, domain['name'], 'guest network test') network_test.network_test_dom0(machine, 'dom0 network test') tslib.forcepowerstate(machine, 'off', vms) pxe_install_xc(machine, build2, upgrade=True) currentBuild = get_build.get_build(machine) if (currentBuild != build): print "INFO: ERROR, UPRADE FAILED" wall = run(['xec', 'get', 'wallpaper'],host=machine) tslib.forcepowerstate(machine, 'on', vms) sleep(30) windows_transitions.vm_reboot_dom0(machine, vms) for domain in domlist: vcpu = run(['xec-vm', '-n', domain['name'], 'get', 'vcpus'],host=machine) slot = run(['xec-vm', '-n', domain['name'], 'get', 'slot'],host=machine) memo = run(['xec-vm', '-n', domain['name'], 'get', 'memory'],host=machine) network_test.network_test_guest(machine, domain['name'], 'guest network test') network_test.network_test_dom0(machine, 'dom0 network test') def report(txt,f): if(f): print 'INFO: '+txt+' PASS' else: print 'INFO: ERROR '+txt+' was reset' # Generate exception if (wall.rstrip('\n') != 'images/wallpaper/s6.png'): report('Wallpapwer',0) else : report('Wallpaper',1) if (vcpu.rstrip('\n') != '2'): report('vcpu',0) else : report('vcpu',1) if (slot.rstrip('\n') != '7'): report('slot',0) else : report('slot',1) if (memo.rstrip('\n') != '1048'): report('VM memory range',0) else : report('memory',1)
def policyTests(machine, vms, steps, build, test_path, caller): #TODO USB policy to be added tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm', '-n', vms, 'set', 'policy-cd-access', 'false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-cd-access false') r = run(['xec-vm', '-n', vms, 'set', 'policy-print-screen', 'false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-print-screen false') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Verify that CD cannot be accessed from the VM") tslib.interact(machine, "Verify that print screen is disabled") tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm', '-n', vms, 'set', 'policy-cd-access', 'true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-cd-access true') r = run(['xec-vm', '-n', vms, 'set', 'policy-cd-recording', 'false'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-cd-recording false') r = run(['xec-vm', '-n', vms, 'set', 'policy-modify-vm-settings', 'false'], host=machine) tslib.cmdResponse( r, 'xec-vm -n ' + vms + ' set policy-modify-vm-settings false') windows_transitions.vm_poweron(machine, vms) tslib.interact( machine, "Verify that CD is accessible but cannot be burned from the VM") tslib.interact(machine, "Verify that VM settings cannot be modified") tslib.forcepowerstate(machine, 'off', vms) r = run(['xec-vm', '-n', vms, 'set', 'policy-modify-vm-settings', 'true'], host=machine) tslib.cmdResponse( r, 'xec-vm -n ' + vms + ' set policy-modify-vm-settings true') r = run(['xec-vm', '-n', vms, 'set', 'policy-cd-recording', 'true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-cd-recording true') r = run(['xec-vm', '-n', vms, 'set', 'policy-print-screen', 'true'], host=machine) tslib.cmdResponse(r, 'xec-vm -n ' + vms + ' set policy-print-screen true') windows_transitions.vm_poweron(machine, vms) tslib.interact(machine, "Verify that CD can be accessed and burned from the VM") tslib.interact(machine, "Verify that VM settings can be modified") tslib.interact(machine, "Verify that print screen is enabled for the VM")
def enableHDX(machine,vms,steps,build,test_path,caller): log(1,'Enabling HDX on the VM') tslib.forcepowerstate(machine, 'on', vms) tslib.hdx_switch(machine, 1, vms) log(2)
def rebootSVM(machine,vms,steps,build,test_path,caller): log(1,'SVM reboot') tslib.hdx_switch(machine, 0, vms) tslib.forcepowerstate(machine, 'on', vms) windows_transitions.vm_reboot_dom0(machine, vms) log(2)
def hostReboot(machine,vms,steps,build,test_path,caller): log(1,'Host Reboot') tslib.forcepowerstate(machine, 'on', vms) power_control.reboot(machine) windows_transitions.vm_poweron(machine) log(2)
def xenopslistcount(machine, vm): tslib.forcepowerstate(machine, 'on', vm) r = run(['xenops', 'list'], host=machine) tslib.cmdResponse(r, 'xenops list') return len(string.split(r, '\n'))
def xenopslistcount(machine,vm): tslib.forcepowerstate(machine, 'on', vm) r = run(['xenops','list'], host=machine) tslib.cmdResponse(r, 'xenops list') return len(string.split(r,'\n'))
def deleteVM(machine,vms,steps,build,test_path,caller): log(1,'Deleting VM') tslib.forcepowerstate(machine, 'off', vms) run(['xec-vm', '-n', vms, 'delete'],host=machine)