On Mon, 2010-08-23 at 17:08 +0800, Amos Kong wrote:
> The function get_interface_name is used to get the interface name of linux
> guest through the macaddress of specified macaddress.
> 
> Signed-off-by: Jason Wang <[email protected]>
> Signed-off-by: Amos Kong <[email protected]>
> ---
>  0 files changed, 0 insertions(+), 0 deletions(-)
> 
> diff --git a/client/tests/kvm/kvm_test_utils.py 
> b/client/tests/kvm/kvm_test_utils.py
> index 53c11ae..8cd7acd 100644
> --- a/client/tests/kvm/kvm_test_utils.py
> +++ b/client/tests/kvm/kvm_test_utils.py
> @@ -481,3 +481,20 @@ def run_autotest(vm, session, control_path, timeout, 
> outputdir):
>              e_msg = ("Tests %s failed during control file execution" %
>                       " ".join(bad_results))
>          raise error.TestFail(e_msg)
> +
> +
> +def get_linux_ifname(session, mac_address):
> +    """
> +    Return the interface name through the mac address.
> +
> +    @param session: session to the virtual machine
> +    @mac_address: the macaddress of nic
> +    """

^ It occurred to me that this function could be named
get_linux_guest_ifname, for clarity. Also, the docstring could specify
'Return the linux guest interface name through its MAC adress'.

> +    output = session.get_command_output("ifconfig -a")
> +
> +    try:
> +        ethname = re.findall("(\w+)\s+Link.*%s" % mac_address, output,
> +                             re.IGNORECASE)[0]
> +        return ethname
> +    except:
> +        return None
> 
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest


_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to