From mboxrd@z Thu Jan 1 00:00:00 1970 From: Amos Kong Subject: Re: [Qemu-devel] [RFC PATCH 02/14] KVM Test: Add a function get_interface_name() to kvm_net_utils.py Date: Tue, 3 Aug 2010 09:39:43 +0800 Message-ID: <20100803013943.GB2365@z> References: <20100720013414.2212.13476.stgit@z> <20100720013506.2212.7371.stgit@z> <1280196535.4009.126.camel@freedom> <4C500682.1090106@redhat.com> Reply-To: Amos Kong Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: Lucas Meneghel Rodrigues , autotest@test.kernel.org, qemu-devel@nongnu.org, kvm@vger.kernel.org To: Michael Goldish Return-path: Received: from mx1.redhat.com ([209.132.183.28]:63129 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751178Ab0HCBjq (ORCPT ); Mon, 2 Aug 2010 21:39:46 -0400 Content-Disposition: inline In-Reply-To: <4C500682.1090106@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jul 28, 2010 at 01:29:22PM +0300, Michael Goldish wrote: > On 07/27/2010 05:08 AM, Lucas Meneghel Rodrigues wrote: > > On Tue, 2010-07-20 at 09:35 +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. > > > > I wonder if it wouldn't be overkill to have separate utility libraries > > on the kvm test instead of a single kvm_utils and kvm_test_utils like > > you are proposing. Any thoughts Michael? > > Yes, looks like this could be in kvm_test_utils.py, especially if > there's only a small number of functions here. Current functions of network are not too much, but we may add a lot of new utility functions in the future. It's more clear to use another file. > >> Signed-off-by: Jason Wang > >> Signed-off-by: Amos Kong > >> --- > >> 0 files changed, 0 insertions(+), 0 deletions(-) > >> > >> diff --git a/client/tests/kvm/kvm_net_utils.py b/client/tests/kvm/kvm_net_utils.py > >> new file mode 100644 > >> index 0000000..ede4965 > >> --- /dev/null > >> +++ b/client/tests/kvm/kvm_net_utils.py > >> @@ -0,0 +1,18 @@ > >> +import re > >> + > >> +def get_linux_ifname(session, mac_address): > >> + """ > >> + Get the interface name through the mac address. > >> + > >> + @param session: session to the virtual machine > >> + @mac_address: the macaddress of nic > >> + """ > >> + > >> + 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 > >> > >> > > > > > > -- > > To unsubscribe from this list: send the line "unsubscribe kvm" in > > the body of a message to majordomo@vger.kernel.org > > More majordomo info at http://vger.kernel.org/majordomo-info.html >