pxe_boot.py 1.0 KB
Newer Older
1 2
import logging
from autotest.client.shared import error
3
from virttest import aexpect
4

L
Lucas Meneghel Rodrigues 已提交
5

X
Xu Tian 已提交
6
@error.context_aware
7
def run(test, params, env):
8 9 10
    """
    PXE test:

X
Xu Tian 已提交
11 12 13
    1) Boot up guest from NIC(from pxe/gpxe server)
    2) Snoop the tftp packet in the tap device
    3) Analyzing the tcpdump result
14

L
Lucas Meneghel Rodrigues 已提交
15 16 17
    :param test: QEMU test object.
    :param params: Dictionary with the test parameters.
    :param env: Dictionary with test environment.
18
    """
X
Xu Tian 已提交
19
    error.context("Try to boot from NIC", logging.info)
20 21 22 23
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = int(params.get("pxe_timeout", 60))

X
Xu Tian 已提交
24
    error.context("Snoop packet in the tap device", logging.info)
25
    output = aexpect.run_fg("tcpdump -nli %s" % vm.get_ifname(),
L
Lucas Meneghel Rodrigues 已提交
26
                            logging.debug, "(pxe capture) ", timeout)[1]
27

X
Xu Tian 已提交
28
    error.context("Analyzing the tcpdump result", logging.info)
29
    if "tftp" not in output:
L
Lucas Meneghel Rodrigues 已提交
30 31 32
        raise error.TestFail(
            "Couldn't find any TFTP packets after %s seconds" %
            timeout)
33
    logging.info("Found TFTP packet")