From patchwork Tue Jul 20 01:35:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 59259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 83407B6EEC for ; Tue, 20 Jul 2010 12:07:34 +1000 (EST) Received: from localhost ([127.0.0.1]:47165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ob1ud-0006BK-Jx for incoming@patchwork.ozlabs.org; Mon, 19 Jul 2010 21:46:27 -0400 Received: from [140.186.70.92] (port=51331 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ob1jl-0000zb-1L for qemu-devel@nongnu.org; Mon, 19 Jul 2010 21:35:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ob1jj-0003NB-Lk for qemu-devel@nongnu.org; Mon, 19 Jul 2010 21:35:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52444) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ob1jj-0003N4-AG for qemu-devel@nongnu.org; Mon, 19 Jul 2010 21:35:11 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6K1ZATf015193 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Jul 2010 21:35:10 -0400 Received: from [127.0.1.1] (dhcp-91-133.nay.redhat.com [10.66.91.133]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6K1Z7ka019918; Mon, 19 Jul 2010 21:35:08 -0400 To: lmr@redhat.com From: Amos Kong Date: Tue, 20 Jul 2010 09:35:06 +0800 Message-ID: <20100720013506.2212.7371.stgit@z> In-Reply-To: <20100720013414.2212.13476.stgit@z> References: <20100720013414.2212.13476.stgit@z> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: autotest@test.kernel.org, qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [RFC PATCH 02/14] KVM Test: Add a function get_interface_name() to kvm_net_utils.py X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 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