From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Meneghel Rodrigues Subject: Re: [Qemu-devel] [RFC PATCH 02/14] KVM Test: Add a function get_interface_name() to kvm_net_utils.py Date: Mon, 26 Jul 2010 23:08:55 -0300 Message-ID: <1280196535.4009.126.camel@freedom> References: <20100720013414.2212.13476.stgit@z> <20100720013506.2212.7371.stgit@z> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: autotest@test.kernel.org, qemu-devel@nongnu.org, kvm@vger.kernel.org To: Amos Kong Return-path: In-Reply-To: <20100720013506.2212.7371.stgit@z> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org 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? > 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 > > From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=60889 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OdZbJ-0005Nl-Te for qemu-devel@nongnu.org; Mon, 26 Jul 2010 22:09:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OdZbI-00047j-6r for qemu-devel@nongnu.org; Mon, 26 Jul 2010 22:09:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7833) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OdZbH-00047Y-V6 for qemu-devel@nongnu.org; Mon, 26 Jul 2010 22:09:00 -0400 Subject: Re: [Qemu-devel] [RFC PATCH 02/14] KVM Test: Add a function get_interface_name() to kvm_net_utils.py From: Lucas Meneghel Rodrigues In-Reply-To: <20100720013506.2212.7371.stgit@z> References: <20100720013414.2212.13476.stgit@z> <20100720013506.2212.7371.stgit@z> Content-Type: text/plain; charset="UTF-8" Date: Mon, 26 Jul 2010 23:08:55 -0300 Message-ID: <1280196535.4009.126.camel@freedom> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amos Kong Cc: autotest@test.kernel.org, Michael Goldish , qemu-devel@nongnu.org, kvm@vger.kernel.org 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? > 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 > >