示例#1
0
文件: guest_ops.py 项目: OpenXT/bvt
def get_architecture(host,guest):
   if not is_acpi_state(host,guest,0):
       guest_start(host,guest)
       guest_switch(host,guest)
       wait_for_guest(host,guest)
   os = get_system_type(host,guest)

   if os == 'windows':
       unparsed = run_via_exec_daemon(['systeminfo'], host=domain_address(host,guest),line_split=True)
       for line in unparsed:
           if "System Type" in line:
               correct_line = line.split(" ")
               break
       if correct_line == None:
           print "ERR: Architecture not returned"
           raise InformationCollectionFailure()
       temp = correct_line
       correct_line = None
       for seg in temp:
           if any(char.isdigit() for char in seg):
               correct_line = seg
               break
       if correct_line == None:
           print "ERR: Architecture not returned"
           raise InformaitonCollectionFailure()
       Arch = re.sub("\D", "", correct_line)
       return Arch.strip()

   elif os == 'linux':
       return run(['uname','-m'],host=domain_address(host,guest),ignore_failure=True)[0].strip() 
   else:
       raise UnexpectedOs() 
示例#2
0
def vm_reinstate_hibernate(dut,who='all'):
    """used to reinstate hibernate after vm_sleep_self call"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(dut,domain['name'])
            call_exec_daemon('run', [r'powercfg -h on'], vmip)
示例#3
0
def wait_for_vms(machine, who='all', timeout=120):
    """wait for vm/vms to come up after a power operation"""
    domlist = find_guest_vms(machine)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(machine, domain['name'])
            wait_for_windows_to_come_up(vmip, timeout=timeout)
示例#4
0
def vm_sleep_self(dut, who='all'):
    """sleep vm/vms from within the VM"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(dut, domain['name'])
            print "turning off hibernate :" + str(call_exec_daemon(command='run', args=[r'powercfg -h off'], host=vmip, timeout=60))
            sleep(4)
            call_exec_daemon('run', [r'C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState sleep'], vmip)
示例#5
0
def vm_reboot_dom0(dut, who='all'):
    """reboot vm/vms from dom0"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            run(['xec-vm', '-n', domain['name'], 'reboot'], host=dut)
            vmip = domains.domain_address(dut, domain['name'])
            wait_for_windows_to_go_down(vmip)
            wait_for_windows_to_come_up(vmip)
示例#6
0
def vm_shutdown_self(dut, who='all'):
    """shutdown vm/vms from within the VM"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(dut, domain['name'])
            call_exec_daemon('run', ['shutdown -s'], host=vmip, timeout=60)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            wait_for_guest_to_go_down(dut, domain['name'])
示例#7
0
def vm_hibernate_self(dut, who='all'):
    """hibernate vm/vms from within the VM"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(dut, domain['name'])
            call_exec_daemon('run', [r'C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState hibernate'], host=vmip, timeout=60)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            wait_for_guest_to_go_down(dut, domain['name'])
示例#8
0
def vm_sleep_dom0(dut, who='all'):
    """sleep vm/vms from dom0"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            run(['xec-vm', '-n', domain['name'], 'sleep'], host=dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(dut, domain['name'])
            wait_for_windows_to_go_down(vmip)
示例#9
0
def soft_shutdown_guest(host, guest, timeout=DEFAULT_SHUTDOWN_TIMEOUT, method="exec_daemon"):
    """Shutdown guest using platform-specific method"""
    if is_stopped(host, guest):
        return True
    vm_address = domain_address(host, guest, timeout=5)
    if method == "exec_daemon":
        call_exec_daemon('shutdown', host=vm_address, timeout=20)
    elif method == "ssh":
        run(['shutdown', '-h', 'now'], host=vm_address, timeout=20, check_host_key=False)
    else:
        raise Exception("Unknown method %s" % method)
    wait_for_shutdown(host, guest, timeout=timeout)
    return True
示例#10
0
def vm_hibernate_self(dut, who='all'):
    """hibernate vm/vms from within the VM"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(dut, domain['name'])
            call_exec_daemon('run', [
                r'C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState hibernate'
            ],
                             host=vmip,
                             timeout=60)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            wait_for_guest_to_go_down(dut, domain['name'])
示例#11
0
def tools_install_problems(host, guest):
    """Return a string describing reasons why the tools install is bad or None
    if it is good for VM identified by host, guest pair"""
    bad = []
    vm_address = domain_address(host, guest, timeout=5)
    for m in XENCLIENT_MODULES:
        if not check_module_loaded(vm_address, m):
            bad.append("Module %s not loaded" % m)
    if bad == []:
        return
    message = ('tools not considered installed at this point because '+
               ' and '.join(bad))
    print 'INSTALL_TOOLS:', message
    return message
示例#12
0
def vm_sleep_self(dut, who='all'):
    """sleep vm/vms from within the VM"""
    domlist = find_guest_vms(dut)
    for domain in domlist:
        if who == 'all' or domain['name'] == who:
            vmip = domains.domain_address(dut, domain['name'])
            print "turning off hibernate :" + str(
                call_exec_daemon(command='run',
                                 args=[r'powercfg -h off'],
                                 host=vmip,
                                 timeout=60))
            sleep(4)
            call_exec_daemon('run', [
                r'C:\Windows\System32\rundll32.exe powrprof.dll,SetSuspendState sleep'
            ], vmip)
示例#13
0
def get_architecture(host, guest):
    if not is_acpi_state(host, guest, 0):
        guest_start(host, guest)
        guest_switch(host, guest)
        wait_for_guest(host, guest)
    os = get_system_type(host, guest)

    if os == 'windows':
        unparsed = run_via_exec_daemon(['systeminfo'],
                                       host=domain_address(host, guest),
                                       line_split=True)
        for line in unparsed:
            if "System Type" in line:
                correct_line = line.split(" ")
                break
        if correct_line == None:
            print "ERR: Architecture not returned"
            raise InformationCollectionFailure()
        temp = correct_line
        correct_line = None
        for seg in temp:
            if any(char.isdigit() for char in seg):
                correct_line = seg
                break
        if correct_line == None:
            print "ERR: Architecture not returned"
            raise InformaitonCollectionFailure()
        Arch = re.sub("\D", "", correct_line)
        return Arch.strip()

    elif os == 'linux':
        return run(['uname', '-m'],
                   host=domain_address(host, guest),
                   ignore_failure=True)[0].strip()
    else:
        raise UnexpectedOs()
示例#14
0
文件: XCXT.py 项目: OpenXT/bvt
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")         
示例#15
0
def stubdom_boot(dut, guest):
    """Test guest still boots on dut when running with studbom"""
    _, name = name_split(guest)
    vm_address = domain_address(dut, guest)
    run(['xec-vm', '-n', name, 'start'], host=dut)
    run(['xec-vm', '-n', name, 'switch'], host=dut)
    wait_for_windows_to_come_up(vm_address)
    shutdown_windows(vm_address)
    wait_for_vm_to_stop(dut, guest)
    status = find_domain(dut, guest)
    print 'INFO: domain status', status
    run(['xec-vm', '-n', name, 'set', 'cd', 'xc-tools.iso'], host=dut)
    run(['xec-vm', '-n', name, 'set', 'stubdom', 'true'], host=dut)
    print 'INFO: booting', guest, 'with stubdom'
    run(['xec-vm', '-n', name, 'start'], host=dut)
    run(['xec-vm', '-n', name, 'switch'], host=dut)
    wait_for_windows_to_come_up(vm_address)
    print 'HEADLINE: verified', guest, 'works with stubdom=true'
示例#16
0
def stubdom_boot(dut, guest):
    """Test guest still boots on dut when running with studbom"""
    _, name = name_split(guest)
    vm_address = domain_address(dut, guest)
    run(['xec-vm', '-n', name, 'start'], host=dut)
    run(['xec-vm', '-n', name, 'switch'], host=dut)
    wait_for_windows_to_come_up(vm_address)
    shutdown_windows(vm_address)
    wait_for_vm_to_stop(dut, guest)
    status = find_domain(dut, guest)
    print 'INFO: domain status', status
    run(['xec-vm', '-n', name, 'set', 'cd', 'xc-tools.iso'], host=dut)
    run(['xec-vm', '-n', name, 'set', 'stubdom', 'true'], host=dut)
    print 'INFO: booting', guest, 'with stubdom'
    run(['xec-vm', '-n', name, 'start'], host=dut)
    run(['xec-vm', '-n', name, 'switch'], host=dut)
    wait_for_windows_to_come_up(vm_address)
    print 'HEADLINE: verified', guest, 'works with stubdom=true'
示例#17
0
def soft_shutdown_guest(host,
                        guest,
                        timeout=DEFAULT_SHUTDOWN_TIMEOUT,
                        method="exec_daemon"):
    """Shutdown guest using platform-specific method"""
    if is_stopped(host, guest):
        return True
    vm_address = domain_address(host, guest, timeout=5)
    if method == "exec_daemon":
        call_exec_daemon('shutdown', host=vm_address, timeout=20)
    elif method == "ssh":
        run(['shutdown', '-h', 'now'],
            host=vm_address,
            timeout=20,
            check_host_key=False)
    else:
        raise Exception("Unknown method %s" % method)
    wait_for_shutdown(host, guest, timeout=timeout)
    return True
示例#18
0
文件: guest_ops.py 项目: OpenXT/bvt
def guest_disk_count(host,guest):
    """function to get the count of 'disks' the guest sees"""
    total_disk_count = 0
    os = get_system_type(host,guest)
    if os == 'windows':
        unparsed = run_via_exec_daemon(['echo', 'list', 'disk', '|', 'diskpart','|','find','"Disk"','|','find','"Online"'],host=domain_address(host, guest, timeout=5),line_split=True)
        #necessary as windows sometimes puts random blank lines at the end
        print "DEBUG: "+',,'.join(unparsed)
        for entry in unparsed:
            if "Disk" in entry:
                total_disk_count += 1
    elif os == 'linux':
        unparsed = run(['lsblk','-l','-o','NAME,TYPE'], host=domain_address(host, guest, timeout=5), timeout=20, check_host_key=False, line_split=True)
        for entry in unparsed:
            if "disk" in entry:
                total_disk_count += 1
    else:
        raise UnexpectedOs() 

    print "DEBUG: returning guest: \"%s\" has %d disks" % (guest,total_disk_count)
    return total_disk_count
示例#19
0
def tools_install_problems(host, guest):
    """Return a string describing reasons why the tools install is bad or None
    if it is good for VM identified by host, guest pair"""
    bad = []
    vm_address = domain_address(host, guest, timeout=5)
    msi_versions = get_msi_versions(vm_address)
    for msi in msi_versions:
        print 'INFO:', msi, 'is installed'
    for msi in EXPECTED_MSIS:
        if msi not in msi_versions:
            bad.append(msi + ' MSI not installed')
    services = get_running_services(vm_address)
    for service in services:
        print 'TOOLS: service', service, 'running'
    for service in EXPECTED_SERVICES:
        if service not in services:
            bad.append(service + ' not running')
    if bad == []:
        return
    message = ('tools not considered installed at this point because ' +
               ' and '.join(bad))
    print 'INSTALL_TOOLS:', message
    return message
示例#20
0
def tools_install_problems(host, guest):
    """Return a string describing reasons why the tools install is bad or None
    if it is good for VM identified by host, guest pair"""
    bad = []
    vm_address = domain_address(host, guest, timeout=5)
    msi_versions = get_msi_versions(vm_address)
    for msi in msi_versions:
        print 'INFO:', msi, 'is installed'
    for msi in EXPECTED_MSIS:
        if msi not in msi_versions:
            bad.append(msi+' MSI not installed')
    services = get_running_services(vm_address)
    for service in services:
        print 'TOOLS: service', service, 'running'
    for service in EXPECTED_SERVICES:
        if service not in services:
            bad.append(service+' not running')
    if bad == []:
        return
    message = ('tools not considered installed at this point because '+
               ' and '.join(bad))
    print 'INSTALL_TOOLS:', message
    return message
示例#21
0
 def get_address():
     """get address for VM """
     check_running()
     return domain_address(host, guest, timeout=5)
示例#22
0
 def get_address():
     """get address for VM """
     check_running()
     return domain_address(host, guest, timeout=5)
示例#23
0
文件: linux_guest.py 项目: OpenXT/bvt
def soft_reboot(dut, vm_name):
    domain = find_domain(dut, vm_name)
    print 'INFO: rebooting guest', domain
    vm_address = domain_address(dut, vm_name)
    run(['shutdown', '-r', 'now'], host=vm_address, check_host_key=False)
    wait_for_domid_change(dut, vm_name, domain['dom_id'])
示例#24
0
def soft_reboot(dut, vm_name):
    domain = find_domain(dut, vm_name)
    print 'INFO: rebooting guest', domain
    vm_address = domain_address(dut, vm_name)
    run(['shutdown', '-r', 'now'], host=vm_address, check_host_key=False)
    wait_for_domid_change(dut, vm_name, domain['dom_id'])